From 95eca26bf0acf8614f3116761853eaa71c1a1dd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Dimino?= Date: Sun, 5 Mar 2017 12:33:49 +0000 Subject: [PATCH] Don't delete targets before executing a rule At the moment, this breaks incremental builds --- src/build_system.ml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/build_system.ml b/src/build_system.ml index 1ce446d3..c385ba11 100644 --- a/src/build_system.ml +++ b/src/build_system.ml @@ -246,7 +246,7 @@ let refresh_targets_timestamps_after_rule_execution t targets = | exception _ -> Pset.add fn acc | stat -> let ts = stat.st_mtime in - Hashtbl.add t.timestamps ~key:fn ~data:ts; + Hashtbl.replace t.timestamps ~key:fn ~data:ts; acc) in if not (Pset.is_empty missing) then @@ -318,7 +318,15 @@ let compile_rule t ~all_targets_by_dir ?(allow_override=false) pre_rule = acc || prev_hash <> hash) in if rule_changed || min_timestamp t targets < max_timestamp t all_deps then begin - List.iter targets ~f:Path.unlink_no_err; + (* CR-someday jdimino: we should remove the targets to be sure + the action re-generate them, however it breaks incrementality + regarding [Write_file ...] actions, since they end up + systematically re-creating the file: + + {[ + List.iter targets ~f:Path.unlink_no_err; + ]} + *) Action.exec action >>| fun () -> refresh_targets_timestamps_after_rule_execution t targets end else