aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/module.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-08-16 10:30:35 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-08-16 10:30:35 +0200
commitd91e48ea57b83f7018a25d3f54bba96cf889d66d (patch)
treeaa6376de69751ae0488febc8fb4faed041699687 /libbuild2/module.hxx
parent50bf3956c88ee6341d0023a421d502d604e3da4f (diff)
Add ability to initialize bootstrapped modules after loading root.build
Diffstat (limited to 'libbuild2/module.hxx')
-rw-r--r--libbuild2/module.hxx28
1 files changed, 21 insertions, 7 deletions
diff --git a/libbuild2/module.hxx b/libbuild2/module.hxx
index 0305e2c..4110682 100644
--- a/libbuild2/module.hxx
+++ b/libbuild2/module.hxx
@@ -40,9 +40,27 @@ namespace build2
// way for us to later pass more information without breaking source
// compatibility.
//
+ // By default a booted module is initialized before loading root.build.
+ //
+ // The module should specify the before_first initialization mode if it
+ // should be initialized first (within the resulting two groups the modules
+ // are initializated in the order loaded).
+ //
+ // The module should specify the after initialization mode if it should be
+ // initialized after loading root.build. Note that in this case the module
+ // is also allowed to be initialized explicitly from root.build.
+ //
+ enum class module_boot_init
+ {
+ before_first,
+ before,
+ after
+ };
+
struct module_boot_extra
{
shared_ptr<build2::module> module; // Module instance (out).
+ module_boot_init init; // Init mode (out).
// Convenience functions.
//
@@ -53,11 +71,8 @@ namespace build2
T& module_as () {assert (module); return static_cast<T&> (*module);}
};
- // Return true if the module should be initialized first (within the
- // resulting two groups the modules are initializated in the order loaded).
- //
using module_boot_function =
- bool (scope& root,
+ void (scope& root,
const location&,
module_boot_extra&);
@@ -122,12 +137,11 @@ namespace build2
//
struct module_state
{
- bool boot; // True if the module boot'ed but not yet init'ed.
- bool first; // True if the boot'ed module must be init'ed first.
+ location_value loc; // Load location.
const string name;
module_init_function* init;
shared_ptr<build2::module> module;
- location_value loc; // Boot location.
+ optional<module_boot_init> boot_init;
};
struct module_map: vector<module_state>