Remove files from the digest cache when promoting them.
This is to avoid problems with incremental compilation on OSX. Fix #456
This commit is contained in:
parent
a80d70aa26
commit
b9c4dd2339
|
@ -87,6 +87,9 @@
|
||||||
- Always build `boot.exe` as a bytecode program. It makes the build of
|
- Always build `boot.exe` as a bytecode program. It makes the build of
|
||||||
jbuilder faster and fix the build on some architectures (#463, fixes #446)
|
jbuilder faster and fix the build on some architectures (#463, fixes #446)
|
||||||
|
|
||||||
|
- Fix bad interaction between promotion and incremental builds on OSX
|
||||||
|
(#460, fix #456)
|
||||||
|
|
||||||
1.0+beta16 (05/11/2017)
|
1.0+beta16 (05/11/2017)
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
|
|
|
@ -1148,7 +1148,11 @@ let promote =
|
||||||
] in
|
] in
|
||||||
let go common =
|
let go common =
|
||||||
set_common common ~targets:[];
|
set_common common ~targets:[];
|
||||||
Action.Promotion.promote_files_registered_in_last_run ()
|
(* We load and restore the digest cache as we need to clear the
|
||||||
|
cache for promoted files, due to issues on OSX. *)
|
||||||
|
Utils.Cached_digest.load ();
|
||||||
|
Action.Promotion.promote_files_registered_in_last_run ();
|
||||||
|
Utils.Cached_digest.dump ()
|
||||||
in
|
in
|
||||||
( Term.(const go
|
( Term.(const go
|
||||||
$ common)
|
$ common)
|
||||||
|
|
|
@ -630,10 +630,29 @@ module Promotion = struct
|
||||||
|
|
||||||
let do_promote db =
|
let do_promote db =
|
||||||
let by_targets = group_by_targets db in
|
let by_targets = group_by_targets db in
|
||||||
|
let potential_build_contexts =
|
||||||
|
match Path.readdir Path.build_dir with
|
||||||
|
| exception _ -> []
|
||||||
|
| files ->
|
||||||
|
List.filter_map files ~f:(fun fn ->
|
||||||
|
if fn = "" || fn.[0] = '.' || fn = "install" then
|
||||||
|
None
|
||||||
|
else
|
||||||
|
let path = Path.(relative build_dir) fn in
|
||||||
|
Option.some_if (Path.is_directory path) path)
|
||||||
|
in
|
||||||
|
let dirs_to_clear_from_cache = Path.root :: potential_build_contexts in
|
||||||
Path.Map.iter by_targets ~f:(fun ~key:dst ~data:srcs ->
|
Path.Map.iter by_targets ~f:(fun ~key:dst ~data:srcs ->
|
||||||
match srcs with
|
match srcs with
|
||||||
| [] -> assert false
|
| [] -> assert false
|
||||||
| src :: others ->
|
| src :: others ->
|
||||||
|
(* We remove the files from the digest cache to force a rehash
|
||||||
|
on the next run. We do this because on OSX [mtime] is not
|
||||||
|
precise enough and if a file is modified and promoted
|
||||||
|
quickly, it will look like it hasn't changed even though it
|
||||||
|
might have. *)
|
||||||
|
List.iter dirs_to_clear_from_cache ~f:(fun dir ->
|
||||||
|
Utils.Cached_digest.remove (Path.append dir dst));
|
||||||
File.promote { src; dst };
|
File.promote { src; dst };
|
||||||
List.iter others ~f:(fun path ->
|
List.iter others ~f:(fun path ->
|
||||||
Format.eprintf " -> ignored %s.@."
|
Format.eprintf " -> ignored %s.@."
|
||||||
|
|
|
@ -1056,7 +1056,6 @@ module Trace = struct
|
||||||
let file = "_build/.db"
|
let file = "_build/.db"
|
||||||
|
|
||||||
let dump (trace : t) =
|
let dump (trace : t) =
|
||||||
Utils.Cached_digest.dump ();
|
|
||||||
let sexp =
|
let sexp =
|
||||||
Sexp.List (
|
Sexp.List (
|
||||||
Hashtbl.fold trace ~init:Pmap.empty ~f:(fun ~key ~data acc ->
|
Hashtbl.fold trace ~init:Pmap.empty ~f:(fun ~key ~data acc ->
|
||||||
|
@ -1069,7 +1068,6 @@ module Trace = struct
|
||||||
Io.write_file file (Sexp.to_string sexp)
|
Io.write_file file (Sexp.to_string sexp)
|
||||||
|
|
||||||
let load () =
|
let load () =
|
||||||
Utils.Cached_digest.load ();
|
|
||||||
let trace = Hashtbl.create 1024 in
|
let trace = Hashtbl.create 1024 in
|
||||||
if Sys.file_exists file then begin
|
if Sys.file_exists file then begin
|
||||||
let sexp = Sexp.load ~fname:file ~mode:Single in
|
let sexp = Sexp.load ~fname:file ~mode:Single in
|
||||||
|
@ -1090,11 +1088,15 @@ let all_targets t =
|
||||||
Hashtbl.fold t.files ~init:[] ~f:(fun ~key ~data:_ acc -> key :: acc)
|
Hashtbl.fold t.files ~init:[] ~f:(fun ~key ~data:_ acc -> key :: acc)
|
||||||
|
|
||||||
let finalize t =
|
let finalize t =
|
||||||
|
(* Promotion must be handled before dumping the digest cache, as it might delete some
|
||||||
|
entries. *)
|
||||||
|
Action.Promotion.finalize ();
|
||||||
Promoted_to_delete.dump ();
|
Promoted_to_delete.dump ();
|
||||||
Trace.dump t.trace;
|
Utils.Cached_digest.dump ();
|
||||||
Action.Promotion.finalize ()
|
Trace.dump t.trace
|
||||||
|
|
||||||
let create ~contexts ~file_tree =
|
let create ~contexts ~file_tree =
|
||||||
|
Utils.Cached_digest.load ();
|
||||||
let contexts =
|
let contexts =
|
||||||
List.map contexts ~f:(fun c -> (c.Context.name, c))
|
List.map contexts ~f:(fun c -> (c.Context.name, c))
|
||||||
|> String_map.of_alist_exn
|
|> String_map.of_alist_exn
|
||||||
|
|
|
@ -196,10 +196,7 @@ module Cached_digest = struct
|
||||||
};
|
};
|
||||||
digest
|
digest
|
||||||
|
|
||||||
let remove fn =
|
let remove fn = Hashtbl.remove cache fn
|
||||||
match Hashtbl.find cache fn with
|
|
||||||
| None -> ()
|
|
||||||
| Some file -> file.timestamp_checked <- false
|
|
||||||
|
|
||||||
let db_file = "_build/.digest-db"
|
let db_file = "_build/.digest-db"
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
$ echo titi > x
|
$ printf titi > x
|
||||||
|
|
||||||
$ $JBUILDER build --root . -j1 --diff-command false @blah 2>&1 | sed 's/.*false.*/DIFF/'
|
$ $JBUILDER build --root . -j1 --diff-command false @blah 2>&1 | sed 's/.*false.*/DIFF/'
|
||||||
sh (internal) (exit 1)
|
sh (internal) (exit 1)
|
||||||
|
@ -15,7 +15,10 @@
|
||||||
$ cat x
|
$ cat x
|
||||||
toto
|
toto
|
||||||
|
|
||||||
$ echo titi > x
|
Otherwise this test fails on OSX
|
||||||
|
$ jbuilder clean --root . -j1
|
||||||
|
|
||||||
|
$ printf titi > x
|
||||||
$ $JBUILDER build --root . -j1 --diff-command false @blah --auto-promote 2>&1 | sed 's/.*false.*/DIFF/'
|
$ $JBUILDER build --root . -j1 --diff-command false @blah --auto-promote 2>&1 | sed 's/.*false.*/DIFF/'
|
||||||
sh (internal) (exit 1)
|
sh (internal) (exit 1)
|
||||||
DIFF
|
DIFF
|
||||||
|
|
Loading…
Reference in New Issue