aboutsummaryrefslogtreecommitdiff
path: root/build2/cc
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-08-02 11:18:38 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-08-02 11:33:51 +0200
commite65c406301c3a7b30174f8706ba39584e80ddf25 (patch)
tree39ab598476f4965616979f498e016e3f7913008c /build2/cc
parente8ef2fbd339afd8113bd92d371bc49d7d570c32f (diff)
Save module map to pkg-config files
Diffstat (limited to 'build2/cc')
-rw-r--r--build2/cc/compile.cxx6
-rw-r--r--build2/cc/pkgconfig.cxx50
2 files changed, 54 insertions, 2 deletions
diff --git a/build2/cc/compile.cxx b/build2/cc/compile.cxx
index 6c3cc4c..9f36e8b 100644
--- a/build2/cc/compile.cxx
+++ b/build2/cc/compile.cxx
@@ -2766,8 +2766,8 @@ namespace build2
// name for each mxx{} explicitly. This will be a major pain, however.
// Another would be to require encoding of the module name in the
// interface unit file name. For example, hello.core -> hello-core.mxx.
- // This is better but will still too restrictive: some will want to call
- // it hello_core.mxx or HelloCore.mxx (because that's their file naming
+ // This is better but still too restrictive: some will want to call it
+ // hello_core.mxx or HelloCore.mxx (because that's their file naming
// convention) or place it in a subdirectory, say, hello/core.mxx.
//
// In the above examples one common theme about all the file names is
@@ -3010,6 +3010,8 @@ namespace build2
// available.
//
// @@ MOD: BMI compatibility check.
+ // @@ UTL: we need to (recursively) see through libux{} (and
+ // also in pkgconfig_save()).
//
if (bt != nullptr &&
(bt->is_a<bmis> () ||
diff --git a/build2/cc/pkgconfig.cxx b/build2/cc/pkgconfig.cxx
index 8d0ea25..d320060 100644
--- a/build2/cc/pkgconfig.cxx
+++ b/build2/cc/pkgconfig.cxx
@@ -733,6 +733,56 @@ namespace build2
os << endl;
+ // If we have modules, list them in the modules variable. This code
+ // is pretty similar to compiler::search_modules().
+ //
+ if (modules)
+ {
+ os << endl
+ << "modules =";
+
+ for (const target* pt: l.prerequisite_targets)
+ {
+ // @@ UTL: we need to (recursively) see through libux{} (and
+ // also in search_modules()).
+ //
+ if (pt != nullptr &&
+ (pt->is_a<bmis> () ||
+ pt->is_a<bmia> () ||
+ pt->is_a<bmie> ()))
+ {
+ // What we have is a binary module interface. What we need is
+ // a module interface source it was built from. We assume it's
+ // the first mxx{} target that we see.
+ //
+ const target* mt (nullptr);
+ for (const target* t: pt->prerequisite_targets)
+ {
+ if ((mt = t->is_a (*x_mod)))
+ break;
+ }
+
+ // Can/should there be a bmi{} without mxx{}? Can't think of a
+ // reason.
+ //
+ assert (mt != nullptr);
+
+ path p (install::resolve_file (mt->as<file> ()));
+
+ if (p.empty ()) // Not installed.
+ continue;
+
+ const string& n (cast<string> (pt->vars[c_module_name]));
+
+ // Module name shouldn't require escaping.
+ //
+ os << ' ' << n << '=' << escape (p.string ());
+ }
+ }
+
+ os << endl;
+ }
+
os.close ();
arm.cancel ();
}