aboutsummaryrefslogtreecommitdiff
path: root/build/target
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-03-10 15:42:04 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-03-10 15:42:04 +0200
commit5925c11a1fe8b2e02b790dd40b031ae005d5b68f (patch)
tree14455da2f4b58d49542023ef0b415414b926d56f /build/target
parent5807ff000225acf47064eb7f0be965bf1598faaa (diff)
Further operation implementation
Diffstat (limited to 'build/target')
-rw-r--r--build/target20
1 files changed, 16 insertions, 4 deletions
diff --git a/build/target b/build/target
index 9c4640e..a49c57f 100644
--- a/build/target
+++ b/build/target
@@ -19,6 +19,7 @@
#include <build/key-set>
#include <build/timestamp>
#include <build/name>
+#include <build/operation>
#include <build/prerequisite>
#include <build/utility> // compare_*, extension_pool
@@ -26,11 +27,11 @@ namespace build
{
class target;
- enum class target_state {unknown, uptodate, updated, failed};
+ enum class target_state {unknown, unchanged, changed, failed};
// Note: should throw rather than returning target_state::failed.
//
- typedef std::function<target_state (target&)> recipe;
+ typedef std::function<target_state (action, target&)> recipe;
struct target_type
{
@@ -71,10 +72,19 @@ namespace build
typedef build::recipe recipe_type;
const recipe_type&
- recipe () const {return recipe_;}
+ recipe (action_id a) const {return action_ == a ? recipe_ : empty_recipe_;}
void
- recipe (recipe_type r) {assert (!recipe_); recipe_ = r;}
+ recipe (action_id a, recipe_type r)
+ {
+ assert (action_ != a || !recipe_);
+ action_ = a;
+ recipe_ = r;
+
+ // Also reset the target state.
+ //
+ state_ = target_state::unknown;
+ }
public:
target_state
@@ -92,7 +102,9 @@ namespace build
static const target_type static_type;
private:
+ action_id action_ {0}; // Action id of this target recipe.
recipe_type recipe_;
+ static const recipe_type empty_recipe_;
target_state state_ {target_state::unknown};
};