aboutsummaryrefslogtreecommitdiff
path: root/build/cli
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/cli
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/cli')
-rw-r--r--build/cli/module7
-rw-r--r--build/cli/module.cxx23
2 files changed, 20 insertions, 10 deletions
diff --git a/build/cli/module b/build/cli/module
index cf6258f..221e6a0 100644
--- a/build/cli/module
+++ b/build/cli/module
@@ -6,14 +6,17 @@
#define BUILD_CLI_MODULE
#include <build/types>
+#include <build/utility>
+
#include <build/module>
namespace build
{
namespace cli
{
- extern "C" void
- cli_init (scope&, scope&, const location&, std::unique_ptr<module>&, bool);
+ extern "C" bool
+ cli_init (
+ scope&, scope&, const location&, unique_ptr<module>&, bool, bool);
}
}
diff --git a/build/cli/module.cxx b/build/cli/module.cxx
index 64e95a8..081980b 100644
--- a/build/cli/module.cxx
+++ b/build/cli/module.cxx
@@ -28,12 +28,13 @@ namespace build
{
static compile compile_;
- extern "C" void
+ extern "C" bool
cli_init (scope& root,
scope& base,
- const location& l,
+ const location& loc,
std::unique_ptr<module>&,
- bool first)
+ bool first,
+ bool)
{
tracer trace ("cli::init");
level5 ([&]{trace << "for " << base.out_path ();});
@@ -44,8 +45,12 @@ namespace build
// semantics. So it is better to let the user load cxx
// explicitly.
//
- if (base.find_target_type ("cxx") == nullptr)
- fail (l) << "cxx module must be initialized before cli";
+ {
+ auto l (base["cxx.loaded"]);
+
+ if (!l || !as<bool> (*l))
+ fail (loc) << "cxx module must be loaded before cli";
+ }
// Register target types.
//
@@ -84,10 +89,10 @@ namespace build
//
if (first)
{
- variable_pool.find ("config.cli", string_type); //@@ VAR type
+ var_pool.find ("config.cli", string_type); //@@ VAR type
- variable_pool.find ("config.cli.options", strings_type);
- variable_pool.find ("cli.options", strings_type);
+ var_pool.find ("config.cli.options", strings_type);
+ var_pool.find ("cli.options", strings_type);
}
// Configure.
@@ -156,6 +161,8 @@ namespace build
//
if (const value& v = config::optional (root, "config.cli.options"))
base.assign ("cli.options") += as<strings> (v);
+
+ return true;
}
}
}