From 53eb43126e562a43f4e8f2247af10da5c4c3c87f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 12 Aug 2016 16:39:13 +0200 Subject: Rename module to init --- build2/dist/init | 31 +++++++++++ build2/dist/init.cxx | 146 +++++++++++++++++++++++++++++++++++++++++++++++++ build2/dist/module | 31 ----------- build2/dist/module.cxx | 146 ------------------------------------------------- 4 files changed, 177 insertions(+), 177 deletions(-) create mode 100644 build2/dist/init create mode 100644 build2/dist/init.cxx delete mode 100644 build2/dist/module delete mode 100644 build2/dist/module.cxx (limited to 'build2/dist') diff --git a/build2/dist/init b/build2/dist/init new file mode 100644 index 0000000..9a439ea --- /dev/null +++ b/build2/dist/init @@ -0,0 +1,31 @@ +// file : build2/dist/init -*- C++ -*- +// copyright : Copyright (c) 2014-2016 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef BUILD2_DIST_INIT +#define BUILD2_DIST_INIT + +#include +#include + +#include + +namespace build2 +{ + namespace dist + { + void + boot (scope&, const location&, unique_ptr&); + + bool + init (scope&, + scope&, + const location&, + unique_ptr&, + bool, + bool, + const variable_map&); + } +} + +#endif // BUILD2_DIST_INIT diff --git a/build2/dist/init.cxx b/build2/dist/init.cxx new file mode 100644 index 0000000..637a232 --- /dev/null +++ b/build2/dist/init.cxx @@ -0,0 +1,146 @@ +// file : build2/dist/init.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2016 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_; + + void + boot (scope& r, const location&, unique_ptr&) + { + tracer trace ("dist::boot"); + + l5 ([&]{trace << "for " << r.out_path ();}); + + // Register meta-operation. + // + r.meta_operations.insert (dist_id, dist); + + // Enter module variables. Do it during boot in case they get assigned + // in bootstrap.build (which is customary for, e.g., dist.package). + // + { + auto& v (var_pool); + + // Note: some overridable, some not. + // + v.insert ("config.dist.root", true); + v.insert ("config.dist.archives", true); + v.insert ("config.dist.cmd", true); + + v.insert ("dist.root"); + v.insert ("dist.cmd"); + v.insert ("dist.archives"); + + v.insert ("dist"); // Flag. + v.insert ("dist.package"); // Project's package name. + } + } + + bool + init (scope& r, + scope&, + const location& l, + unique_ptr&, + bool first, + bool, + const variable_map& config_hints) + { + tracer trace ("dist::init"); + + if (!first) + { + warn (l) << "multiple dist module initializations"; + return true; + } + + const dir_path& out_root (r.out_path ()); + l5 ([&]{trace << "for " << out_root;}); + + assert (config_hints.empty ()); // We don't known any hints. + + // 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. + // + bool s (config::specified (r, "config.dist")); + + // Adjust module priority so that the config.dist.* values are saved at + // the end of config.build. + // + if (s) + config::save_module (r, "dist", INT32_MAX); + + // dist.root + // + { + value& v (r.assign ("dist.root")); + + if (s) + { + const value& cv (config::optional (r, "config.dist.root")); + + if (cv && !cv.empty ()) // @@ BC LT [null] + v = cast (cv); // Strip abs_dir_path. + } + } + + // dist.cmd + // + { + value& v (r.assign ("dist.cmd")); + + if (s) + { + const value& cv ( + config::required (r, "config.dist.cmd", path ("install")).first); + + if (cv && !cv.empty ()) // @@ BC LT [null] + v = cv; + } + } + + // dist.archives + // + { + value& v (r.assign ("dist.archives")); + + if (s) + { + const value& cv (config::optional (r, "config.dist.archives")); + + if (cv && !cv.empty ()) // @@ BC LT [null] + v = cv; + } + } + + return true; + } + } +} diff --git a/build2/dist/module b/build2/dist/module deleted file mode 100644 index 3c43c1f..0000000 --- a/build2/dist/module +++ /dev/null @@ -1,31 +0,0 @@ -// file : build2/dist/module -*- C++ -*- -// copyright : Copyright (c) 2014-2016 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef BUILD2_DIST_MODULE -#define BUILD2_DIST_MODULE - -#include -#include - -#include - -namespace build2 -{ - namespace dist - { - void - boot (scope&, const location&, unique_ptr&); - - bool - init (scope&, - scope&, - const location&, - unique_ptr&, - bool, - bool, - const variable_map&); - } -} - -#endif // BUILD2_DIST_MODULE diff --git a/build2/dist/module.cxx b/build2/dist/module.cxx deleted file mode 100644 index 2da75c4..0000000 --- a/build2/dist/module.cxx +++ /dev/null @@ -1,146 +0,0 @@ -// file : build2/dist/module.cxx -*- C++ -*- -// copyright : Copyright (c) 2014-2016 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_; - - void - boot (scope& r, const location&, unique_ptr&) - { - tracer trace ("dist::boot"); - - l5 ([&]{trace << "for " << r.out_path ();}); - - // Register meta-operation. - // - r.meta_operations.insert (dist_id, dist); - - // Enter module variables. Do it during boot in case they get assigned - // in bootstrap.build (which is customary for, e.g., dist.package). - // - { - auto& v (var_pool); - - // Note: some overridable, some not. - // - v.insert ("config.dist.root", true); - v.insert ("config.dist.archives", true); - v.insert ("config.dist.cmd", true); - - v.insert ("dist.root"); - v.insert ("dist.cmd"); - v.insert ("dist.archives"); - - v.insert ("dist"); // Flag. - v.insert ("dist.package"); // Project's package name. - } - } - - bool - init (scope& r, - scope&, - const location& l, - unique_ptr&, - bool first, - bool, - const variable_map& config_hints) - { - tracer trace ("dist::init"); - - if (!first) - { - warn (l) << "multiple dist module initializations"; - return true; - } - - const dir_path& out_root (r.out_path ()); - l5 ([&]{trace << "for " << out_root;}); - - assert (config_hints.empty ()); // We don't known any hints. - - // 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. - // - bool s (config::specified (r, "config.dist")); - - // Adjust module priority so that the config.dist.* values are saved at - // the end of config.build. - // - if (s) - config::save_module (r, "dist", INT32_MAX); - - // dist.root - // - { - value& v (r.assign ("dist.root")); - - if (s) - { - const value& cv (config::optional (r, "config.dist.root")); - - if (cv && !cv.empty ()) // @@ BC LT [null] - v = cast (cv); // Strip abs_dir_path. - } - } - - // dist.cmd - // - { - value& v (r.assign ("dist.cmd")); - - if (s) - { - const value& cv ( - config::required (r, "config.dist.cmd", path ("install")).first); - - if (cv && !cv.empty ()) // @@ BC LT [null] - v = cv; - } - } - - // dist.archives - // - { - value& v (r.assign ("dist.archives")); - - if (s) - { - const value& cv (config::optional (r, "config.dist.archives")); - - if (cv && !cv.empty ()) // @@ BC LT [null] - v = cv; - } - } - - return true; - } - } -} -- cgit v1.1