aboutsummaryrefslogtreecommitdiff
path: root/build/module
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-12-02 11:37:15 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-12-02 11:37:15 +0200
commit9891b20350021ce41a950645dd76df20a45c92cc (patch)
tree0cd27041b0c3413e17b9319ae99e87c5e745b1ff /build/module
parent74212589a797ca75e55f92a522e198915c0dbaf6 (diff)
Implement optional module loading
The syntax is: using? cli Now each module use results in two bool variables: <module>.loaded and <module>.configured. Also implement variable visibility (the above two variables are limited to project).
Diffstat (limited to 'build/module')
-rw-r--r--build/module19
1 files changed, 14 insertions, 5 deletions
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 <module>.configured variable.
+ //
extern "C"
using module_init_function =
- void (scope& root,
+ bool (scope& root,
scope& base,
const location&,
std::unique_ptr<module>&,
- 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<std::string,
std::pair<module_init_function*, std::unique_ptr<module>>>;
// 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&);