From e4c4fec8c9097722ee5ee94f2ce5ad0313ed8d7b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 1 Jul 2015 16:45:34 +0200 Subject: Clean up group state, mtime design --- build/target | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'build/target') diff --git a/build/target b/build/target index 000496c..39f6679 100644 --- a/build/target +++ b/build/target @@ -782,17 +782,40 @@ namespace build public: using target::target; + // Target mtime is only available after a rule has been matched + // (because this is when we know if we should get our mtime from + // the group and where the path which we need to load mtime is + // normally assigned). The mtime is also unavailable while the + // execution of the target is postponed (because we temporarily + // loose our group state). + // + // The rule for groups that utilize the group state is as follows: + // if it has any members that are mtime_targets, then the group + // should be mtime_target and the members get the mtime from it. + // timestamp mtime () const { - if (mtime_ == timestamp_unknown) - mtime_ = load_mtime (); + assert (raw_state != target_state::postponed); + + const mtime_target* t (raw_state == target_state::group + ? static_cast (group) + : this); + + if (t->mtime_ == timestamp_unknown) + t->mtime_ = t->load_mtime (); - return mtime_; + return t->mtime_; } void - mtime (timestamp mt) {mtime_ = mt;} + mtime (timestamp mt) + { + // While we can cache the mtime at any time, it may be ignored + // if the target state is group (see the mtime() accessor). + // + mtime_ = mt; + } protected: virtual timestamp @@ -853,8 +876,11 @@ namespace build using path_target::path_target; protected: + // Note that it is final in order to be consistent with file_rule, + // search_existing_file(). + // virtual timestamp - load_mtime () const; + load_mtime () const final; public: virtual const target_type& type () const {return static_type;} -- cgit v1.1