From 83bb02cada0b894d9134cc5489999e0f0fe8bd7c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 8 Jul 2019 14:55:35 +0200 Subject: Move in build system module to separate library --- libbuild2/module.hxx | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'libbuild2/module.hxx') diff --git a/libbuild2/module.hxx b/libbuild2/module.hxx index 7d94837..c32fc9a 100644 --- a/libbuild2/module.hxx +++ b/libbuild2/module.hxx @@ -50,24 +50,31 @@ namespace build2 bool optional, // Loaded with using? (optional module). const variable_map& hints); // Configuration hints (see below). + // If the boot function is not NULL, then such a module is said to require + // bootstrapping and must be loaded in bootstrap.build. + // struct module_functions { - module_boot_function* boot; - module_init_function* init; + const char* name = nullptr; // Module/submodule name. + module_boot_function* boot = nullptr; + module_init_function* init = nullptr; }; - // The build2__load() function will be written in C++ and will be + // The build2__load() function will be written in C++ and will be // called from C++ but we need to suppress name mangling to be able to use - // dlsym() or equivalent. + // dlsym() or equivalent, thus extern "C". // - // Note that the load() function is guaranteed to be called during serial - // execution (either from main() or during the load phase). + // The part in the function name is the main module name without + // submodule components (for example, `c` in `c.config`) and the load + // function is expected to return boot/init functions for all its submodules + // (if any) as well as for the module itself as an array of module_functions + // terminated with an all-NULL entry. // - // @@ I wonder if returning a "C++ struct" (it contains pointer to functions - // with signatures containing C++ type) is kosher. + // Note that the load function is guaranteed to be called during serial + // execution (either from main() or during the load phase). // extern "C" - using module_load_function = module_functions (); + using module_load_function = const module_functions* (); // Loaded modules state. // @@ -119,6 +126,9 @@ namespace build2 // Builtin modules. // + // @@ Maybe this should be renamed to loaded modules? + // @@ We can also change it to std::map + // using available_module_map = std::map; LIBBUILD2_SYMEXPORT extern available_module_map builtin_modules; } -- cgit v1.1