From d91e48ea57b83f7018a25d3f54bba96cf889d66d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 16 Aug 2020 10:30:35 +0200 Subject: Add ability to initialize bootstrapped modules after loading root.build --- libbuild2/module.hxx | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'libbuild2/module.hxx') 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 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 (*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 module; - location_value loc; // Boot location. + optional boot_init; }; struct module_map: vector -- cgit v1.1