aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-11-23 09:53:18 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-23 09:57:32 +0200
commitc6265603e0e98c19f8d81c8edd5a34a550063c02 (patch)
tree7108ad8849d4ac74281a89e5034774f055435f59
parent0a4f6bd240a512dadc54afd3116d8b8d03879de4 (diff)
Add support for config.cli=false (leave unconfigured)
-rw-r--r--build2/cli/init.cxx57
-rw-r--r--build2/config/utility4
-rw-r--r--build2/config/utility.cxx12
3 files changed, 50 insertions, 23 deletions
diff --git a/build2/cli/init.cxx b/build2/cli/init.cxx
index 093cdbb..3cb1f98 100644
--- a/build2/cli/init.cxx
+++ b/build2/cli/init.cxx
@@ -28,7 +28,7 @@ namespace build2
bool
config_init (scope& rs,
scope& bs,
- const location&,
+ const location& l,
unique_ptr<module_base>&,
bool first,
bool optional,
@@ -47,6 +47,9 @@ namespace build2
// Note: some overridable, some not.
//
+ // The config.cli=false is recognized as an explicit request to leave
+ // the module unconfigured.
+ //
v.insert<path> ("config.cli", true);
v.insert<strings> ("config.cli.options", true);
@@ -59,17 +62,33 @@ namespace build2
// The plan is as follows: try to configure the module. If this fails,
// we are using default values, and the module is optional, leave it
// unconfigured.
- //
- // We will only honor optional if the user didn't specify any cli
- // configuration explicitly.
+ // First take care of the explicit request by the user to leave the
+ // module unconfigured.
//
- optional = optional && !config::specified (rs, "config.cli");
+ bool conf (true);
- // If the configuration says we are unconfigured, then we don't need to
- // re-run tests, etc. But we may still need to print the config report.
- //
- bool conf (!optional || !config::unconfigured (rs, "config.cli"));
+ if (const path* p = cast_null<path> (rs["config.cli"]))
+ {
+ conf = p->string () != "false";
+
+ if (!conf && !optional)
+ fail (l) << "non-optional module requested to be left unconfigured";
+ }
+
+ if (conf)
+ {
+ // Otherwise we will only honor optional if the user didn't specify
+ // any cli configuration explicitly.
+ //
+ optional = optional && !config::specified (rs, "config.cli");
+
+ // If the configuration says we are unconfigured, then we should't
+ // re-run tests, etc. But we may still need to print the config
+ // report.
+ //
+ conf = !optional || !config::unconfigured (rs, "config.cli");
+ }
if (first)
{
@@ -168,13 +187,7 @@ namespace build2
ver = test (cli);
if (ver.empty ())
- {
- // Note that we are unconfigured so that we don't keep
- // re-testing this on each run.
- //
- config::unconfigured (rs, "config.cli", true);
conf = false;
- }
else
{
auto p (config::required (rs, "config.cli", cli));
@@ -197,6 +210,12 @@ namespace build2
nv = p.second;
}
+ // Note that we are unconfigured so that we don't keep re-testing this
+ // on each run.
+ //
+ if (!conf)
+ nv = config::unconfigured (rs, "config.cli", true) || nv;
+
// If this is a new value (e.g., we are configuring), then print the
// report at verbosity level 2 and up (-v).
//
@@ -234,7 +253,7 @@ namespace build2
bool
init (scope& rs,
scope& bs,
- const location& loc,
+ const location& l,
unique_ptr<module_base>&,
bool,
bool optional,
@@ -249,19 +268,19 @@ namespace build2
// the user load cxx explicitly.
//
if (!cast_false<bool> (bs["cxx.loaded"]))
- fail (loc) << "cxx module must be loaded before cli";
+ fail (l) << "cxx module must be loaded before cli";
// Load cli.config.
//
if (!cast_false<bool> (bs["cli.config.loaded"]))
{
- if (!load_module ("cli.config", rs, bs, loc, optional, hints))
+ if (!load_module ("cli.config", rs, bs, l, optional, hints))
return false;
}
else if (!cast_false<bool> (bs["cli.config.configured"]))
{
if (!optional)
- fail << "cli module could not be configured" <<
+ fail (l) << "cli module could not be configured" <<
info << "re-run with -V option for more information";
return false;
diff --git a/build2/config/utility b/build2/config/utility
index de75de4..31270fb 100644
--- a/build2/config/utility
+++ b/build2/config/utility
@@ -120,9 +120,9 @@ namespace build2
// 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.
+ // values for this module. Return true if this sets a new value.
//
- void
+ bool
unconfigured (scope& root, const string& ns, bool);
// Enter the variable so that it is saved during configuration. See
diff --git a/build2/config/utility.cxx b/build2/config/utility.cxx
index 9131620..4c0e933 100644
--- a/build2/config/utility.cxx
+++ b/build2/config/utility.cxx
@@ -105,7 +105,7 @@ namespace build2
return l && !cast<bool> (l);
}
- void
+ bool
unconfigured (scope& root, const string& ns, bool v)
{
// Note: not overridable.
@@ -115,7 +115,15 @@ namespace build2
if (current_mif->id == configure_id)
save_variable (root, var);
- root.assign (var) = !v;
+ value& x (root.assign (var));
+
+ if (x.null || cast<bool> (x) != !v)
+ {
+ x = !v;
+ return true;
+ }
+ else
+ return false;
}
void