From 930ae81f85e5ee5ac37311f5e9c89000fbcb59a6 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 1 Aug 2019 16:17:09 +0300 Subject: Move bash build system module to separate library --- libbuild2/bash/init.cxx | 104 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 libbuild2/bash/init.cxx (limited to 'libbuild2/bash/init.cxx') diff --git a/libbuild2/bash/init.cxx b/libbuild2/bash/init.cxx new file mode 100644 index 0000000..17c9ddd --- /dev/null +++ b/libbuild2/bash/init.cxx @@ -0,0 +1,104 @@ +// file : libbuild2/bash/init.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2019 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include + +using namespace std; + +namespace build2 +{ + namespace bash + { + static const in_rule in_rule_; + static const install_rule install_rule_ (in_rule_); + + bool + init (scope& rs, + scope& bs, + const location& l, + unique_ptr&, + bool, + bool, + const variable_map&) + { + tracer trace ("bash::init"); + l5 ([&]{trace << "for " << bs;}); + + // Load in.base (in.* variables, in{} target type). + // + if (!cast_false (rs["in.base.loaded"])) + load_module (rs, rs, "in.base", l); + + bool install_loaded (cast_false (rs["install.loaded"])); + + // Register target types and configure default installability. + // + bs.target_types.insert (); + + if (install_loaded) + { + using namespace install; + + // Install into bin// by default stripping the .bash + // extension from if present. + // + const project_name& p (cast (rs.vars[var_project])); + + install_path (bs, dir_path ("bin") /= project_base (p)); + install_mode (bs, "644"); + } + + // Register rules. + // + { + auto& r (bs.rules); + + r.insert (perform_update_id, "bash.in", in_rule_); + r.insert (perform_clean_id, "bash.in", in_rule_); + r.insert (configure_update_id, "bash.in", in_rule_); + + r.insert (perform_update_id, "bash.in", in_rule_); + r.insert (perform_clean_id, "bash.in", in_rule_); + r.insert (configure_update_id, "bash.in", in_rule_); + + if (install_loaded) + { + r.insert (perform_install_id, "bash.install", install_rule_); + r.insert (perform_uninstall_id, "bash.uninstall", install_rule_); + + r.insert (perform_install_id, "bash.install", install_rule_); + r.insert (perform_uninstall_id, "bash.uninstall", install_rule_); + } + } + + return true; + } + + static const module_functions mod_functions[] = + { + // NOTE: don't forget to also update the documentation in init.hxx if + // changing anything here. + + {"bash", nullptr, init}, + {nullptr, nullptr, nullptr} + }; + + const module_functions* + build2_bash_load () + { + return mod_functions; + } + } +} -- cgit v1.1