From 8ee02c5d40006d52d0048a748a695d589b3627cb Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 11 Apr 2016 17:37:29 +0200 Subject: Simplify unconfigured module interface --- build2/config/operation.cxx | 42 +++++++++++++++++++++++++++++++----------- build2/config/utility | 8 +++++++- 2 files changed, 38 insertions(+), 12 deletions(-) (limited to 'build2/config') diff --git a/build2/config/operation.cxx b/build2/config/operation.cxx index ec92e89..8b0bb3d 100644 --- a/build2/config/operation.cxx +++ b/build2/config/operation.cxx @@ -127,8 +127,11 @@ namespace build2 // names storage; - for (const auto& p: mod.vars) + for (auto b (mod.vars.begin ()), i (b), e (mod.vars.end ()); + i != e; + ++i) { + const auto& p (*i); const variable& var (p.first); pair org (root.find_original (var)); @@ -208,32 +211,49 @@ namespace build2 } } - const value& val (*l); + const string& n (var.name); + const value& v (*l); // We will only write config.*.configured if it is false (true is - // implied by its absence). - // - // @@ Do we still need this? + // implied by its absence). We will also ignore false values if + // there is any other value for this module (see unconfigured()). // - const string& n (var.name); - if (n.size () > 11 && n.compare (n.size () - 11, 11, ".configured") == 0) { - if (val == nullptr || cast (val)) + if (cast (v)) + continue; + + size_t m (n.size () - 11); // Prefix size. + auto same = [&n, m] (const variable& v) + { + return v.name.size () >= m && + v.name.compare (0, m, n, 0, m) == 0; + }; + + // Check if this is the first value for this module. + // + auto j (i); + if (j != b && same ((--j)->first)) + continue; + + // Check if this is the last value for this module. + // + j = i; + if (++j != e && same (j->first)) continue; } if (next_module (var)) ofs << endl; - if (val) + if (v) { storage.clear (); - ofs << var.name << " = " << reverse (val, storage) << endl; + ofs << n << " = " << reverse (v, storage) << endl; } else - ofs << var.name << " = [null]" << endl; + ofs << n << " = [null]" << endl; } } catch (const ofstream::failure&) diff --git a/build2/config/utility b/build2/config/utility index 8a93c09..beab758 100644 --- a/build2/config/utility +++ b/build2/config/utility @@ -86,11 +86,17 @@ namespace build2 bool specified (scope& root, const string& ns); - // + // Check if there is a false config.*.configured value. This mechanism can + // be used to "remember" that the module is left unconfigured in order to + // avoid re-running the tests, etc. // bool unconfigured (scope& root, const string& ns); + // Set the config.*.configured value. Note that you only need to set it to + // false. It will be automatically ignored if there are any other config.* + // values for this module. + // void unconfigured (scope& root, const string& ns, bool); -- cgit v1.1