aboutsummaryrefslogtreecommitdiff
path: root/build2/target.txx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-01-27 13:59:51 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-01-27 13:59:51 +0200
commita5949f9e974171144dba84771a9f305f9e1dcc3f (patch)
tree1e70c60d0c9daf4065e1163426c65b512d70c0c6 /build2/target.txx
parentbb171dd3fa145b15a6defd122b15be6822806e2b (diff)
Rework default extension derivation, again
Diffstat (limited to 'build2/target.txx')
-rw-r--r--build2/target.txx29
1 files changed, 5 insertions, 24 deletions
diff --git a/build2/target.txx b/build2/target.txx
index fbaa8ef..4999f61 100644
--- a/build2/target.txx
+++ b/build2/target.txx
@@ -10,14 +10,14 @@
namespace build2
{
template <const char* ext>
- const string&
+ const string*
target_extension_fix (const target_key&, scope&)
{
- return extension_pool.find (ext);
+ return &extension_pool.find (ext);
}
template <const char* var, const char* def>
- const string&
+ const string*
target_extension_var (const target_key& tk, scope& s)
{
// Include target type/pattern-specific variables.
@@ -27,29 +27,10 @@ namespace build2
// Help the user here and strip leading '.' from the extension.
//
const string& e (as<string> (*l));
- return extension_pool.find (
+ return &extension_pool.find (
!e.empty () && e.front () == '.' ? string (e, 1) : e);
}
- if (def != nullptr)
- return extension_pool.find (def);
-
- // Similar code to target_extension_fail().
- //
- {
- diag_record dr;
- dr << error << "no default extension in variable '" << var << "'"
- << info << "required to derive file name for ";
-
- if (tk.dir->absolute ())
- dr << "target " << tk;
- else
- dr << "prerequisite " << prerequisite_key {nullptr, tk, &s};
-
- dr << info << "perhaps you forgot to add "
- << tk.type->name << "{*}: " << var << " = ...";
- }
-
- throw failed ();
+ return def != nullptr ? &extension_pool.find (def) : nullptr;
}
}