aboutsummaryrefslogtreecommitdiff
path: root/build/test
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/test
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/test')
-rw-r--r--build/test/module4
-rw-r--r--build/test/module.cxx23
-rw-r--r--build/test/rule.cxx12
3 files changed, 22 insertions, 17 deletions
diff --git a/build/test/module b/build/test/module
index 0b6af78..25bb2f2 100644
--- a/build/test/module
+++ b/build/test/module
@@ -12,9 +12,9 @@ namespace build
{
namespace test
{
- extern "C" void
+ extern "C" bool
test_init (
- scope&, scope&, const location&, std::unique_ptr<module>&, bool);
+ scope&, scope&, const location&, unique_ptr<module>&, bool, bool);
}
}
diff --git a/build/test/module.cxx b/build/test/module.cxx
index deda6e9..167c09b 100644
--- a/build/test/module.cxx
+++ b/build/test/module.cxx
@@ -21,12 +21,13 @@ namespace build
{
static rule rule_;
- extern "C" void
+ extern "C" bool
test_init (scope& r,
scope& b,
const location& l,
- unique_ptr<build::module>&,
- bool first)
+ unique_ptr<module>&,
+ bool first,
+ bool)
{
tracer trace ("test::init");
@@ -36,7 +37,7 @@ namespace build
if (!first)
{
warn (l) << "multiple test module initializations";
- return;
+ return true;
}
const dir_path& out_root (r.out_path ());
@@ -66,13 +67,15 @@ namespace build
// Enter module variables.
//
{
- variable_pool.find ("test", bool_type);
- variable_pool.find ("test.input", name_type);
- variable_pool.find ("test.output", name_type);
- variable_pool.find ("test.roundtrip", name_type);
- variable_pool.find ("test.options", strings_type);
- variable_pool.find ("test.arguments", strings_type);
+ var_pool.find ("test", bool_type);
+ var_pool.find ("test.input", name_type);
+ var_pool.find ("test.output", name_type);
+ var_pool.find ("test.roundtrip", name_type);
+ var_pool.find ("test.options", strings_type);
+ var_pool.find ("test.arguments", strings_type);
}
+
+ return true;
}
}
}
diff --git a/build/test/rule.cxx b/build/test/rule.cxx
index ea268a9..3a4c91d 100644
--- a/build/test/rule.cxx
+++ b/build/test/rule.cxx
@@ -72,7 +72,7 @@ namespace build
//
if (!l.defined ())
l = t.base_scope ()[
- variable_pool.find (string("test.") + t.type ().name, bool_type)];
+ var_pool.find (string("test.") + t.type ().name, bool_type)];
r = l && as<bool> (*l);
}
@@ -150,13 +150,15 @@ namespace build
string n ("test.");
n += t.type ().name;
- const variable& in (variable_pool.find (n + ".input", name_type));
- const variable& on (variable_pool.find (n + ".output", name_type));
- const variable& rn (variable_pool.find (n + ".roundtrip", name_type));
+ const variable& in (var_pool.find (n + ".input", name_type));
+ const variable& on (var_pool.find (n + ".output", name_type));
+ const variable& rn (var_pool.find (n + ".roundtrip", name_type));
// We should only keep value(s) that were specified together
// in the innermost scope.
//
+ // @@ Shouldn't we stop at project root?
+ //
for (scope* s (&bs); s != nullptr; s = s->parent_scope ())
{
ol = s->vars[on];
@@ -294,7 +296,7 @@ namespace build
var += t.type ().name;
var += '.';
var += n;
- l = t.base_scope ()[variable_pool.find (var, strings_type)];
+ l = t.base_scope ()[var_pool.find (var, strings_type)];
}
if (l)