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/dist/module.cxx | 142 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 build2/dist/module.cxx (limited to 'build2/dist/module.cxx') diff --git a/build2/dist/module.cxx b/build2/dist/module.cxx new file mode 100644 index 0000000..00b709e --- /dev/null +++ b/build2/dist/module.cxx @@ -0,0 +1,142 @@ +// file : build2/dist/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 dist + { + static rule rule_; + + extern "C" void + dist_boot (scope& r, const location&, unique_ptr&) + { + tracer trace ("dist::boot"); + + level5 ([&]{trace << "for " << r.out_path ();}); + + // Register meta-operation. + // + r.meta_operations.insert (dist_id, dist); + } + + extern "C" bool + dist_init (scope& r, + scope&, + const location& l, + unique_ptr&, + bool first, + bool) + { + tracer trace ("dist::init"); + + if (!first) + { + warn (l) << "multiple dist module initializations"; + return true; + } + + const dir_path& out_root (r.out_path ()); + level5 ([&]{trace << "for " << out_root;}); + + // Enter module variables. + // + if (first) + { + auto& v (var_pool); + + v.find ("dist", bool_type); + + v.find ("dist.package", string_type); + + v.find ("dist.root", dir_path_type); + v.find ("config.dist.root", dir_path_type); + + //@@ VAR type + // + v.find ("dist.cmd", string_type); + v.find ("config.dist.cmd", string_type); + + v.find ("dist.archives", strings_type); + v.find ("config.dist.archives", strings_type); + } + + // Register our wildcard rule. Do it explicitly for the alias + // to prevent something like insert(dist_id, test_id) + // taking precedence. + // + r.rules.insert (dist_id, 0, "dist", rule_); + r.rules.insert (dist_id, 0, "dist.alias", rule_); + + // Configuration. + // + // Note that we don't use any defaults for root -- the location + // must be explicitly specified or we will complain if and when + // we try to dist. + // + using namespace config; + + bool s (specified (r, "config.dist")); + + // dist.root + // + { + value& v (r.assign ("dist.root")); + + if (s) + { + const value& cv (optional_absolute (r, "config.dist.root")); + + if (cv && !cv.empty ()) + v = cv; + } + } + + // dist.cmd + // + { + value& v (r.assign ("dist.cmd")); + + if (s) + { + const value& cv (required (r, "config.dist.cmd", "install").first); + + if (cv && !cv.empty ()) + v = cv; + } + else + v = "install"; + } + + // dist.archives + // + { + value& v (r.assign ("dist.archives")); + + if (s) + { + const value& cv (optional (r, "config.dist.archives")); + + if (cv && !cv.empty ()) + v = cv; + } + } + + return true; + } + } +} -- cgit v1.1