Fix some issues with merging the capture from several buck targets.

Reviewed By: jberdine

Differential Revision: D3125949

fb-gh-sync-id: dd9e263
fbshipit-source-id: dd9e263
master
Cristiano Calcagno 9 years ago committed by Facebook Github Bot 0
parent a8de56e9bf
commit d2ff52e17c

@ -240,8 +240,7 @@ let () = (* parse command-line arguments *)
begin begin
L.err "ERROR: results directory %s does not exist@.@." !Config.results_dir; L.err "ERROR: results directory %s does not exist@.@." !Config.results_dir;
print_usage_exit () print_usage_exit ()
end ; end
if !Config.merge then MergeCapture.merge_captured_targets ()
let analyze_exe_env exe_env = let analyze_exe_env exe_env =
let init_time = Unix.gettimeofday () in let init_time = Unix.gettimeofday () in
@ -374,6 +373,7 @@ let () =
process_cluster_cmdline fname; process_cluster_cmdline fname;
finish_logging () finish_logging ()
| None -> | None ->
if !Config.merge then MergeCapture.merge_captured_targets ();
let clusters = DB.find_source_dirs () in let clusters = DB.find_source_dirs () in
L.err "Found %d source files in %s@." L.err "Found %d source files in %s@."
(IList.length clusters) !Config.results_dir; (IList.length clusters) !Config.results_dir;

@ -16,7 +16,12 @@ module F = Format
is used to determine whether a captured directory needs to be merged. *) is used to determine whether a captured directory needs to be merged. *)
let check_timestamp_of_symlinks = true let check_timestamp_of_symlinks = true
let buck_out () = Filename.concat (Filename.dirname !Config.results_dir) "buck-out" let buck_out () =
match !Config.project_root with
| Some root ->
Filename.concat root "buck-out"
| None ->
Filename.concat (Filename.dirname !Config.results_dir) "buck-out"
let infer_deps () = Filename.concat !Config.results_dir "infer-deps.txt" let infer_deps () = Filename.concat !Config.results_dir "infer-deps.txt"
@ -43,6 +48,12 @@ let empty_stats () =
targets_merged = 0; targets_merged = 0;
} }
let link_exists s =
try
let _ = Unix.lstat s in
true
with Unix.Unix_error _ -> false
(** Create symbolic links recursively from the destination to the source. (** Create symbolic links recursively from the destination to the source.
Replicate the structure of the source directory in the destination, Replicate the structure of the source directory in the destination,
with files replaced by links to the source. *) with files replaced by links to the source. *)
@ -61,14 +72,14 @@ let rec slink ~stats src dst =
end end
else else
begin begin
if Sys.file_exists dst then Sys.remove dst; if link_exists dst then Unix.unlink dst;
Unix.symlink src dst; Unix.symlink src dst;
(* Set the accessed and modified time of the new symlink to be slightly in the future. Due to (* Set the accessed and modified time of the original file slightly in the past. Due to
the coarse precision of the timestamps, it is possible for the source and destination of a the coarse precision of the timestamps, it is possible for the source and destination of a
link to have the same modification time. When this happens, the files will be considered to link to have the same modification time. When this happens, the files will be considered to
need re-analysis every time, indefinitely. *) need re-analysis every time, indefinitely. *)
let near_future = Unix.gettimeofday () +. 1. in let near_past = Unix.gettimeofday () -. 1. in
Unix.utimes dst near_future near_future ; Unix.utimes src near_past near_past;
stats.files_linked <- stats.files_linked + 1; stats.files_linked <- stats.files_linked + 1;
end end

Loading…
Cancel
Save