From a1cec9e0df14f3c1a833e2a447b5324ff9c430d3 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 21 Jul 2015 16:21:07 +0200 Subject: Test module genesis --- build/test/module.cxx | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 build/test/module.cxx (limited to 'build/test/module.cxx') 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 + +#include +#include +#include +#include + +#include +#include + +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& 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 m (new module (test_id)); + + { + auto& rs (base.rules); + + // Register the standard alias rule for the test operation. + // + rs.insert (test_id, "alias", alias_rule::instance); + + // Register our test running rule. + // + rs.insert (test_id, "test", m->rule); + } + + r = move (m); + } + } +} -- cgit v1.1