aboutsummaryrefslogtreecommitdiff
path: root/build2/config
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-01-04 16:04:39 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-01-04 16:04:39 +0200
commit759e714238438cccf74f035e1ba11c925b27cd55 (patch)
tree36683f9df793d0100f49189dad9cabf09be78d89 /build2/config
parentb1ef30736694f644e2e473429257a18b64a7615c (diff)
Load config.build in init(), not boot()
We now make sure the config module is init'ed first.
Diffstat (limited to 'build2/config')
-rw-r--r--build2/config/init.cxx73
-rw-r--r--build2/config/init.hxx2
2 files changed, 32 insertions, 43 deletions
diff --git a/build2/config/init.cxx b/build2/config/init.cxx
index 7285671..2552e77 100644
--- a/build2/config/init.cxx
+++ b/build2/config/init.cxx
@@ -22,13 +22,12 @@ namespace build2
{
namespace config
{
- void
- boot (scope& rs, const location& loc, unique_ptr<module_base>& mod)
+ bool
+ boot (scope& rs, const location&, unique_ptr<module_base>& mod)
{
tracer trace ("config::boot");
- const dir_path& out_root (rs.out_path ());
- l5 ([&]{trace << "for " << out_root;});
+ l5 ([&]{trace << "for " << rs.out_path ();});
const string& mname (*current_mname);
const string& oname (*current_oname);
@@ -56,26 +55,38 @@ namespace build2
rs.meta_operations.insert (configure_id, mo_configure);
rs.meta_operations.insert (disfigure_id, mo_disfigure);
- auto& vp (var_pool.rw (rs));
+ return true; // Initialize first (load config.build).
+ }
- // utility.cxx:unconfigured() (note: not overridable).
- //
- vp.insert_pattern<bool> (
- "config.*.configured", false, variable_visibility::normal);
+ bool
+ init (scope& rs,
+ scope&,
+ const location& l,
+ unique_ptr<module_base>&,
+ bool first,
+ bool,
+ const variable_map& config_hints)
+ {
+ tracer trace ("config::init");
- // Load config.build if one exists.
- //
- // Note that we have to do this during bootstrap since the order in
- // which the modules will be initialized is unspecified. So it is
- // possible that some module which needs the configuration will get
- // called first.
+ if (!first)
+ {
+ warn (l) << "multiple config module initializations";
+ return true;
+ }
+
+ const dir_path& out_root (rs.out_path ());
+ l5 ([&]{trace << "for " << out_root;});
+
+ assert (config_hints.empty ()); // We don't known any hints.
+
+ auto& vp (var_pool.rw (rs));
+
+ // Load config.build if one exists (we don't need to worry about
+ // disfigure since we will never be init'ed).
//
const variable& c_v (vp.insert<uint64_t> ("config.version", false));
- // Don't load it if we are disfiguring. The same situation as with
- // module loading above.
- //
- if (mname != "disfigure" && (!mname.empty () || oname != "disfigure"))
{
path f (out_root / config_file);
@@ -96,7 +107,7 @@ namespace build2
uint64_t v (p.second ? cast<uint64_t> (p.first) : 0);
if (v != module::version)
- fail (loc) << "incompatible config file " << f <<
+ fail (l) << "incompatible config file " << f <<
info << "config file version " << v
<< (p.second ? "" : " (missing)") <<
info << "config module version " << module::version <<
@@ -107,28 +118,6 @@ namespace build2
source (rs, rs, f);
}
}
- }
-
- bool
- init (scope& rs,
- scope&,
- const location& l,
- unique_ptr<module_base>&,
- bool first,
- bool,
- const variable_map& config_hints)
- {
- tracer trace ("config::init");
-
- if (!first)
- {
- warn (l) << "multiple config module initializations";
- return true;
- }
-
- l5 ([&]{trace << "for " << rs.out_path ();});
-
- assert (config_hints.empty ()); // We don't known any hints.
// Register alias and fallback rule for the configure meta-operation.
//
diff --git a/build2/config/init.hxx b/build2/config/init.hxx
index 45c288b..a79ef02 100644
--- a/build2/config/init.hxx
+++ b/build2/config/init.hxx
@@ -14,7 +14,7 @@ namespace build2
{
namespace config
{
- void
+ bool
boot (scope&, const location&, unique_ptr<module_base>&);
bool