From 7ef6c2f53b404ef74ab1f592652f34c8fcebad23 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 17 Aug 2016 14:54:55 +0200 Subject: Add config.bin.{prefix,suffix} convenience values These can be used to specify for both lib and exe. --- build2/bin/init.cxx | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/build2/bin/init.cxx b/build2/bin/init.cxx index 0db4400..1d87fd2 100644 --- a/build2/bin/init.cxx +++ b/build2/bin/init.cxx @@ -62,6 +62,8 @@ namespace build2 v.insert ("config.bin.libs.lib", true); v.insert ("config.bin.rpath", true); + v.insert ("config.bin.prefix", true); + v.insert ("config.bin.suffix", true); v.insert ("config.bin.lib.prefix", true); v.insert ("config.bin.lib.suffix", true); v.insert ("config.bin.exe.prefix", true); @@ -145,17 +147,25 @@ namespace build2 // config.build if not specified. We also override any existing value // that might have been specified before loading the module. // - if (const value* v = omitted (r, "config.bin.lib.prefix").first) - b.assign ("bin.lib.prefix") = *v; + { + const value* p (omitted (r, "config.bin.prefix").first); + const value* s (omitted (r, "config.bin.suffix").first); - if (const value* v = omitted (r, "config.bin.lib.suffix").first) - b.assign ("bin.lib.suffix") = *v; + auto set = [&r, &b] (const char* bv, const char* cv, const value* v) + { + if (const value* o = omitted (r, cv).first) + v = o; - if (const value* v = omitted (r, "config.bin.exe.prefix").first) - b.assign ("bin.exe.prefix") = *v; + if (v != nullptr) + b.assign (bv) = *v; + }; - if (const value* v = omitted (r, "config.bin.exe.suffix").first) - b.assign ("bin.exe.suffix") = *v; + set ("bin.lib.prefix", "config.bin.lib.prefix", p); + set ("bin.lib.suffix", "config.bin.lib.suffix", s); + + set ("bin.exe.prefix", "config.bin.exe.prefix", p); + set ("bin.exe.suffix", "config.bin.exe.suffix", s); + } if (first) { -- cgit v1.1