|
|
@ -216,7 +216,19 @@ let touch_start_file_unless_continue () =
|
|
|
|
if not (Sys.file_exists start = `Yes) then create ()
|
|
|
|
if not (Sys.file_exists start = `Yes) then create ()
|
|
|
|
else if not Config.continue_capture then ( delete () ; create () )
|
|
|
|
else if not Config.continue_capture then ( delete () ; create () )
|
|
|
|
|
|
|
|
|
|
|
|
let run_command ~prog ~args cleanup =
|
|
|
|
exception Infer_error of string
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let default_error_handling : Unix.Exit_or_signal.t -> unit = function
|
|
|
|
|
|
|
|
| Ok _
|
|
|
|
|
|
|
|
-> ()
|
|
|
|
|
|
|
|
| Error _ as status when Config.keep_going
|
|
|
|
|
|
|
|
-> (* Log error and proceed past the failure when keep going mode is on *)
|
|
|
|
|
|
|
|
L.external_error "%s" (Unix.Exit_or_signal.to_string_hum status) ;
|
|
|
|
|
|
|
|
()
|
|
|
|
|
|
|
|
| Error _ as status
|
|
|
|
|
|
|
|
-> raise (Infer_error (Unix.Exit_or_signal.to_string_hum status))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let run_command ?(cleanup= default_error_handling) ~prog ~args () =
|
|
|
|
Unix.waitpid (Unix.fork_exec ~prog ~argv:(prog :: args) ())
|
|
|
|
Unix.waitpid (Unix.fork_exec ~prog ~argv:(prog :: args) ())
|
|
|
|
|> fun status ->
|
|
|
|
|> fun status ->
|
|
|
|
cleanup status ;
|
|
|
|
cleanup status ;
|
|
|
@ -316,13 +328,17 @@ let capture ~changed_files = function
|
|
|
|
Buck.add_flavors_to_buck_command build_cmd
|
|
|
|
Buck.add_flavors_to_buck_command build_cmd
|
|
|
|
else build_cmd ) )
|
|
|
|
else build_cmd ) )
|
|
|
|
in
|
|
|
|
in
|
|
|
|
run_command ~prog:infer_py ~args (function
|
|
|
|
run_command ~prog:infer_py ~args
|
|
|
|
| Result.Error `Exit_non_zero exit_code
|
|
|
|
~cleanup:(function
|
|
|
|
-> if Int.equal exit_code Config.infer_py_argparse_error_exit_code then
|
|
|
|
| Error `Exit_non_zero exit_code
|
|
|
|
(* swallow infer.py argument parsing error *)
|
|
|
|
when Int.equal exit_code Config.infer_py_argparse_error_exit_code
|
|
|
|
|
|
|
|
-> (* swallow infer.py argument parsing error *)
|
|
|
|
Config.print_usage_exit ()
|
|
|
|
Config.print_usage_exit ()
|
|
|
|
| _
|
|
|
|
| Error _ as status
|
|
|
|
|
|
|
|
-> raise (Infer_error (Unix.Exit_or_signal.to_string_hum status))
|
|
|
|
|
|
|
|
| Ok _
|
|
|
|
-> ())
|
|
|
|
-> ())
|
|
|
|
|
|
|
|
()
|
|
|
|
| XcodeXcpretty (prog, args)
|
|
|
|
| XcodeXcpretty (prog, args)
|
|
|
|
-> L.progress "Capturing using xcodebuild and xcpretty...@." ;
|
|
|
|
-> L.progress "Capturing using xcodebuild and xcpretty...@." ;
|
|
|
|
check_xcpretty () ;
|
|
|
|
check_xcpretty () ;
|
|
|
@ -331,22 +347,23 @@ let capture ~changed_files = function
|
|
|
|
in
|
|
|
|
in
|
|
|
|
capture_with_compilation_database ~changed_files json_cdb
|
|
|
|
capture_with_compilation_database ~changed_files json_cdb
|
|
|
|
|
|
|
|
|
|
|
|
let run_parallel_analysis ~changed_files =
|
|
|
|
let run_parallel_analysis ~changed_files : unit =
|
|
|
|
let multicore_dir = Config.results_dir ^/ Config.multicore_dir_name in
|
|
|
|
let multicore_dir = Config.results_dir ^/ Config.multicore_dir_name in
|
|
|
|
Utils.rmtree multicore_dir ;
|
|
|
|
Utils.rmtree multicore_dir ;
|
|
|
|
Unix.mkdir_p multicore_dir ;
|
|
|
|
Unix.mkdir_p multicore_dir ;
|
|
|
|
InferAnalyze.main ~changed_files ~makefile:(multicore_dir ^/ "Makefile") ;
|
|
|
|
InferAnalyze.main ~changed_files ~makefile:(multicore_dir ^/ "Makefile") ;
|
|
|
|
run_command ~prog:"make"
|
|
|
|
run_command ~prog:"make"
|
|
|
|
~args:
|
|
|
|
~args:
|
|
|
|
( "-C"
|
|
|
|
( "--directory"
|
|
|
|
:: multicore_dir
|
|
|
|
:: multicore_dir
|
|
|
|
:: "-k"
|
|
|
|
:: (if Config.keep_going then "--keep-going" else "--no-keep-going")
|
|
|
|
:: "-j"
|
|
|
|
:: "--jobs"
|
|
|
|
:: string_of_int Config.jobs
|
|
|
|
:: string_of_int Config.jobs
|
|
|
|
:: Option.value_map
|
|
|
|
:: Option.value_map
|
|
|
|
~f:(fun l -> ["-l"; string_of_float l])
|
|
|
|
~f:(fun l -> ["--load-average"; string_of_float l])
|
|
|
|
~default:[] Config.load_average
|
|
|
|
~default:[] Config.load_average
|
|
|
|
@ if Config.debug_mode then [] else ["-s"] ) (fun _ -> () )
|
|
|
|
@ if Config.debug_mode then [] else ["--silent"] )
|
|
|
|
|
|
|
|
()
|
|
|
|
|
|
|
|
|
|
|
|
let execute_analyze ~changed_files =
|
|
|
|
let execute_analyze ~changed_files =
|
|
|
|
if Int.equal Config.jobs 1 || Config.cluster_cmdline <> None then
|
|
|
|
if Int.equal Config.jobs 1 || Config.cluster_cmdline <> None then
|
|
|
|