aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build2/b.cxx34
-rw-r--r--libbuild2/module.cxx7
-rw-r--r--libbuild2/module.hxx8
3 files changed, 28 insertions, 21 deletions
diff --git a/build2/b.cxx b/build2/b.cxx
index f2b7674..e093641 100644
--- a/build2/b.cxx
+++ b/build2/b.cxx
@@ -500,30 +500,22 @@ main (int argc, char* argv[])
// Load builtin modules.
//
- {
- auto load = [] (module_load_function* lf)
- {
- for (const module_functions* i (lf ()); i->name != nullptr; ++i)
- loaded_modules[i->name] = i;
- };
-
- load (&config::build2_config_load);
- load (&dist::build2_dist_load);
- load (&test::build2_test_load);
- load (&install::build2_install_load);
-
- load (&bin::build2_bin_load);
- load (&cc::build2_cc_load);
- load (&c::build2_c_load);
- load (&cxx::build2_cxx_load);
- load (&version::build2_version_load);
- load (&in::build2_in_load);
+ load_builtin_module (&config::build2_config_load);
+ load_builtin_module (&dist::build2_dist_load);
+ load_builtin_module (&test::build2_test_load);
+ load_builtin_module (&install::build2_install_load);
+
+ load_builtin_module (&bin::build2_bin_load);
+ load_builtin_module (&cc::build2_cc_load);
+ load_builtin_module (&c::build2_c_load);
+ load_builtin_module (&cxx::build2_cxx_load);
+ load_builtin_module (&version::build2_version_load);
+ load_builtin_module (&in::build2_in_load);
#ifndef BUILD2_BOOTSTRAP
- load (&cli::build2_cli_load);
- load (&bash::build2_bash_load);
+ load_builtin_module (&cli::build2_cli_load);
+ load_builtin_module (&bash::build2_bash_load);
#endif
- }
// Start up the scheduler and allocate lock shards.
//
diff --git a/libbuild2/module.cxx b/libbuild2/module.cxx
index 1bd60a6..c3e4c62 100644
--- a/libbuild2/module.cxx
+++ b/libbuild2/module.cxx
@@ -33,6 +33,13 @@ namespace build2
{
loaded_module_map loaded_modules;
+ void
+ load_builtin_module (module_load_function* lf)
+ {
+ for (const module_functions* i (lf ()); i->name != nullptr; ++i)
+ loaded_modules[i->name] = i;
+ }
+
// Sorted array of bundled modules (excluding core modules bundled with
// libbuild2; see below).
//
diff --git a/libbuild2/module.hxx b/libbuild2/module.hxx
index f583361..3aaa1c7 100644
--- a/libbuild2/module.hxx
+++ b/libbuild2/module.hxx
@@ -154,6 +154,14 @@ namespace build2
//
using loaded_module_map = std::map<string, const module_functions*>;
LIBBUILD2_SYMEXPORT extern loaded_module_map loaded_modules;
+
+ // Load a builtin module (i.e., a module linked as a static/shared library
+ // or that is part of the build system driver).
+ //
+ // Note: assumes serial execution.
+ //
+ LIBBUILD2_SYMEXPORT void
+ load_builtin_module (module_load_function*);
}
#endif // LIBBUILD2_MODULE_HXX