aboutsummaryrefslogtreecommitdiff
path: root/build2/cc/common.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-09-05 11:35:00 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-09-05 11:41:05 +0200
commitda863cd132e6d6024707027459b371c2bff9ca71 (patch)
tree7500f30cb662fbe01ad8e4dde858e45ca141b948 /build2/cc/common.cxx
parent9c0dc1f4957420688cf2c1afe79fa2f53f2a6abf (diff)
Adjust pkg-config logic to cover binless libraries
Diffstat (limited to 'build2/cc/common.cxx')
-rw-r--r--build2/cc/common.cxx64
1 files changed, 52 insertions, 12 deletions
diff --git a/build2/cc/common.cxx b/build2/cc/common.cxx
index 23c37ff..b20c2d8 100644
--- a/build2/cc/common.cxx
+++ b/build2/cc/common.cxx
@@ -532,7 +532,7 @@ namespace build2
bool l (p.is_a<lib> ());
const optional<string>& ext (l ? nullopt : p.tk.ext); // Only liba/libs.
- // Then figure out what we need to search for.
+ // First figure out what we need to search for.
//
const string& name (*p.tk.name);
@@ -613,10 +613,12 @@ namespace build2
liba* a (nullptr);
libs* s (nullptr);
+ pair<path, path> pc; // pkg-config .pc file paths.
+
path f; // Reuse the buffer.
const dir_path* pd (nullptr);
- auto search =[&a, &s,
+ auto search =[&a, &s, &pc,
&an, &ae,
&sn, &se,
&name, ext,
@@ -738,6 +740,39 @@ namespace build2
a = msvc_search_static (ld, d, p, exist);
}
+ // Look for binary-less libraries via pkg-config .pc files. Note that
+ // it is possible we have already found one of them as binfull but the
+ // other is binless.
+ //
+ {
+ bool na (a == nullptr && !an.empty ()); // Need static.
+ bool ns (s == nullptr && !sn.empty ()); // Need shared.
+
+ if (na || ns)
+ {
+ pair<path, path> r (pkgconfig_search (d, p.proj, name));
+
+ if (na && !r.first.empty ())
+ {
+ insert_library (a, name, d, nullopt, exist, trace);
+ a->mtime (timestamp_unreal);
+ a->path (empty_path);
+ }
+
+ if (ns && !r.second.empty ())
+ {
+ insert_library (s, name, d, nullopt, exist, trace);
+ s->mtime (timestamp_unreal);
+ s->path (empty_path);
+ }
+
+ // Only keep these .pc paths if we found anything via them.
+ //
+ if ((na && a != nullptr) || (ns && s != nullptr))
+ pc = move (r);
+ }
+ }
+
return a != nullptr || s != nullptr;
};
@@ -890,19 +925,24 @@ namespace build2
if (ll && (a != nullptr || s != nullptr))
{
- // Try to extract library information from pkg-config. We only add
- // the default macro if we could not extract more precise
- // information. The idea is that when we auto-generate .pc files, we
- // will copy those macros (or custom ones) from *.export.poptions.
+ // Try to extract library information from pkg-config. We only add the
+ // default macro if we could not extract more precise information. The
+ // idea is that in .pc files that we generate, we copy those macros
+ // (or custom ones) from *.export.poptions.
//
- if (!pkgconfig_load (act, *p.scope,
- *lt, a, s,
- p.proj, name,
- *pd, sysd, *usrd))
+ if (pc.first.empty () && pc.second.empty ())
{
- if (a != nullptr) add_macro (*a, "STATIC");
- if (s != nullptr) add_macro (*s, "SHARED");
+ if (!pkgconfig_load (act, *p.scope,
+ *lt, a, s,
+ p.proj, name,
+ *pd, sysd, *usrd))
+ {
+ if (a != nullptr) add_macro (*a, "STATIC");
+ if (s != nullptr) add_macro (*s, "SHARED");
+ }
}
+ else
+ pkgconfig_load (act, *p.scope, *lt, a, s, pc, *pd, sysd, *usrd);
}
// If we have the lock (meaning this is the first time), set the