aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-11-02 12:21:42 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-11-02 12:21:42 +0200
commit009e3bdd4743fb6bb74334ec5567f43830df1722 (patch)
tree5dc72aedca8fdaa854d65801b91f9a12ea99a4e0
parent9bbdade4a502f72d1d5a25d6ace2f6545c2658b0 (diff)
Use rule-specific variables for module name set on bmi*{} targets
-rw-r--r--build2/cc/compile-rule.cxx22
-rw-r--r--build2/cc/init.cxx5
-rw-r--r--build2/cc/pkgconfig.cxx7
3 files changed, 21 insertions, 13 deletions
diff --git a/build2/cc/compile-rule.cxx b/build2/cc/compile-rule.cxx
index d0ef61a..1136cbe 100644
--- a/build2/cc/compile-rule.cxx
+++ b/build2/cc/compile-rule.cxx
@@ -3273,14 +3273,14 @@ namespace build2
break;
}
- // Set the cc.module_name variable if this is an interface unit. Note
- // that it may seem like a good idea to set it on the bmi{} group to
- // avoid duplication. We, however, cannot do it MT-safely since we don't
- // match the group.
+ // Set the cc.module_name rule-specific variable if this is an interface
+ // unit. Note that it may seem like a good idea to set it on the bmi{}
+ // group to avoid duplication. We, however, cannot do it MT-safely since
+ // we don't match the group.
//
if (mi.iface)
{
- if (value& v = t.vars.assign (c_module_name))
+ if (value& v = t.state[a].assign (c_module_name))
assert (cast<string> (v) == mi.name);
else
v = move (mi.name); // Note: move.
@@ -3607,7 +3607,8 @@ namespace build2
//
if (bt->is_a<bmix> ())
{
- const string& n (cast<string> (bt->vars[c_module_name]));
+ const string& n (
+ cast<string> (bt->state[a].vars[c_module_name]));
if (const target** p = check_exact (n))
*p = bt;
@@ -3622,6 +3623,7 @@ namespace build2
// something else is going on and ignore.
//
const string* n (cast_null<string> (bt->vars[c_module_name]));
+
if (n == nullptr)
continue;
@@ -3783,7 +3785,7 @@ namespace build2
if (m.score <= in.size ())
{
- const string& mn (cast<string> (bt->vars[c_module_name]));
+ const string& mn (cast<string> (bt->state[a].vars[c_module_name]));
if (in != mn)
{
@@ -3827,7 +3829,7 @@ namespace build2
if (et == nullptr)
continue; // Unresolved (std.*).
- const string& mn (cast<string> (et->vars[c_module_name]));
+ const string& mn (cast<string> (et->state[a].vars[c_module_name]));
if (find_if (imports.begin (), imports.end (),
[&mn] (const module_import& i)
@@ -4136,7 +4138,7 @@ namespace build2
else
{
s.insert (0, 1, '=');
- s.insert (0, cast<string> (f.vars[c_module_name]));
+ s.insert (0, cast<string> (f.state[a].vars[c_module_name]));
s.insert (0, "-fmodule-file=");
}
@@ -4169,7 +4171,7 @@ namespace build2
// specified with the IFCPATH environment variable or the
// /module:stdIfcDir option.
//
- if (std_module (cast<string> (f.vars[c_module_name])))
+ if (std_module (cast<string> (f.state[a].vars[c_module_name])))
{
dir_path d (f.path ().directory ());
diff --git a/build2/cc/init.cxx b/build2/cc/init.cxx
index bb0269c..183802f 100644
--- a/build2/cc/init.cxx
+++ b/build2/cc/init.cxx
@@ -124,8 +124,9 @@ namespace build2
//
v.insert<bool> ("cc.system", v_t);
- // C++ module name. Should be set on the bmi*{} target by the matching
- // rule.
+ // C++ module name. Set on the bmi*{} target as a rule-specific variable
+ // by the matching rule. Can also be set by the user (normally via the
+ // x.module_name alias) on the x_mod{} source.
//
v.insert<string> ("cc.module_name", v_t);
diff --git a/build2/cc/pkgconfig.cxx b/build2/cc/pkgconfig.cxx
index 79cd7bc..1630076 100644
--- a/build2/cc/pkgconfig.cxx
+++ b/build2/cc/pkgconfig.cxx
@@ -1077,6 +1077,11 @@ namespace build2
// exist but for a "different purpose" (e.g., it could be used as
// a header).
//
+ // @@ Could setting it in the rule-specific vars help? (But we
+ // are not matching a rule for it.) Note that we are setting
+ // it on the module source, not bmi*{}! So rule-specific vars
+ // don't seem to the answer here.
+ //
if (tl.second.owns_lock ())
{
mt.vars.assign (c_module_name) = move (mn);
@@ -1486,7 +1491,7 @@ namespace build2
modules.push_back (
module {
- cast<string> (pt->vars[c_module_name]),
+ cast<string> (pt->state[a].vars[c_module_name]),
move (p),
move (pp),
symexport