aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/cc/pkgconfig.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-09-28 16:39:03 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-09-28 16:39:03 +0200
commite59b4fc15eef3b3d0af5b81190b1e54f270ee2d2 (patch)
treea5ed16c04977a4b79058ac4551b41b51b84f0305 /libbuild2/cc/pkgconfig.cxx
parentf96b437a0c0ff0a62b16d425d500496ffb76e70e (diff)
Omit -l for binless libraries, metadata from common .pc file
Having -l options for binless (header-only) libraries makes it unusable from other build systems. But omitting them could make the metadata incomplete (for example, importable headers), so we omit that as well.
Diffstat (limited to 'libbuild2/cc/pkgconfig.cxx')
-rw-r--r--libbuild2/cc/pkgconfig.cxx29
1 files changed, 26 insertions, 3 deletions
diff --git a/libbuild2/cc/pkgconfig.cxx b/libbuild2/cc/pkgconfig.cxx
index f36a7a7..5efab0d 100644
--- a/libbuild2/cc/pkgconfig.cxx
+++ b/libbuild2/cc/pkgconfig.cxx
@@ -1281,6 +1281,11 @@ namespace build2
// file must be generated based on the static library to get accurate
// Libs.private.
//
+ // The other things that we omit from the common variant are -l options
+ // for binless libraries (so that it's usable from other build systems) as
+ // well as metadata (which could become incomplete due the previous
+ // omissions; for example, importable headers metadata).
+ //
void link_rule::
pkgconfig_save (action a,
const file& l,
@@ -1562,7 +1567,8 @@ namespace build2
appended_libraries* pls; // Previous.
appended_libraries* ls; // Current.
strings& args;
- } d {os, nullptr, &ls, args};
+ bool common;
+ } d {os, nullptr, &ls, args, common};
auto imp = [&priv] (const target&, bool la) {return priv && la;};
@@ -1606,7 +1612,17 @@ namespace build2
if (l != nullptr)
{
if (l->is_a<libs> () || l->is_a<liba> ()) // See through libux.
- d.args.push_back (save_library_target (*l));
+ {
+ // Omit binless libraries from the common .pc file (see
+ // above).
+ //
+ // Note that in this case we still want to recursively
+ // traverse such libraries since they may still link to some
+ // non-binless system libraries (-lm, etc).
+ //
+ if (!d.common || !l->path ().empty ())
+ d.args.push_back (save_library_target (*l));
+ }
}
else
{
@@ -1687,8 +1703,15 @@ namespace build2
}
}
- // Save metadata.
+ // Save metadata unless this is the common .pc file (see above).
//
+ if (common)
+ {
+ os.close ();
+ arm.cancel ();
+ return;
+ }
+
// The build2.metadata variable is a general indication of the
// metadata being present. Its value is the metadata version
// optionally followed by the user metadata variable prefix and