aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-08-17 12:53:37 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-08-17 12:53:37 +0200
commitdc46fa754baa446d5428ba38db0d637a17b91c57 (patch)
tree55d0cac384babc4fbbd27bb1cd8837fca6187017
parent136dc68a2704d50ccc7dee644e67f86a31b34f49 (diff)
Add support for config.bin.{lib,exe}.{prefix,suffix}
This replaces the bin.libprefix functionality.
-rw-r--r--build2/bin/init.cxx46
-rw-r--r--build2/cc/link.cxx18
-rw-r--r--build2/cc/module.cxx2
-rw-r--r--build2/config/utility6
-rw-r--r--build2/config/utility.cxx4
-rw-r--r--build2/config/utility.txx3
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<strings> ("config.bin.libs.lib", true);
v.insert<dir_paths> ("config.bin.rpath", true);
+ v.insert<string> ("config.bin.lib.prefix", true);
+ v.insert<string> ("config.bin.lib.suffix", true);
+ v.insert<string> ("config.bin.exe.prefix", true);
+ v.insert<string> ("config.bin.exe.suffix", true);
+
v.insert<string> ("bin.lib");
v.insert<strings> ("bin.exe.lib");
v.insert<strings> ("bin.liba.lib");
v.insert<strings> ("bin.libs.lib");
v.insert<dir_paths> ("bin.rpath");
+
+ v.insert<string> ("bin.lib.prefix");
+ v.insert<string> ("bin.lib.suffix");
+ v.insert<string> ("bin.exe.prefix");
+ v.insert<string> ("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<dir_paths> (
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<module_base>&,
- 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<string> ("bin.libprefix", true);
- }
-
// Load bin.config.
//
if (!cast_false<bool> (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<string> (l).c_str ();
+ if (auto l = t["bin.exe.suffix"]) s = cast<string> (l).c_str ();
+
break;
}
case otype::a:
@@ -681,8 +685,8 @@ namespace build2
e = "a";
}
- if (auto l = t["bin.libprefix"])
- p = cast<string> (l).c_str ();
+ if (auto l = t["bin.lib.prefix"]) p = cast<string> (l).c_str ();
+ if (auto l = t["bin.lib.suffix"]) s = cast<string> (l).c_str ();
break;
}
@@ -710,14 +714,14 @@ namespace build2
e = "so";
}
- if (auto l = t["bin.libprefix"])
- p = cast<string> (l).c_str ();
+ if (auto l = t["bin.lib.prefix"]) p = cast<string> (l).c_str ();
+ if (auto l = t["bin.lib.suffix"]) s = cast<string> (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<const value*, bool>
- required (scope& root, const variable&);
+ omitted (scope& root, const variable&);
inline pair<const value*, bool>
- 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<const value*, bool>
- 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<lookup, size_t> 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);