diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-07-01 16:45:34 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-07-01 16:45:34 +0200 |
commit | e4c4fec8c9097722ee5ee94f2ce5ad0313ed8d7b (patch) | |
tree | e8de68957fc5cd00bb7b0b3199ca8a9abba4f678 /build/target | |
parent | f7e9830c0c413f05737002dcc8d06e73cb379980 (diff) |
Clean up group state, mtime design
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;} |