diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2018-10-26 16:30:55 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2018-10-26 18:32:35 +0300 |
commit | 1dba8a7b279c857e9c13cbd6496849f5501e9944 (patch) | |
tree | 48776eb303d1934d482ed7fbc2acf271c5cff49c | |
parent | 8ababa51319753c5c697374c722bb01e845e3e68 (diff) |
Add support for libpkgconf 1.5 API
-rw-r--r-- | build2/cc/pkgconfig.cxx | 43 |
1 files 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 <build2/cc/compile-rule.hxx> #include <build2/cc/link-rule.hxx> +#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 <typename H> +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 <typename H, typename P> +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<pkgconf_client_t, void (*) (pkgconf_client_t*)> 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); |