aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-08-13 17:11:30 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-08-13 17:11:30 +0200
commit907a284e955e22de8e78c838a873b0889b33a945 (patch)
treeaacdd9369acbd0693301568d42f66445314d28ec
parent53eb43126e562a43f4e8f2247af10da5c4c3c87f (diff)
Use extension derivation function rather than extension variable directly
-rw-r--r--build2/cc/compile.cxx15
-rw-r--r--build2/target-type2
2 files changed, 11 insertions, 6 deletions
diff --git a/build2/cc/compile.cxx b/build2/cc/compile.cxx
index b5bcc50..92ddf3b 100644
--- a/build2/cc/compile.cxx
+++ b/build2/cc/compile.cxx
@@ -283,12 +283,17 @@ namespace build2
// We will just have to try all of the possible ones, in the "most
// likely to match" order.
//
- const variable& var (var_pool["extension"]);
-
- auto test = [&s, &n, &e, &var] (const target_type& tt) -> bool
+ auto test = [&s, &n, &e] (const target_type& tt) -> bool
{
- if (auto l = s.find (var, tt, n))
- if (cast<string> (l) == e)
+ // Call the extension derivation function. Here we know that it will
+ // only use the target type and name from the target key so we can
+ // pass bogus values for the rest.
+ //
+ const string* dummy (nullptr);
+ target_key tk {&tt, nullptr, nullptr, &n, dummy};
+
+ if (const string* de = tt.extension (tk, s))
+ if (*de == e)
return true;
return false;
diff --git a/build2/target-type b/build2/target-type
index 6140ab1..378fd7c 100644
--- a/build2/target-type
+++ b/build2/target-type
@@ -31,7 +31,7 @@ namespace build2
// respectively. If the extension function returns NULL, then that means the
// default extension for this target could not be derived.
//
- // The extension function is used in two places: search_existing_file()
+ // The extension is primarily used in two places: search_existing_file()
// (called for a prerequisite) and in target::derive_path() (called for a
// target); see their implementations for details.
//