From 9fb791e9fad6c63fc1dac49f4d05ae63b8a3db9b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 5 Jan 2016 11:55:15 +0200 Subject: Rename build directory/namespace to build2 --- build2/test/module.cxx | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 build2/test/module.cxx (limited to 'build2/test/module.cxx') diff --git a/build2/test/module.cxx b/build2/test/module.cxx new file mode 100644 index 0000000..133849a --- /dev/null +++ b/build2/test/module.cxx @@ -0,0 +1,88 @@ +// file : build2/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 build2 +{ + namespace test + { + static rule rule_; + + extern "C" void + test_boot (scope& root, const location&, unique_ptr&) + { + tracer trace ("test::boot"); + + level5 ([&]{trace << "for " << root.out_path ();}); + + // Register the test operation. + // + root.operations.insert (test_id, test); + } + + extern "C" bool + test_init (scope& root, + scope&, + const location& l, + unique_ptr&, + bool first, + bool) + { + tracer trace ("test::init"); + + if (!first) + { + warn (l) << "multiple test module initializations"; + return true; + } + + const dir_path& out_root (root.out_path ()); + level5 ([&]{trace << "for " << out_root;}); + + // Enter module variables. + // + { + auto& v (var_pool); + + v.find ("test", bool_type); + v.find ("test.input", name_type); + v.find ("test.output", name_type); + v.find ("test.roundtrip", name_type); + v.find ("test.options", strings_type); + v.find ("test.arguments", strings_type); + } + + // Register rules. + // + { + auto& r (root.rules); + + // Register our test running rule. + // + r.insert (perform_test_id, "test", rule_); + + // Register our rule for the dist meta-operation. We need + // to do this because we have "ad-hoc prerequisites" (test + // input/output files) that need to be entered into the + // target list. + // + r.insert (dist_id, test_id, "test", rule_); + } + + return true; + } + } +} -- cgit v1.1