aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/functions-name.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2024-01-11 14:45:15 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2024-01-15 08:52:39 +0200
commit05ee8c20d83c2f108aa71a65e19b7adff8ff9aa0 (patch)
tree34f54b78150895a1bf1c93214a0b5cfc8203dd8f /libbuild2/functions-name.cxx
parent1d925696ac7eb8d7adb4d70b3f5afb010d745931 (diff)
Fail with unable to import rather than unknown target type
Diffstat (limited to 'libbuild2/functions-name.cxx')
-rw-r--r--libbuild2/functions-name.cxx34
1 files changed, 28 insertions, 6 deletions
diff --git a/libbuild2/functions-name.cxx b/libbuild2/functions-name.cxx
index fcb492f..456f85b 100644
--- a/libbuild2/functions-name.cxx
+++ b/libbuild2/functions-name.cxx
@@ -97,7 +97,18 @@ namespace build2
const target_type* ntt (to_target_type (s, n, o).first);
if (ntt == nullptr)
+ {
+ // If this is an imported target and the target type is unknown, then
+ // it cannot possibly match one of the known types. We handle it like
+ // this instead of failing because the later failure (e.g., as a
+ // result of this target listed as prerequisite) will have more
+ // accurate diagnostics. See also filter() below.
+ //
+ if (n.proj)
+ return false;
+
fail << "unknown target type " << n.type << " in " << n;
+ }
return ntt->is_a (*tt);
}
@@ -142,13 +153,24 @@ namespace build2
const target_type* ntt (to_target_type (s, c, p ? *++i : name ()).first);
if (ntt == nullptr)
- fail << "unknown target type " << n.type << " in " << n;
+ {
+ // If this is an imported target and the target type is unknown, then
+ // it cannot possibly match one of the known types. We handle it like
+ // this instead of failing because the later failure (e.g., as a
+ // result of this target listed as prerequisite) will have more
+ // accurate diagnostics. See also is_a() above.
+ //
+ if (!n.proj)
+ fail << "unknown target type " << n.type << " in " << n;
+ }
- if ((find_if (tts.begin (), tts.end (),
- [ntt] (const target_type* tt)
- {
- return ntt->is_a (*tt);
- }) != tts.end ()) != out)
+ if (ntt != nullptr
+ ? (find_if (tts.begin (), tts.end (),
+ [ntt] (const target_type* tt)
+ {
+ return ntt->is_a (*tt);
+ }) != tts.end ()) != out
+ : out)
{
r.push_back (move (n));
if (p)