aboutsummaryrefslogtreecommitdiff
path: root/build2/config
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-06-27 16:59:09 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-06-27 16:59:09 +0200
commit41cad5bba8a718a0403c0578660c60e81c9f46e4 (patch)
tree7eebba42dac307fdfcf600f5f6527afe0c0f4fea /build2/config
parent34cc74df52ed129bffeb7b6fcf11f05c222550ba (diff)
Add config.bin.target var/hint, use to decide libso{} install mode
Normally the user doesn't need to specify config.bin.target explicitly since the cxx module will hint it. We now also have the whole set of target's components: bin.target.{cpu,vendor,system,version,class}
Diffstat (limited to 'build2/config')
-rw-r--r--build2/config/utility15
-rw-r--r--build2/config/utility.cxx47
-rw-r--r--build2/config/utility.txx3
3 files changed, 59 insertions, 6 deletions
diff --git a/build2/config/utility b/build2/config/utility
index beab758..c47cecf 100644
--- a/build2/config/utility
+++ b/build2/config/utility
@@ -55,6 +55,21 @@ namespace build2
return required (root, name, string (default_value), override);
}
+ // As above, but leave the unspecified value as undefined (and return
+ // NULL pointer) rather than setting it to the default value.
+ //
+ // This can be useful when we don't have a default value but may figure
+ // out some fallback. See config.bin.target for an example.
+ //
+ pair<const value*, bool>
+ required (scope& root, const variable&);
+
+ inline pair<const value*, bool>
+ required (scope& root, const string& name)
+ {
+ return required (root, var_pool.find (name));
+ }
+
// Set, if necessary, an optional config.* variable. In particular,
// an unspecified variable is set to NULL which is used to distinguish
// between the "configured as unspecified" and "not yet configured"
diff --git a/build2/config/utility.cxx b/build2/config/utility.cxx
index 1dbf3d3..768a70d 100644
--- a/build2/config/utility.cxx
+++ b/build2/config/utility.cxx
@@ -15,28 +15,63 @@ namespace build2
namespace config
{
void
- save_variable (scope& root, const variable& var, uint64_t flags)
+ save_variable (scope& r, const variable& var, uint64_t flags)
{
if (current_mif->id == configure_id)
{
// The project might not be using the config module. But then how
// could we be configuring it? Good question.
//
- if (module* mod = root.modules.lookup<module> (module::name))
+ if (module* mod = r.modules.lookup<module> (module::name))
mod->vars.emplace (var, flags);
}
}
+ pair<const value*, bool>
+ required (scope& r, const variable& var)
+ {
+ // This is a stripped-down version of the other required() twisted
+ // implementation.
+
+ pair<lookup, size_t> org (r.find_original (var));
+
+ bool n (false); // New flag.
+ lookup l (org.first);
+
+ // Treat an inherited value that was set to default as new.
+ //
+ if (l.defined () && l->extra)
+ n = true;
+
+ if (var.override != nullptr)
+ {
+ pair<lookup, size_t> ovr (r.find_override (var, move (org)));
+
+ if (l != ovr.first) // Overriden?
+ {
+ // Override is always treated as new.
+ //
+ n = true;
+ l = move (ovr.first);
+ }
+ }
+
+ if (l.defined () && current_mif->id == configure_id)
+ save_variable (r, var);
+
+ return pair<const value*, bool> (l.value, n);
+ }
+
const value&
- optional (scope& root, const variable& var)
+ optional (scope& r, const variable& var)
{
if (current_mif->id == configure_id)
- save_variable (root, var);
+ save_variable (r, var);
- auto l (root[var]);
+ auto l (r[var]);
return l.defined ()
? *l
- : root.assign (var); // NULL.
+ : r.assign (var); // NULL.
}
bool
diff --git a/build2/config/utility.txx b/build2/config/utility.txx
index 30ed02f..5ebd261 100644
--- a/build2/config/utility.txx
+++ b/build2/config/utility.txx
@@ -13,6 +13,9 @@ namespace build2
pair<reference_wrapper<const value>, bool>
required (scope& root, const variable& var, const T& def_val, bool def_ovr)
{
+ // Note: see also the other required() version if changing anything
+ // here.
+
if (current_mif->id == configure_id)
save_variable (root, var);