From c1dc06dfd1d329f8c6499dbe2166725ab9c35e17 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 20 Jul 2018 15:31:13 +0200 Subject: Implement bash module --- build2/bash/init.cxx | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 build2/bash/init.cxx (limited to 'build2/bash/init.cxx') diff --git a/build2/bash/init.cxx b/build2/bash/init.cxx new file mode 100644 index 0000000..ff653c2 --- /dev/null +++ b/build2/bash/init.cxx @@ -0,0 +1,89 @@ +// file : build2/bash/init.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2018 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.out_path ();}); + + // Load in.base (in.* varibales, 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 string& 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; + } + } +} -- cgit v1.1