aboutsummaryrefslogtreecommitdiff
path: root/build2/config
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-04-11 17:37:29 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-04-11 17:37:29 +0200
commit8ee02c5d40006d52d0048a748a695d589b3627cb (patch)
tree29824aabedc6387606e78318656d235318a62d9a /build2/config
parent6d61a95027c0e199495f083b393d740933f41e82 (diff)
Simplify unconfigured module interface
Diffstat (limited to 'build2/config')
-rw-r--r--build2/config/operation.cxx42
-rw-r--r--build2/config/utility8
2 files changed, 38 insertions, 12 deletions
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<lookup, size_t> 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<bool> (val))
+ if (cast<bool> (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);