From 1dba8a7b279c857e9c13cbd6496849f5501e9944 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 26 Oct 2018 16:30:55 +0300 Subject: Add support for libpkgconf 1.5 API --- build2/cc/pkgconfig.cxx | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/build2/cc/pkgconfig.cxx b/build2/cc/pkgconfig.cxx index 26b0aea..79cd7bc 100644 --- a/build2/cc/pkgconfig.cxx +++ b/build2/cc/pkgconfig.cxx @@ -29,12 +29,50 @@ #include #include +#ifndef BUILD2_BOOTSTRAP + +// Note that the libpkgconf library doesn't provide the version macro that we +// could use to compile the code conditionally against different API versions. +// Thus, we need to sense the pkgconf_client_new() function signature +// ourselves to call it properly. +// +namespace details +{ + void* + pkgconf_cross_personality_default (); // Never called. +} + +using namespace details; + +template +static inline pkgconf_client_t* +call_pkgconf_client_new (pkgconf_client_t* (*f) (H, void*), + H error_handler, + void* error_handler_data) +{ + return f (error_handler, error_handler_data); +} + +template +static inline pkgconf_client_t* +call_pkgconf_client_new (pkgconf_client_t* (*f) (H, void*, P), + H error_handler, + void* error_handler_data) +{ + return f (error_handler, + error_handler_data, + ::pkgconf_cross_personality_default ()); +} + +#endif + using namespace std; using namespace butl; namespace build2 { #ifndef BUILD2_BOOTSTRAP + // Load package information from a .pc file. Filter out the -I/-L options // that refer to system directories. // @@ -275,8 +313,9 @@ namespace build2 // Initialize the client handle. // unique_ptr c ( - pkgconf_client_new (pkgconf_error_handler, - nullptr /* error_handler_data */), + call_pkgconf_client_new (&pkgconf_client_new, + pkgconf_error_handler, + nullptr /* handler_data */), [] (pkgconf_client_t* c) {pkgconf_client_free (c);}); pkgconf_client_set_flags (c.get (), pkgconf_flags); -- cgit v1.1