aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/parser.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/parser.cxx
parent1d925696ac7eb8d7adb4d70b3f5afb010d745931 (diff)
Fail with unable to import rather than unknown target type
Diffstat (limited to 'libbuild2/parser.cxx')
-rw-r--r--libbuild2/parser.cxx21
1 files changed, 18 insertions, 3 deletions
diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx
index 71465f0..baf404a 100644
--- a/libbuild2/parser.cxx
+++ b/libbuild2/parser.cxx
@@ -2778,9 +2778,24 @@ namespace build2
optional<string>& e (rp.second);
if (t == nullptr)
- fail (ploc) << "unknown target type " << n.type <<
- info << "perhaps the module that defines this target type is "
- << "not loaded by project " << *scope_->root_scope ();
+ {
+ if (n.proj)
+ {
+ // If the target type is unknown then no phase 2 import (like
+ // rule-specific search) can possibly succeed so we can fail now and
+ // with a more accurate reason. See import2(names) for background.
+ //
+ diag_record dr;
+ dr << fail (ploc) << "unable to import target " << n;
+ import_suggest (dr, *n.proj, nullptr, string (), false);
+ }
+ else
+ {
+ fail (ploc) << "unknown target type " << n.type <<
+ info << "perhaps the module that defines this target type is "
+ << "not loaded by project " << *scope_->root_scope ();
+ }
+ }
if (t->factory == nullptr)
fail (ploc) << "abstract target type " << t->name << "{}";