aboutsummaryrefslogtreecommitdiff
path: root/build/test/module.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-07-21 16:21:07 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-07-21 16:21:07 +0200
commita1cec9e0df14f3c1a833e2a447b5324ff9c430d3 (patch)
treee61c7e1cb3fa27ba435053761f5a2a3fb670f728 /build/test/module.cxx
parentbead742dbac51088e89cdd4dd7a55aaa1d8c98d7 (diff)
Test module genesis
Diffstat (limited to 'build/test/module.cxx')
-rw-r--r--build/test/module.cxx72
1 files changed, 72 insertions, 0 deletions
diff --git a/build/test/module.cxx b/build/test/module.cxx
new file mode 100644
index 0000000..d5ba754
--- /dev/null
+++ b/build/test/module.cxx
@@ -0,0 +1,72 @@
+// file : build/test/module.cxx -*- C++ -*-
+// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd
+// license : MIT; see accompanying LICENSE file
+
+#include <build/test/module>
+
+#include <build/scope>
+#include <build/target>
+#include <build/rule>
+#include <build/diagnostics>
+
+#include <build/test/operation>
+#include <build/test/rule>
+
+using namespace std;
+using namespace butl;
+
+namespace build
+{
+ namespace test
+ {
+ class module: public build::module
+ {
+ public:
+ module (operation_id test_id): rule (test_id) {}
+
+ test::rule rule;
+ };
+
+ extern "C" void
+ test_init (scope& root,
+ scope& base,
+ const location& l,
+ unique_ptr<build::module>& r,
+ bool first)
+ {
+ tracer trace ("test::init");
+
+ if (&root != &base)
+ fail (l) << "test module must be initialized in bootstrap.build";
+
+ if (!first)
+ {
+ warn (l) << "multiple test module initializations";
+ return;
+ }
+
+ const dir_path& out_root (root.path ());
+ level4 ([&]{trace << "for " << out_root;});
+
+ // Register the test operation.
+ //
+ operation_id test_id (root.operations.insert (test));
+
+ unique_ptr<module> m (new module (test_id));
+
+ {
+ auto& rs (base.rules);
+
+ // Register the standard alias rule for the test operation.
+ //
+ rs.insert<alias> (test_id, "alias", alias_rule::instance);
+
+ // Register our test running rule.
+ //
+ rs.insert<target> (test_id, "test", m->rule);
+ }
+
+ r = move (m);
+ }
+ }
+}