aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/module.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-04-27 09:49:45 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-04-27 10:03:50 +0200
commit9e5750ae2e3f837f80860aaab6b01e4d556213ed (patch)
treed3b2e551e444c47b6ce0289969e78360161b6685 /libbuild2/module.hxx
parent028e10ba787a7dbb46e3fcba6f88f496b76cebc5 (diff)
Rework tool importation along with cli module
Specifically, now config.<tool> (like config.cli) is handled by the import machinery (it is like a shorter alias for config.import.<tool>.<tool>.exe that we already had). And the cli module now uses that instead of custom logic. This also adds support for uniform tool metadata extraction that is handled by the import machinery. As a result, a tool that follows the "build2 way" can be imported with metadata by the buildfile and/or corresponding module without any tool-specific code or brittleness associated with parsing --version or similar outputs. See the cli tool/module for details. Finally, two new flavors of the import directive are now supported: import! triggers immediate importation skipping any rule-specific logic while import? is optional import (analogous to using?). Note that optional import is always immediate. There is also the import-specific metadata attribute which can be specified for these two import flavors in order to trigger metadata importation. For example: import? [metadata] cli = cli%exe{cli} if ($cli != [null]) info "cli version $($cli:cli.version)"
Diffstat (limited to 'libbuild2/module.hxx')
-rw-r--r--libbuild2/module.hxx13
1 files changed, 11 insertions, 2 deletions
diff --git a/libbuild2/module.hxx b/libbuild2/module.hxx
index f5c726e..b2b42e4 100644
--- a/libbuild2/module.hxx
+++ b/libbuild2/module.hxx
@@ -170,9 +170,18 @@ namespace build2
// A wrapper over init_module() to use from other modules that incorporates
// the <name>.loaded variable check (use init_module() directly to sidestep
- // this check).
+ // this check). Return a pointer to the pointer to the module instance if it
+ // was both successfully loaded and configured and NULL otherwise (so can be
+ // used as bool).
//
- LIBBUILD2_SYMEXPORT bool
+ // Note also that NULL can be returned even of optional is false which
+ // happens if the requested module has already been loaded but failed to
+ // configure. The function could have issued diagnostics but the caller can
+ // normally provide additional information.
+ //
+ // Note: for non-optional modules use the versions below.
+ //
+ LIBBUILD2_SYMEXPORT const shared_ptr<module>*
load_module (scope& root,
scope& base,
const string& name,