diff options
Diffstat (limited to 'build/target')
-rw-r--r-- | build/target | 36 |
1 files changed, 31 insertions, 5 deletions
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<const mtime_target*> (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;} |