From becea217436a79b7ef37a023da6cb4c560225a71 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 2 Dec 2015 14:24:10 +0200 Subject: Redo extension derivation for file{}, doc{}, and cli{} We now first check the 'extension' variable, then use the default. --- build/target.txx | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'build/target.txx') 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 std::string& + const string& target_extension_fix (const target_key&, scope&) { return extension_pool.find (ext); } - template - const std::string& + template + 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 (*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 (*l)); + throw failed (); } } -- cgit v1.1