From 41cad5bba8a718a0403c0578660c60e81c9f46e4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 27 Jun 2016 16:59:09 +0200 Subject: 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} --- build2/config/utility.cxx | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) (limited to 'build2/config/utility.cxx') 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::name)) + if (module* mod = r.modules.lookup (module::name)) mod->vars.emplace (var, flags); } } + pair + required (scope& r, const variable& var) + { + // This is a stripped-down version of the other required() twisted + // implementation. + + pair 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 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 (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 -- cgit v1.1