aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-08-20 15:56:26 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-08-20 15:56:26 +0200
commit5058b155076b004f4abf21be6cf657a3f2cc4d1b (patch)
tree2a1675598de93c22ef9850996cfd2964fb11480c
parentc9c366bc5f77a806384ebf678fe4335c1422884c (diff)
Add support for not cleaning generated version file
-rw-r--r--build2/context.cxx4
-rw-r--r--build2/context.hxx4
-rw-r--r--build2/variable.hxx14
-rw-r--r--build2/variable.ixx9
-rw-r--r--build2/version/rule.cxx5
5 files changed, 30 insertions, 6 deletions
diff --git a/build2/context.cxx b/build2/context.cxx
index 11c2c63..f7f2448 100644
--- a/build2/context.cxx
+++ b/build2/context.cxx
@@ -191,6 +191,8 @@ namespace build2
const variable* var_import_target;
+ const variable* var_clean;
+
const string* current_mname;
const string* current_oname;
@@ -538,6 +540,8 @@ namespace build2
var_project_summary = &vp.insert<string> ("project.summary", pv);
var_import_target = &vp.insert<name> ("import.target");
+
+ var_clean = &vp.insert<bool> ("clean", variable_visibility::target);
}
// Register builtin rules.
diff --git a/build2/context.hxx b/build2/context.hxx
index bf31887..dbb41ae 100644
--- a/build2/context.hxx
+++ b/build2/context.hxx
@@ -254,7 +254,9 @@ namespace build2
extern const variable* var_project_url; // project.url
extern const variable* var_project_summary; // project.summary
- extern const variable* var_import_target; // import.target
+ extern const variable* var_import_target; // import.target
+
+ extern const variable* var_clean; // [bool] target visibility
// Current action (meta/operation).
//
diff --git a/build2/variable.hxx b/build2/variable.hxx
index decc300..5ef67fd 100644
--- a/build2/variable.hxx
+++ b/build2/variable.hxx
@@ -283,12 +283,16 @@ namespace build2
template <typename T> const T* cast_null (const value&);
template <typename T> const T* cast_null (const lookup&);
- // As above but returns false if the value is NULL (or not defined, in case
- // of lookup). Note that the template argument is only for documentation and
- // should be bool (or semantically compatible).
+ // As above but returns false/true if the value is NULL (or not defined,
+ // in case of lookup). Note that the template argument is only for
+ // documentation and should be bool (or semantically compatible).
//
- template <typename T> T cast_false (const value& v);
- template <typename T> T cast_false (const lookup& l);
+ template <typename T> T cast_false (const value&);
+ template <typename T> T cast_false (const lookup&);
+
+ template <typename T> T cast_true (const value&);
+ template <typename T> T cast_true (const lookup&);
+
// Assign value type to the value. In the second version the variable is
// optional and is only used for diagnostics.
diff --git a/build2/variable.ixx b/build2/variable.ixx
index 8656a04..04cf6dc 100644
--- a/build2/variable.ixx
+++ b/build2/variable.ixx
@@ -193,6 +193,15 @@ namespace build2
cast_false (const lookup& l) {return l && cast<T> (l);}
template <typename T>
+ inline T
+ cast_true (const value& v) {return !v || cast<T> (v);}
+
+ template <typename T>
+ inline T
+ cast_true (const lookup& l) {return !l || cast<T> (l);}
+
+
+ template <typename T>
inline void
typify (value& v, const variable& var)
{
diff --git a/build2/version/rule.cxx b/build2/version/rule.cxx
index a9d62ba..3c9723e 100644
--- a/build2/version/rule.cxx
+++ b/build2/version/rule.cxx
@@ -81,6 +81,11 @@ namespace build2
{
doc& t (static_cast<doc&> (xt));
+ // If this is clean check if we were asked not to remove it.
+ //
+ if (a == perform_clean_id && !cast_true<bool> (t[var_clean]))
+ return noop_recipe;
+
// Derive the file name.
//
t.derive_path ();