From 009e3bdd4743fb6bb74334ec5567f43830df1722 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 2 Nov 2018 12:21:42 +0200 Subject: Use rule-specific variables for module name set on bmi*{} targets --- build2/cc/compile-rule.cxx | 22 ++++++++++++---------- build2/cc/init.cxx | 5 +++-- build2/cc/pkgconfig.cxx | 7 ++++++- 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 (v) == mi.name); else v = move (mi.name); // Note: move. @@ -3607,7 +3607,8 @@ namespace build2 // if (bt->is_a ()) { - const string& n (cast (bt->vars[c_module_name])); + const string& n ( + cast (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 (bt->vars[c_module_name])); + if (n == nullptr) continue; @@ -3783,7 +3785,7 @@ namespace build2 if (m.score <= in.size ()) { - const string& mn (cast (bt->vars[c_module_name])); + const string& mn (cast (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 (et->vars[c_module_name])); + const string& mn (cast (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 (f.vars[c_module_name])); + s.insert (0, cast (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 (f.vars[c_module_name]))) + if (std_module (cast (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 ("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 ("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 (pt->vars[c_module_name]), + cast (pt->state[a].vars[c_module_name]), move (p), move (pp), symexport -- cgit v1.1