From 42131c57e7bc35765d94446f0be356bbceaf525b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 5 Sep 2018 17:36:20 +0200 Subject: Only consider common .pc file for binless variant if there is no binfull --- build2/cc/common.cxx | 6 +++++- build2/cc/common.hxx | 3 ++- build2/cc/pkgconfig.cxx | 36 +++++++++++++++++++++++------------- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/build2/cc/common.cxx b/build2/cc/common.cxx index b20c2d8..6a1698e 100644 --- a/build2/cc/common.cxx +++ b/build2/cc/common.cxx @@ -750,7 +750,11 @@ namespace build2 if (na || ns) { - pair r (pkgconfig_search (d, p.proj, name)); + // Only consider the common .pc file if we can be sure there + // is no binfull variant. + // + pair r ( + pkgconfig_search (d, p.proj, name, na && ns /* common */)); if (na && !r.first.empty ()) { diff --git a/build2/cc/common.hxx b/build2/cc/common.hxx index 2a1a2dd..deed573 100644 --- a/build2/cc/common.hxx +++ b/build2/cc/common.hxx @@ -311,7 +311,8 @@ namespace build2 pair pkgconfig_search (const dir_path&, const optional&, - const string&) const; + const string&, + bool) const; void pkgconfig_load (action, const scope&, diff --git a/build2/cc/pkgconfig.cxx b/build2/cc/pkgconfig.cxx index 9a4f002..10f8cce 100644 --- a/build2/cc/pkgconfig.cxx +++ b/build2/cc/pkgconfig.cxx @@ -485,12 +485,14 @@ namespace build2 // Search for the .pc files in the pkgconf directories that correspond to // the specified library directory. If found, return static (first) and - // shared (second) library .pc files. + // shared (second) library .pc files. If common is false, then only + // consider our .static/.shared files. // pair common:: pkgconfig_search (const dir_path& libd, const optional& proj, - const string& stem) const + const string& stem, + bool common) const { // When it comes to looking for .pc files we have to decide where to // search (which directory(ies)) as well as what to search for (which @@ -541,30 +543,36 @@ namespace build2 return path (); }; - pair r; - // Return false (and so stop the iteration) if a .pc file is found. // // Note that we rely on the "small function object" optimization here. // - auto check = [&r, &search_dir] (dir_path&& d) -> bool + struct data + { + pair r; + bool common; + } d {{}, common}; + + auto check = [&d, &search_dir] (dir_path&& p) -> bool { // First look for static/shared-specific files. // - r.first = search_dir (d, ".static"); - r.second = search_dir (d, ".shared"); + d.r.first = search_dir (p, ".static"); + d.r.second = search_dir (p, ".shared"); - if (!r.first.empty () || !r.second.empty ()) + if (!d.r.first.empty () || !d.r.second.empty ()) return false; // Then the common. // - r.first = r.second = search_dir (d, string ()); - return r.first.empty (); + if (d.common) + d.r.first = d.r.second = search_dir (p, string ()); + + return d.r.first.empty (); }; pkgconfig_search (libd, check); - return r; + return d.r; }; bool common:: @@ -581,7 +589,8 @@ namespace build2 { assert (at != nullptr || st != nullptr); - pair p (pkgconfig_search (libd, proj, stem)); + pair p ( + pkgconfig_search (libd, proj, stem, true /* common */)); if (p.first.empty () && p.second.empty ()) return false; @@ -1120,7 +1129,8 @@ namespace build2 pair common:: pkgconfig_search (const dir_path&, const optional&, - const string&) const + const string&, + bool) const { return pair (); } -- cgit v1.1