diff options
-rw-r--r-- | libbuild2/cc/functions.cxx | 8 | ||||
-rw-r--r-- | libbuild2/functions-name.cxx | 16 | ||||
-rw-r--r-- | libbuild2/functions-name.hxx | 7 | ||||
-rw-r--r-- | libbuild2/functions-target.cxx | 11 |
4 files changed, 31 insertions, 11 deletions
diff --git a/libbuild2/cc/functions.cxx b/libbuild2/cc/functions.cxx index 9d408af..0adcf5f 100644 --- a/libbuild2/cc/functions.cxx +++ b/libbuild2/cc/functions.cxx @@ -76,7 +76,9 @@ namespace build2 for (auto i (ts_ns.begin ()); i != ts_ns.end (); ++i) { name& n (*i), o; - const target& t (to_target (*bs, move (n), move (n.pair ? *++i : o))); + const target& t (to_target (*bs, + move (n), move (n.pair ? *++i : o), + true /* in_recipe */)); if (!t.matched (a)) fail << t << " is not matched" << @@ -193,7 +195,9 @@ namespace build2 for (auto i (ts_ns.begin ()); i != ts_ns.end (); ++i) { name& n (*i), o; - const target& t (to_target (*bs, move (n), move (n.pair ? *++i : o))); + const target& t (to_target (*bs, + move (n), move (n.pair ? *++i : o), + true /* in_recipe */)); bool la (false); if (li diff --git a/libbuild2/functions-name.cxx b/libbuild2/functions-name.cxx index 456f85b..cb32d09 100644 --- a/libbuild2/functions-name.cxx +++ b/libbuild2/functions-name.cxx @@ -49,7 +49,10 @@ namespace build2 } const target& - to_target (const scope& s, name&& n, name&& o) + to_target (const scope& s, + name&& n, name&& o, + bool in_recipe, + const location& loc) { // Note: help the user out and search in both out and src like a // prerequisite. @@ -62,13 +65,13 @@ namespace build2 // bool typed (n.typed ()); - diag_record dr (fail); + diag_record dr (fail (loc)); dr << "target " << (n.pair ? names {move (n), move (o)} : names {move (n)}) << " not found"; - if (!typed) + if (in_recipe && !typed) dr << info << "wrap it in ([names] ...) if this is literal target name " << "specified inside recipe"; @@ -76,12 +79,15 @@ namespace build2 } const target& - to_target (const scope& s, names&& ns) + to_target (const scope& s, names&& ns, bool in_recipe, const location& loc) { assert (ns.size () == (ns[0].pair ? 2 : 1)); name o; - return to_target (s, move (ns[0]), move (ns[0].pair ? ns[1] : o)); + return to_target (s, + move (ns[0]), move (ns[0].pair ? ns[1] : o), + in_recipe, + loc); } static bool diff --git a/libbuild2/functions-name.hxx b/libbuild2/functions-name.hxx index 34fa4b8..30fc8ad 100644 --- a/libbuild2/functions-name.hxx +++ b/libbuild2/functions-name.hxx @@ -18,13 +18,16 @@ namespace build2 // Resolve the name to target issuing diagnostics and failing if not found. // LIBBUILD2_SYMEXPORT const target& - to_target (const scope&, name&&, name&& out); + to_target (const scope&, + name&&, name&& out, + bool in_recipe, + const location& = {}); // As above but from the names vector which should contain a single name // or an out-qualified name pair (asserted). // LIBBUILD2_SYMEXPORT const target& - to_target (const scope&, names&&); + to_target (const scope&, names&&, bool in_recipe, const location& = {}); } #endif // LIBBUILD2_FUNCTIONS_NAME_HXX diff --git a/libbuild2/functions-target.cxx b/libbuild2/functions-target.cxx index c7cb50e..55baeda 100644 --- a/libbuild2/functions-target.cxx +++ b/libbuild2/functions-target.cxx @@ -35,6 +35,8 @@ namespace build2 if (s == nullptr) fail << "target.path() called out of scope"; + context& ctx (s->ctx); + // Most of the time we will have a single target so optimize for that. // small_vector<path, 1> r; @@ -42,7 +44,10 @@ namespace build2 for (auto i (ns.begin ()); i != ns.end (); ++i) { name& n (*i), o; - const target& t (to_target (*s, move (n), move (n.pair ? *++i : o))); + const target& t ( + to_target (*s, + move (n), move (n.pair ? *++i : o), + ctx.phase != run_phase::load /* in_recipe */)); if (const auto* pt = t.is_a<path_target> ()) { @@ -94,7 +99,9 @@ namespace build2 name o; const target& t ( - to_target (*s, move (ns[0]), move (ns[0].pair ? ns[1] : o))); + to_target (*s, + move (ns[0]), move (ns[0].pair ? ns[1] : o), + s->ctx.phase != run_phase::load /* in_recipe */)); if (const auto* et = t.is_a<exe> ()) { |