From 5925c11a1fe8b2e02b790dd40b031ae005d5b68f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 10 Mar 2015 15:42:04 +0200 Subject: Further operation implementation --- build/target | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'build/target') diff --git a/build/target b/build/target index 9c4640e..a49c57f 100644 --- a/build/target +++ b/build/target @@ -19,6 +19,7 @@ #include #include #include +#include #include #include // 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 recipe; + typedef std::function 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}; }; -- cgit v1.1