aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build2/b.cxx2
-rw-r--r--build2/cli/module.cxx22
-rw-r--r--build2/config/operation.cxx42
-rw-r--r--build2/config/utility8
4 files changed, 47 insertions, 27 deletions
diff --git a/build2/b.cxx b/build2/b.cxx
index 313fe95..7ebbab1 100644
--- a/build2/b.cxx
+++ b/build2/b.cxx
@@ -315,7 +315,7 @@ main (int argc, char* argv[])
os.push_back (targetspec (name ("dir", string ())));
const path p ("<buildspec>");
- const location l (&p, 1, 0); //@@ TODO
+ const location l (&p, 0, 0); //@@ TODO
operation_id oid (0); // Not yet translated.
const operation_info* oif (nullptr);
diff --git a/build2/cli/module.cxx b/build2/cli/module.cxx
index 7b98e93..bc6e13f 100644
--- a/build2/cli/module.cxx
+++ b/build2/cli/module.cxx
@@ -87,7 +87,7 @@ namespace build2
// Don't re-run tests if the configuration says we are unconfigured.
//
if (optional && config::unconfigured (root, "config.cli"))
- return false;
+ return false;
// config.cli
//
@@ -96,9 +96,9 @@ namespace build2
// Return version or empty string if unable to execute (e.g.,
// the cli executable is not found).
//
- auto test = [optional] (const char* cli) -> string
+ auto test = [optional] (const path& cli) -> string
{
- const char* args[] = {cli, "--version", nullptr};
+ const char* args[] = {cli.string ().c_str (), "--version", nullptr};
if (verb >= 2)
print_process (args);
@@ -145,7 +145,7 @@ namespace build2
};
string ver;
- const char* cli ("cli"); // Default.
+ path cli ("cli"); // Default.
if (optional)
{
@@ -169,19 +169,19 @@ namespace build2
}
else
{
- auto p (config::required (root, "config.cli", path (cli)));
- assert (p.second && cast<string> (p.first) == cli);
+ auto p (config::required (root, "config.cli", cli));
+ assert (p.second && cast<path> (p.first) == cli);
}
}
else
{
- auto p (config::required (root, "config.cli", path (cli)));
+ auto p (config::required (root, "config.cli", cli));
// If we actually set a new value, test it by trying to execute.
//
if (p.second)
{
- cli = cast<string> (p.first).c_str ();
+ cli = cast<path> (p.first);
ver = test (cli);
if (ver.empty ())
@@ -189,12 +189,6 @@ namespace build2
}
}
- // Clear the unconfigured flag, if any.
- //
- // @@ Get rid of needing to do this.
- //
- config::unconfigured (root, "config.cli", false);
-
if (!ver.empty () && verb >= 2)
text << cli << " " << ver;
}
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);