aboutsummaryrefslogtreecommitdiff
path: root/build2/cc/compile.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-06-16 16:22:48 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-06-16 16:22:48 +0200
commit5c8de4f515c99d894bec764a6793352c9cad0825 (patch)
tree6a590192c8010e19d9fa152058ba382ec160d603 /build2/cc/compile.cxx
parentf3e193b2651b2589daecaf181b96c5622acc51e9 (diff)
Add support for explicitly specifying module name on mxx{} target
Diffstat (limited to 'build2/cc/compile.cxx')
-rw-r--r--build2/cc/compile.cxx51
1 files changed, 31 insertions, 20 deletions
diff --git a/build2/cc/compile.cxx b/build2/cc/compile.cxx
index 265b1a9..c23eff2 100644
--- a/build2/cc/compile.cxx
+++ b/build2/cc/compile.cxx
@@ -2780,37 +2780,48 @@ namespace build2
continue;
// Find the mxx{} prerequisite and extract its "file name" for the
- // fuzzy match.
+ // fuzzy match unless the user specified the module name explicitly.
//
- string f;
for (prerequisite_member p: group_prerequisite_members (act, *pt))
{
if (p.is_a (*x_mod))
{
- //@@ MOD: TODO check if module name set? Won't we have to search
- // it for that? Search to existing only?
-
- // Add the directory part if it is relative. The idea is to
- // include it into the module match, say hello.core vs
- // hello/mxx{core}. Why not for absolute? Good question. What
- // if it contains special components, say, ../mxx{core}?
+ // Check for an explicit module name. Only look for an existing
+ // target (which means the name can only be specified on the
+ // target itself, no target type/pattern-spec).
//
- const dir_path& d (p.dir ());
+ const target* t (p.search_existing ());
+ const string* n (t != nullptr
+ ? cast_null<string> (t->vars[c_module_name])
+ : nullptr);
+ if (n != nullptr)
+ done = check (pt, *n, false);
+ else
+ {
+ // Fuzzy match.
+ //
+ string f;
- if (!d.empty () && d.relative ())
- f = d.representation (); // Includes trailing slash.
+ // Add the directory part if it is relative. The idea is to
+ // include it into the module match, say hello.core vs
+ // hello/mxx{core}.
+ //
+ // @@ MOD: Why not for absolute? Good question. What if it
+ // contains special components, say, ../mxx{core}?
+ //
+ const dir_path& d (p.dir ());
- f += p.name ();
+ if (!d.empty () && d.relative ())
+ f = d.representation (); // Includes trailing slash.
+
+ f += p.name ();
+ done = check (pt, f, true);
+ }
break;
}
}
- if (f.empty ()) // bmi{} without mxx{}? Good luck with that.
- continue;
-
- // Check if it resolves any of our imports.
- //
- if ((done = check (pt, f, true)))
+ if (done)
break;
}
@@ -2880,7 +2891,7 @@ namespace build2
info << "guessed: " << in <<
info << "actual: " << mn <<
info << "consider adjusting module interface file names or" <<
- info << "consider explicitly specifying module name with @@ MOD";
+ info << "consider specifying module name with cc.module_name";
}
}
}