diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2018-07-20 15:31:13 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2018-07-20 16:10:26 +0200 |
commit | c1dc06dfd1d329f8c6499dbe2166725ab9c35e17 (patch) | |
tree | 97449ae7263490473a833944cfeb3d889a2f580d /build2/bash/rule.hxx | |
parent | b4286df8c9bafdab1934cef99ccc0506ec4555e2 (diff) | |
download | build2-c1dc06dfd1d329f8c6499dbe2166725ab9c35e17.tar.gz build2-c1dc06dfd1d329f8c6499dbe2166725ab9c35e17.tar.xz build2-c1dc06dfd1d329f8c6499dbe2166725ab9c35e17.zip |
Implement bash module
Diffstat (limited to 'build2/bash/rule.hxx')
-rw-r--r-- | build2/bash/rule.hxx | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/build2/bash/rule.hxx b/build2/bash/rule.hxx new file mode 100644 index 00000000..9957970d --- /dev/null +++ b/build2/bash/rule.hxx @@ -0,0 +1,81 @@ +// file : build2/bash/rule.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef BUILD2_BASH_RULE_HXX +#define BUILD2_BASH_RULE_HXX + +#include <build2/types.hxx> +#include <build2/utility.hxx> + +#include <build2/in/rule.hxx> +#include <build2/install/rule.hxx> + +namespace build2 +{ + namespace bash + { + // Preprocess a bash script (exe{}) or module (bash{}) .in file that + // imports one or more bash modules. + // + // Note that the default substitution symbol is '@' and the mode is lax + // (think bash arrays). The idea is that '@' is normally used in ways that + // are highly unlikely to be misinterpreted as substitutions. The user, + // however, is still able to override both of these choices with the + // corresponding in.* variables (e.g., to use '`' and strict mode). + // + class in_rule: public in::rule + { + public: + in_rule (): rule ("bash.in 1", "bash.in", '@', false /* strict */) {} + + virtual bool + match (action, target&, const string&) const override; + + virtual recipe + apply (action, target&) const override; + + virtual target_state + perform_update (action, const target&) const override; + + virtual prerequisite_target + search (action, + const target&, + const prerequisite_member&, + include_type) const override; + + virtual optional<string> + substitute (const location&, + action a, + const target&, + const string&, + bool) const override; + + string + substitute_import (const location&, + action a, + const target&, + const string&) const; + }; + + // Installation rule for bash scripts (exe{}) and modules (bash{}) that + // signals to in_rule that this is update for install. + // + class install_rule: public install::file_rule + { + public: + install_rule (const in_rule& in): in_ (in) {} + + virtual bool + match (action, target&, const string&) const override; + + virtual recipe + apply (action, target&) const override; + + private: + const in_rule& in_; + }; + } +} + +#endif // BUILD2_BASH_RULE_HXX |