diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-08-30 15:30:39 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-08-30 15:30:39 +0200 |
commit | e879c347f4f05dac5405bcc45ae2d5c9dde5447c (patch) | |
tree | 8ad9956bf66a3b28c9628608e8b9c9787e2c34a5 /build2/variable | |
parent | dee70af1d3b6ca4caf1027b79eb471b28624fff8 (diff) |
Add support for target visibility, use for dist, test, install
This means we can no longer write:
install = false
Now it should be:
*: install = false
Diffstat (limited to 'build2/variable')
-rw-r--r-- | build2/variable | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/build2/variable b/build2/variable index fb44bb4..000ac9c 100644 --- a/build2/variable +++ b/build2/variable @@ -80,9 +80,13 @@ namespace build2 enum class variable_visibility { + target, // Target and target type/pattern-specific. scope, // This scope (no outer scopes). project, // This project (no outer projects). normal // All outer scopes. + + // Note that the search for target type/pattern-specific terminates at + // the project boundary. }; // variable @@ -119,6 +123,9 @@ namespace build2 inline bool operator== (const variable& x, const variable& y) {return x.name == y.name;} + inline ostream& + operator<< (ostream& os, const variable& v) {return os << v.name;} + // // class value @@ -697,8 +704,14 @@ namespace build2 struct variable_pool: private variable_pool_base { const variable& + insert (string name, variable_visibility v = variable_visibility::normal) + { + return insert (move (name), nullptr, v, false); + } + + const variable& insert (string name, - bool overridable = false, + bool overridable, variable_visibility v = variable_visibility::normal) { return insert (move (name), nullptr, v, overridable); @@ -706,8 +719,15 @@ namespace build2 template <typename T> const variable& + insert (string name, variable_visibility v = variable_visibility::normal) + { + return insert (move (name), &value_traits<T>::value_type, v, false); + } + + template <typename T> + const variable& insert (string name, - bool overridable = false, + bool overridable, variable_visibility v = variable_visibility::normal) { return insert ( |