aboutsummaryrefslogtreecommitdiff
path: root/build/file.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-12-10 13:54:59 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-12-10 13:54:59 +0200
commit0d0d9a9c56822919e9794658d31db57f8fc3e2bf (patch)
tree6dcb1649706dc7fc3f02cd5646b4611b3309fbd1 /build/file.cxx
parent5f29fc16fb85a934280e00e54bc6307685c4e05d (diff)
Implement two-phase initialization of modules loaded from bootstrap.build
Diffstat (limited to 'build/file.cxx')
-rw-r--r--build/file.cxx34
1 files changed, 30 insertions, 4 deletions
diff --git a/build/file.cxx b/build/file.cxx
index 9595d8f..59fe1b9 100644
--- a/build/file.cxx
+++ b/build/file.cxx
@@ -75,8 +75,8 @@ namespace build
return dir_path ();
}
- void
- source (const path& bf, scope& root, scope& base)
+ static void
+ source (const path& bf, scope& root, scope& base, bool boot)
{
tracer trace ("source");
@@ -90,7 +90,7 @@ namespace build
level5 ([&]{trace << "sourcing " << bf;});
- parser p;
+ parser p (boot);
p.parse_buildfile (ifs, bf, root, base);
}
catch (const ifstream::failure&)
@@ -100,6 +100,12 @@ namespace build
}
void
+ source (const path& bf, scope& root, scope& base)
+ {
+ return source (bf, root, base, false);
+ }
+
+ void
source_once (const path& bf, scope& root, scope& base, scope& once)
{
tracer trace ("source_once");
@@ -440,7 +446,11 @@ namespace build
// process hard to reason about. But we may try to bootstrap the
// same root scope multiple time.
//
- source_once (bf, root, root);
+ if (root.buildfiles.insert (bf).second)
+ source (bf, root, root, true);
+ else
+ level5 ([&]{trace << "skipping already sourced " << bf;});
+
r = true;
}
@@ -722,6 +732,22 @@ namespace build
if (scope* rs = root.parent_scope ()->root_scope ())
load_root_pre (*rs);
+ // Finish off loading bootstrapped modules.
+ //
+ for (auto& p: root.modules)
+ {
+ const string& n (p.first);
+ module_state& s (p.second);
+
+ if (s.boot)
+ {
+ load_module (false, n, root, root, s.loc);
+ assert (!s.boot);
+ }
+ }
+
+ // Load root.build.
+ //
path bf (root.src_path () / path ("build/root.build"));
if (file_exists (bf))