[driver] make clear when the results dir becomes available

Summary:
The logic is not that simple and this will be needed in a later diff to create
the log file as early as possible.

Reviewed By: jberdine

Differential Revision: D5173128

fbshipit-source-id: 830f105
master
Jules Villard 8 years ago committed by Facebook Github Bot
parent 5fae8ca712
commit 644066f4be

@ -548,16 +548,28 @@ let differential_mode () =
Unix.mkdir_p out_path;
Differential.to_files diff out_path
let assert_results_dir advice =
if Sys.file_exists Config.results_dir <> `Yes then (
L.stderr "ERROR: results directory %s does not exist@\nERROR: %s@." Config.results_dir advice;
exit 1
)
let setup_results_dir () =
match Config.command with
| Analyze -> assert_results_dir "have you run capture before?"
| Clang | Report | ReportDiff -> create_results_dir ()
| Capture | Compile | Run ->
(* These have their own logic depending on the rest of the command line. It particular they
might delete the previous results directory. Let them do their thing. *)
()
let () =
if Config.print_builtins then Builtin.print_and_exit ();
setup_results_dir ();
match Config.command with
| Analyze ->
Logging.set_log_file_identifier
CommandLineOption.Analyze (Option.map ~f:Filename.basename Config.cluster_cmdline);
if Sys.file_exists Config.results_dir <> `Yes then (
L.stderr "ERROR: results directory %s does not exist@.@." Config.results_dir;
Config.print_usage_exit ()
);
InferAnalyze.register_perf_stats_report ();
analyze Analyze
| Clang ->

@ -42,8 +42,7 @@ let register_perf_stats_report source_file => {
let stats_dir = Filename.concat Config.results_dir Config.frontend_stats_dir_name;
let abbrev_source_file = DB.source_file_encoding source_file;
let stats_file = Config.perf_stats_prefix ^ "_" ^ abbrev_source_file ^ ".json";
Utils.create_dir Config.results_dir;
Utils.create_dir stats_dir;
Unix.mkdir_p stats_dir;
PerfStats.register_report_at_exit (Filename.concat stats_dir stats_file)
};

Loading…
Cancel
Save