From 907a284e955e22de8e78c838a873b0889b33a945 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 13 Aug 2016 17:11:30 +0200 Subject: Use extension derivation function rather than extension variable directly --- build2/cc/compile.cxx | 15 ++++++++++----- build2/target-type | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'build2') 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 (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. // -- cgit v1.1