aboutsummaryrefslogtreecommitdiff
path: root/build/rule
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-07-24 16:39:55 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-07-24 16:39:55 +0200
commit1d6e68fda762535fa8508f94ca254a79f293edb2 (patch)
tree7b97edd9f1786cd610c1f41e720d2b105dd87cbc /build/rule
parentbb4f9e6498ba715911f83e0dc221a5b1b86baf51 (diff)
Add support for generated test input/output
Diffstat (limited to 'build/rule')
-rw-r--r--build/rule17
1 files changed, 16 insertions, 1 deletions
diff --git a/build/rule b/build/rule
index ea0b5ae..a144a9b 100644
--- a/build/rule
+++ b/build/rule
@@ -34,8 +34,9 @@ namespace build
target_type* target;
- match_result (target_type& t, bool v): value (v), target (&t) {}
+ action recipe_action = action (); // Used as recipe's action if set.
+ match_result (target_type& t, bool v): value (v), target (&t) {}
match_result (std::nullptr_t v = nullptr): prerequisite (v), target (v) {}
match_result (prerequisite_type& p): prerequisite (&p), target (nullptr) {}
match_result (prerequisite_type* p): prerequisite (p), target (nullptr) {}
@@ -76,6 +77,20 @@ namespace build
static target_state
perform_update (action, target&);
+ // Sometimes it is useful, normally as an optimization, to check
+ // if the file target is up to date. In particular, if the rule
+ // that matched a target is this fallback rule and the target
+ // has no prerequisites, then it means it is up to date.
+ //
+ static bool
+ uptodate (action a, target& t)
+ {
+ recipe_function* const* r (t.recipe (a).target<recipe_function*> ());
+ return r != nullptr && *r == &perform_update &&
+ t.prerequisites.empty () &&
+ (t.group == nullptr || t.group->prerequisites.empty ());
+ }
+
static file_rule instance;
};