aboutsummaryrefslogtreecommitdiff
path: root/build2/target.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'build2/target.cxx')
-rw-r--r--build2/target.cxx34
1 files changed, 32 insertions, 2 deletions
diff --git a/build2/target.cxx b/build2/target.cxx
index 43c6a41..89e16b5 100644
--- a/build2/target.cxx
+++ b/build2/target.cxx
@@ -308,7 +308,7 @@ namespace build2
if (de != nullptr)
ext = &extension_pool.find (de);
//
- // Otherwis see if the target type has function that will
+ // Otherwise see if the target type has function that will
// give us the default extension.
//
else if (auto f = type ().extension)
@@ -393,6 +393,36 @@ namespace build2
return t;
}
+ const string&
+ target_extension_fail (const target_key& tk, scope& s)
+ {
+ {
+ diag_record dr;
+ dr << error << "no default extension to derive file name for ";
+
+ // This is a bit hacky: we may be dealing with a target (see
+ // file::derive_path()) or prerequisite (see search_existing_file()). So
+ // we are going to check if dir is absolute. If it is, then we assume
+ // this is a target, otherwise -- prerequisite.
+ //
+ if (tk.dir->absolute ())
+ dr << "target " << tk;
+ else
+ dr << "prerequisite " << prerequisite_key {nullptr, tk, &s};
+ }
+
+ throw failed ();
+ }
+
+ // Assert if called.
+ //
+ const string&
+ target_extension_assert (const target_key&, scope&)
+ {
+ assert (false); // Attempt to obtain the default extension.
+ throw failed ();
+ }
+
// type info
//
@@ -525,7 +555,7 @@ namespace build2
"man",
&doc::static_type,
&man_factory,
- nullptr, // Should be specified explicitly.
+ &target_extension_assert, // Should be specified explicitly (see factory).
&search_file,
false
};