From e879c347f4f05dac5405bcc45ae2d5c9dde5447c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 30 Aug 2016 15:30:39 +0200 Subject: 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 --- build2/variable | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'build2/variable') 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 const variable& + insert (string name, variable_visibility v = variable_visibility::normal) + { + return insert (move (name), &value_traits::value_type, v, false); + } + + template + const variable& insert (string name, - bool overridable = false, + bool overridable, variable_visibility v = variable_visibility::normal) { return insert ( -- cgit v1.1