From d402bc96297c6ed3dd6ee883dcff8cc39bd01030 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 18 Jan 2017 13:50:58 +0200 Subject: Ignore prerequisite mtimes that are not linker inputs This makes sure, for example, that we don't unnecessarily re-link an executable when its testscript prerequisite is changes. --- build2/algorithm | 48 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 13 deletions(-) (limited to 'build2/algorithm') diff --git a/build2/algorithm b/build2/algorithm index 9401915..3dbef4c 100644 --- a/build2/algorithm +++ b/build2/algorithm @@ -180,15 +180,31 @@ namespace build2 target_state reverse_execute_prerequisites (action, target&); - // A version of the above that also determines whether the action - // needs to be executed on the target based on the passed mtime - // timestamp. + // A version of the above that also determines whether the action needs to + // be executed on the target based on the passed timestamp and filter. // - // Note that because we use mtime, this function should normally - // only be used in the perform_update action. + // The filter is passed each prerequisite target and is expected to signal + // which ones should be used for timestamp comparison. If the filter is + // NULL, then all the prerequisites are used. // - bool - execute_prerequisites (action, target&, const timestamp&); + // Note that the return value is a pair with the second half indicating + // whether any prerequisites were updated. This is used to handle the + // situation where some prerequisites were updated but no update of the + // target is necessary. In this case we still signal that the target was + // (conceptually, but not physically) changed. This is important both to + // propagate the fact that some work has been done and to also allow our + // dependents to detect this case if they are up to something tricky (like + // recursively linking liba{} prerequisites). + // + // Note that because we use mtime, this function should normally only be + // used in the perform_update action. + // + using prerequisite_filter = function; + + pair + execute_prerequisites (action, target&, + const timestamp&, + const prerequisite_filter& = nullptr); // Another version of the above that does two extra things for the caller: // it determines whether the action needs to be executed on the target based @@ -198,17 +214,23 @@ namespace build2 // prerequisites of the same type may get injected). // template - T* - execute_prerequisites (action, target&, const timestamp&); + pair + execute_prerequisites (action, target&, + const timestamp&, + const prerequisite_filter& = nullptr); - target* + pair execute_prerequisites (const target_type&, - action, target&, const timestamp&); + action, target&, + const timestamp&, + const prerequisite_filter& = nullptr); template - T* + pair execute_prerequisites (const target_type&, - action, target&, const timestamp&); + action, target&, + const timestamp&, + const prerequisite_filter& = nullptr); // Return noop_recipe instead of using this function directly. // -- cgit v1.1