From dc46fa754baa446d5428ba38db0d637a17b91c57 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 17 Aug 2016 12:53:37 +0200 Subject: Add support for config.bin.{lib,exe}.{prefix,suffix} This replaces the bin.libprefix functionality. --- build2/bin/init.cxx | 46 +++++++++++++++++++++++++++++++++------------- build2/cc/link.cxx | 18 +++++++++++------- build2/cc/module.cxx | 2 +- build2/config/utility | 6 +++--- build2/config/utility.cxx | 4 ++-- build2/config/utility.txx | 3 +-- 6 files changed, 51 insertions(+), 28 deletions(-) diff --git a/build2/bin/init.cxx b/build2/bin/init.cxx index 102c060..0db4400 100644 --- a/build2/bin/init.cxx +++ b/build2/bin/init.cxx @@ -45,7 +45,7 @@ namespace build2 tracer trace ("bin::config_init"); l5 ([&]{trace << "for " << b.out_path ();}); - // Enter configuration variables. + // Enter variables. // if (first) { @@ -62,17 +62,28 @@ namespace build2 v.insert ("config.bin.libs.lib", true); v.insert ("config.bin.rpath", true); + v.insert ("config.bin.lib.prefix", true); + v.insert ("config.bin.lib.suffix", true); + v.insert ("config.bin.exe.prefix", true); + v.insert ("config.bin.exe.suffix", true); + v.insert ("bin.lib"); v.insert ("bin.exe.lib"); v.insert ("bin.liba.lib"); v.insert ("bin.libs.lib"); v.insert ("bin.rpath"); + + v.insert ("bin.lib.prefix"); + v.insert ("bin.lib.suffix"); + v.insert ("bin.exe.prefix"); + v.insert ("bin.exe.suffix"); } // Configure. // using config::required; using config::optional; + using config::omitted; // Adjust module priority (binutils). // @@ -128,6 +139,24 @@ namespace build2 b.assign ("bin.rpath") += cast_null ( optional (r, "config.bin.rpath")); + // config.bin.{lib,exe}.{prefix,suffix} + // + // These ones are not used very often so we will omit them from the + // 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; + + if (const value* v = omitted (r, "config.bin.lib.suffix").first) + b.assign ("bin.lib.suffix") = *v; + + if (const value* v = omitted (r, "config.bin.exe.prefix").first) + b.assign ("bin.exe.prefix") = *v; + + if (const value* v = omitted (r, "config.bin.exe.suffix").first) + b.assign ("bin.exe.suffix") = *v; + if (first) { bool new_val (false); // Set any new values? @@ -140,7 +169,7 @@ namespace build2 // We first see if the value was specified via the configuration // mechanism. // - auto p (required (r, var)); + auto p (omitted (r, var)); const value* v (p.first); // Then see if there is a config hint (e.g., from the C++ module). @@ -216,7 +245,7 @@ namespace build2 // We first see if the value was specified via the configuration // mechanism. // - auto p (required (r, var)); + auto p (omitted (r, var)); const value* v (p.first); // Then see if there is a config hint (e.g., from the C++ module). @@ -266,22 +295,13 @@ namespace build2 scope& b, const location& loc, unique_ptr&, - bool first, + bool, bool, const variable_map& hints) { tracer trace ("bin::init"); l5 ([&]{trace << "for " << b.out_path ();}); - // Enter the rest of the variables. - // - if (first) - { - auto& v (var_pool); - - v.insert ("bin.libprefix", true); - } - // Load bin.config. // if (!cast_false (b["bin.config.loaded"])) diff --git a/build2/cc/link.cxx b/build2/cc/link.cxx index 4bebc6f..df1fa7e 100644 --- a/build2/cc/link.cxx +++ b/build2/cc/link.cxx @@ -651,8 +651,9 @@ namespace build2 // if (t.path ().empty ()) { - const char* p (nullptr); - const char* e (nullptr); + const char* p (nullptr); // Prefix. + const char* s (nullptr); // Suffix. + const char* e (nullptr); // Extension. switch (lt) { @@ -663,6 +664,9 @@ namespace build2 else e = ""; + if (auto l = t["bin.exe.prefix"]) p = cast (l).c_str (); + if (auto l = t["bin.exe.suffix"]) s = cast (l).c_str (); + break; } case otype::a: @@ -681,8 +685,8 @@ namespace build2 e = "a"; } - if (auto l = t["bin.libprefix"]) - p = cast (l).c_str (); + if (auto l = t["bin.lib.prefix"]) p = cast (l).c_str (); + if (auto l = t["bin.lib.suffix"]) s = cast (l).c_str (); break; } @@ -710,14 +714,14 @@ namespace build2 e = "so"; } - if (auto l = t["bin.libprefix"]) - p = cast (l).c_str (); + if (auto l = t["bin.lib.prefix"]) p = cast (l).c_str (); + if (auto l = t["bin.lib.suffix"]) s = cast (l).c_str (); break; } } - t.derive_path (e, p); + t.derive_path (e, p, s); } // Add ad hoc group members. diff --git a/build2/cc/module.cxx b/build2/cc/module.cxx index 74c07e2..ec7178b 100644 --- a/build2/cc/module.cxx +++ b/build2/cc/module.cxx @@ -61,7 +61,7 @@ namespace build2 // default value every time will be a waste. So try without a default // first. // - auto p (config::required (r, config_x)); + auto p (config::omitted (r, config_x)); if (p.first == nullptr) { diff --git a/build2/config/utility b/build2/config/utility index d11a38b..aa7dc7e 100644 --- a/build2/config/utility +++ b/build2/config/utility @@ -72,12 +72,12 @@ namespace build2 // out some fallback. See config.bin.target for an example. // pair - required (scope& root, const variable&); + omitted (scope& root, const variable&); inline pair - required (scope& root, const string& name) + omitted (scope& root, const string& name) { - return required (root, var_pool.find (name)); + return omitted (root, var_pool.find (name)); } // Set, if necessary, an optional config.* variable. In particular, diff --git a/build2/config/utility.cxx b/build2/config/utility.cxx index 45417f1..9131620 100644 --- a/build2/config/utility.cxx +++ b/build2/config/utility.cxx @@ -15,9 +15,9 @@ namespace build2 namespace config { pair - required (scope& r, const variable& var) + omitted (scope& r, const variable& var) { - // This is a stripped-down version of the other required() twisted + // This is a stripped-down version of the required() twisted // implementation. pair org (r.find_original (var)); diff --git a/build2/config/utility.txx b/build2/config/utility.txx index ce9e40f..659ffb8 100644 --- a/build2/config/utility.txx +++ b/build2/config/utility.txx @@ -17,8 +17,7 @@ namespace build2 bool def_ovr, uint64_t save_flags) { - // Note: see also the other required() version if changing anything - // here. + // Note: see also omitted() if changing anything here. if (current_mif->id == configure_id) save_variable (root, var, save_flags); -- cgit v1.1