From 9891b20350021ce41a950645dd76df20a45c92cc Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 2 Dec 2015 11:37:15 +0200 Subject: Implement optional module loading The syntax is: using? cli Now each module use results in two bool variables: .loaded and .configured. Also implement variable visibility (the above two variables are limited to project). --- build/module | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'build/module') diff --git a/build/module b/build/module index 43ab1e0..984a50f 100644 --- a/build/module +++ b/build/module @@ -21,23 +21,32 @@ namespace build ~module () = default; }; + // Return false if the module configuration (normally based on the default + // values) was unsuccessful but this is not (yet) an error. One example + // would be the optional use of a module. Or a module might remain + // unconfigured for as long as it is actually not used (e.g., install, + // dist). The return value is used to set the .configured variable. + // extern "C" using module_init_function = - void (scope& root, + bool (scope& root, scope& base, const location&, std::unique_ptr&, - bool first); // First time for this project. + bool first, // First time for this project. + bool optional); // Loaded with 'using?' (optional module). using loaded_module_map = std::map>>; // Load the specified module. Used by the parser but also by some - // modules to load prerequisite modules. + // modules to load prerequisite modules. Return true if the module + // was both successfully loaded and configured. // - void - load_module (const std::string& name, + bool + load_module (bool optional, + const std::string& name, scope& root, scope& base, const location&); -- cgit v1.1