aboutsummaryrefslogtreecommitdiff
path: root/build2/cc
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-04-17 13:42:37 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-04-17 13:42:37 +0200
commitca0f9c71be279aee845bf5328ac0af8c02c8849e (patch)
treef8e5ccf1722a90895af7aef36e775fac0088ee7e /build2/cc
parent9f537aca20984524a442e4829e5bba2e9f0df91b (diff)
Incorporate ad hoc prerequisite mtime into out-of-date determination
Diffstat (limited to 'build2/cc')
-rw-r--r--build2/cc/compile-rule.cxx3
-rw-r--r--build2/cc/link-rule.cxx35
2 files changed, 28 insertions, 10 deletions
diff --git a/build2/cc/compile-rule.cxx b/build2/cc/compile-rule.cxx
index 3ed6075..298194a 100644
--- a/build2/cc/compile-rule.cxx
+++ b/build2/cc/compile-rule.cxx
@@ -4317,6 +4317,9 @@ namespace build2
// execute them to keep the dependency counts straight. Actually, no, we
// may also have to update the modules.
//
+ // Note that this also takes care of forcing update on any ad hoc
+ // prerequisite change.
+ //
auto pr (
execute_prerequisites<file> (
(mod ? *x_mod : x_src),
diff --git a/build2/cc/link-rule.cxx b/build2/cc/link-rule.cxx
index 28d4fc6..443f91d 100644
--- a/build2/cc/link-rule.cxx
+++ b/build2/cc/link-rule.cxx
@@ -1633,13 +1633,34 @@ namespace build2
bool binless (md.binless);
assert (ot != otype::e || !binless); // Sanity check.
- // Update prerequisites. We determine if any relevant ones render us
- // out-of-date manually below.
+ // Determine if we are out-of-date.
+ //
+ bool update (false);
+ bool scratch (false);
+ timestamp mt (binless ? timestamp_unreal : t.load_mtime ());
+
+ // Update prerequisites. We determine if any relevant non-ad hoc ones
+ // render us out-of-date manually below.
//
- // Note that straight_execute_prerequisites() blanks out all the ad hoc
+ // Note that execute_prerequisites() blanks out all the ad hoc
// prerequisites so we don't need to worry about them from now on.
//
- target_state ts (straight_execute_prerequisites (a, t));
+ target_state ts;
+
+ if (optional<target_state> s =
+ execute_prerequisites (a,
+ t,
+ mt,
+ [] (const target&, size_t) {return false;}))
+ ts = *s;
+ else
+ {
+ // An ad hoc prerequisite renders us out-of-date. Let's update from
+ // scratch for good measure.
+ //
+ scratch = update = true;
+ ts = target_state::changed;
+ }
// (Re)generate pkg-config's .pc file. While the target itself might be
// up-to-date from a previous run, there is no guarantee that .pc exists
@@ -1661,11 +1682,6 @@ namespace build2
return ts;
}
- // Determine if we are out-of-date.
- //
- bool update (false);
- timestamp mt (t.load_mtime ());
-
// Open the dependency database (do it before messing with Windows
// manifests to diagnose missing output directory).
//
@@ -2120,7 +2136,6 @@ namespace build2
// target (interrupted update) then force the target update. Also note
// this situation in the "from scratch" flag.
//
- bool scratch (false);
if (dd.writing () || dd.mtime > mt)
scratch = update = true;