aboutsummaryrefslogtreecommitdiff
path: root/build/target.txx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-12-02 14:24:10 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-12-02 14:45:13 +0200
commitbecea217436a79b7ef37a023da6cb4c560225a71 (patch)
tree5017f0ad3bc4d78ad737f4dc2b8b2036bb5f5664 /build/target.txx
parent685fe65f6b26b9e57c3d10cfe68c66d8baff8a68 (diff)
Redo extension derivation for file{}, doc{}, and cli{}
We now first check the 'extension' variable, then use the default.
Diffstat (limited to 'build/target.txx')
-rw-r--r--build/target.txx22
1 files changed, 14 insertions, 8 deletions
diff --git a/build/target.txx b/build/target.txx
index e347f77..89a402e 100644
--- a/build/target.txx
+++ b/build/target.txx
@@ -10,24 +10,27 @@
namespace build
{
template <const char* ext>
- const std::string&
+ const string&
target_extension_fix (const target_key&, scope&)
{
return extension_pool.find (ext);
}
- template <const char* var>
- const std::string&
+ template <const char* var, const char* def>
+ const string&
target_extension_var (const target_key& tk, scope& s)
{
// Include target type/pattern-specific variables.
//
- auto l (s.lookup (tk, var));
+ if (auto l = s.lookup (tk, var))
+ return extension_pool.find (as<string> (*l));
+
+ if (def != nullptr)
+ return extension_pool.find (def);
- if (!l)
{
diag_record dr;
- dr << fail << "no default extension in variable '" << var << "'"
+ dr << error << "no default extension in variable '" << var << "'"
<< info << "required to derive file name for ";
// This is a bit hacky: we may be dealing with a target (see
@@ -39,11 +42,14 @@ namespace build
dr << "target " << tk;
else
{
- const std::string* proj (nullptr); // Used for local prerequisites.
+ const string* proj (nullptr); // Used for local prerequisites.
dr << "prerequisite " << prerequisite_key {&proj, tk, &s};
}
+
+ dr << info << "perhaps you forgot to add "
+ << tk.type->name << "{*}: " << var << " = ...";
}
- return extension_pool.find (as<std::string> (*l));
+ throw failed ();
}
}