aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/cc
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-12-08 11:13:37 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-12-08 11:13:37 +0200
commit3c40652f128e7d20e92e595495bb09691edb7a43 (patch)
treec50f03f414d7c0ffe2748b83390359513e1b1959 /libbuild2/cc
parent5a25de484f6569e4ba8aa181efa9653cd0e0cd4e (diff)
Update pkg-config modules serialization format to handle partitions
Diffstat (limited to 'libbuild2/cc')
-rw-r--r--libbuild2/cc/pkgconfig.cxx31
1 files changed, 27 insertions, 4 deletions
diff --git a/libbuild2/cc/pkgconfig.cxx b/libbuild2/cc/pkgconfig.cxx
index 35ba2d8..f0a5e0c 100644
--- a/libbuild2/cc/pkgconfig.cxx
+++ b/libbuild2/cc/pkgconfig.cxx
@@ -1134,7 +1134,8 @@ namespace build2
string m;
for (size_t b (0), e (0); !(m = next (mstr, b, e)).empty (); )
{
- // The format is <name>=<path>.
+ // The format is <name>=<path> with `..` used as a partition
+ // separator (see pkgconfig_save() for details).
//
size_t p (m.find ('='));
if (p == string::npos ||
@@ -1153,6 +1154,11 @@ namespace build2
string pp (pc.variable ("cxx_module_preprocessed." + mn));
string se (pc.variable ("cxx_module_symexport." + mn));
+ // Replace the partition separator.
+ //
+ if ((p = mn.find ("..")) != string::npos)
+ mn.replace (p, 2, 1, ':');
+
// For now there are only C++ modules.
//
auto tl (
@@ -1594,7 +1600,11 @@ namespace build2
};
vector<module> modules;
- for (const target* pt: g.prerequisite_targets[a])
+ // Note that the prerequisite targets are in the member, not the
+ // group (for now we don't support different sets of modules for
+ // static/shared library; see load above for details).
+ //
+ for (const target* pt: l.prerequisite_targets[a])
{
// @@ UTL: we need to (recursively) see through libu*{} (and
// also in search_modules()).
@@ -1641,10 +1651,23 @@ namespace build2
os << endl
<< "cxx_modules =";
- // Module names shouldn't require escaping.
+ // The partition separator (`:`) is not a valid character in the
+ // variable name. In fact, from the pkg-config source we can see
+ // that the only valid special characters in variable names are
+ // `_` and `.`. So to represent partition separators we use `..`,
+ // for example hello.print..impl. While in the variable values we
+ // can use `:`, for consistency we use `..` there as well.
//
- for (const module& m: modules)
+ for (module& m: modules)
+ {
+ size_t p (m.name.find (':'));
+ if (p != string::npos)
+ m.name.replace (p, 1, 2, '.');
+
+ // Module names shouldn't require escaping.
+ //
os << ' ' << m.name << '=' << escape (m.file.string ());
+ }
os << endl;