aboutsummaryrefslogtreecommitdiff
path: root/build2/config/utility.cxx
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/utility.cxx
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/utility.cxx')
-rw-r--r--build2/config/utility.cxx47
1 files changed, 41 insertions, 6 deletions
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