From 44ebe59b99174605cbf9bbe5ddd43899ccbe71f5 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Tue, 7 Apr 2020 01:54:50 -0700 Subject: [PATCH] [config][easy] make Config.temp_file_dir relative and rename Summary: This makes it similar to the other dir names in infer-out/. Reviewed By: ngorogiannis Differential Revision: D20795359 fbshipit-source-id: 88729d26d --- infer/src/base/Config.ml | 6 ++- infer/src/base/Config.mli | 40 ++++++++++--------- infer/src/base/ResultsDir.ml | 2 +- infer/src/integration/Buck.ml | 4 +- infer/src/integration/BuckGenrule.ml | 2 +- .../integration/CaptureCompilationDatabase.ml | 2 +- infer/src/integration/ClangQuotes.ml | 2 +- infer/src/integration/Gradle.ml | 4 +- infer/src/integration/Javac.ml | 4 +- 9 files changed, 35 insertions(+), 31 deletions(-) diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index cde2d1392..826f25b90 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -232,6 +232,8 @@ let starvation_issues_dir_name = "starvation_issues" let test_determinator_results = "test_determinator_results" +let temp_dir_name = "tmp" + (** Enable detailed tracing information during array abstraction *) let trace_absarray = false @@ -3035,8 +3037,6 @@ and custom_symbols = and symops_per_iteration = !symops_per_iteration -and temp_file_dir = !results_dir ^/ "tmp" - and keep_going = !keep_going and test_determinator = !test_determinator @@ -3106,6 +3106,8 @@ let is_checker_enabled c = let captured_dir = results_dir ^/ captured_dir_name +let temp_dir = results_dir ^/ temp_dir_name + let clang_frontend_action_string = let text = if capture then ["translating"] else [] in let text = if is_checker_enabled Linters then "linting" :: text else text in diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index 12d1a872a..dc184ae87 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -128,8 +128,6 @@ val pp_version : Format.formatter -> unit -> unit val proc_stats_filename : string -val procnames_locks_dir : string - val property_attributes : string val racerd_issues_dir_name : string @@ -251,9 +249,6 @@ val capture : bool val capture_blacklist : string option -val captured_dir : string -(** directory where the results of the capture phase are stored *) - val censor_report : ((bool * Str.regexp) * (bool * Str.regexp) * string) list val changed_files_index : string option @@ -324,8 +319,6 @@ val dotty_cfg_libs : bool val dump_duplicate_symbols : bool -val dynamic_dispatch : bool - val eradicate_condition_redundant : bool val eradicate_field_over_annotated : bool @@ -625,12 +618,6 @@ val threadsafe_aliases : Yojson.Basic.t val topl_properties : string list -val toplevel_results_dir : string -(** In some integrations, eg Buck, infer subprocesses started by the build system (started by the - toplevel infer process) will have their own results directory; this points to the results - directory of the toplevel infer process, which can be useful for, eg, storing debug info. In - other cases this is equal to {!results_dir}. *) - val trace_error : bool val trace_events : bool @@ -666,17 +653,24 @@ val write_html_whitelist_regex : string list val xcode_developer_dir : string option val xcpretty : bool -(** {2 Global variables with initial values specified by command-line options} *) -val temp_file_dir : string +(** {2 Configuration values derived from command-line options} *) -val clang_compilation_dbs : [`Escaped of string | `Raw of string] list ref +val dynamic_dispatch : bool -(** {2 Command Line Interface Documentation} *) +val captured_dir : string +(** directory where the results of the capture phase are stored *) -val print_usage_exit : unit -> 'a +val procnames_locks_dir : string -(** {2 Miscellanous} *) +val temp_dir : string +(** directory inside {!results_dir} to put temporary files *) + +val toplevel_results_dir : string +(** In some integrations, eg Buck, infer subprocesses started by the build system (started by the + toplevel infer process) will have their own results directory; this points to the results + directory of the toplevel infer process, which can be useful for, eg, storing debug info. In + other cases this is equal to {!results_dir}. *) val is_in_custom_symbols : string -> string -> bool (** Does named symbol match any prefix in the named custom symbol list? *) @@ -685,3 +679,11 @@ val java_package_is_external : string -> bool (** Check if a Java package is external to the repository *) val execution_id : Int64.t + +(** {2 Global variables with initial values specified by command-line options} *) + +val clang_compilation_dbs : [`Escaped of string | `Raw of string] list ref + +(** {2 Command Line Interface Documentation} *) + +val print_usage_exit : unit -> 'a diff --git a/infer/src/base/ResultsDir.ml b/infer/src/base/ResultsDir.ml index a53cf6206..332b83684 100644 --- a/infer/src/base/ResultsDir.ml +++ b/infer/src/base/ResultsDir.ml @@ -64,7 +64,7 @@ let create_results_dir () = L.die UserError "ERROR: %s@\nPlease remove '%s' and try again" error Config.results_dir ) ; Unix.mkdir_p Config.results_dir ; - Unix.mkdir_p Config.temp_file_dir ; + Unix.mkdir_p Config.temp_dir ; List.iter ~f:Unix.mkdir_p results_dir_dir_markers ; prepare_logging_and_db () ; () diff --git a/infer/src/integration/Buck.ml b/infer/src/integration/Buck.ml index 57c6d0e85..402e4bbfa 100644 --- a/infer/src/integration/Buck.ml +++ b/infer/src/integration/Buck.ml @@ -325,7 +325,7 @@ let rec exceed_length ~max = function let store_args_in_file args = if exceed_length ~max:max_command_line_length args then ( - let file = Filename.temp_file ~in_dir:Config.temp_file_dir "buck_targets" ".txt" in + let file = Filename.temp_file ~in_dir:Config.temp_dir "buck_targets" ".txt" in let write_args outc = Out_channel.output_string outc (String.concat ~sep:"\n" args) in let () = Utils.with_file_out file ~f:write_args in L.(debug Capture Quiet) "Buck targets options stored in file '%s'@\n" file ; @@ -381,7 +381,7 @@ let capture_buck_args = let run_buck_build prog buck_build_args = L.debug Capture Verbose "%s %s@." prog (List.to_string ~f:Fn.id buck_build_args) ; - let buck_output_file = Filename.temp_file ~in_dir:Config.temp_file_dir "buck_output" ".log" in + let buck_output_file = Filename.temp_file ~in_dir:Config.temp_dir "buck_output" ".log" in let infer_args = Option.fold (Sys.getenv CommandLineOption.args_env_var) ~init:"--fcp-syntax-only" ~f:(fun acc arg -> Printf.sprintf "%s%c%s" acc CommandLineOption.env_var_sep arg) diff --git a/infer/src/integration/BuckGenrule.ml b/infer/src/integration/BuckGenrule.ml index 4787b1088..6287f96b3 100644 --- a/infer/src/integration/BuckGenrule.ml +++ b/infer/src/integration/BuckGenrule.ml @@ -23,7 +23,7 @@ let write_infer_deps infile = let run_buck_capture cmd = - let buck_output_file = Filename.temp_file ~in_dir:Config.temp_file_dir "buck_output" ".log" in + let buck_output_file = Filename.temp_file ~in_dir:Config.temp_dir "buck_output" ".log" in let shell_cmd = List.map ~f:Escape.escape_shell cmd |> String.concat ~sep:" " diff --git a/infer/src/integration/CaptureCompilationDatabase.ml b/infer/src/integration/CaptureCompilationDatabase.ml index 6e974a29f..2dfca678f 100644 --- a/infer/src/integration/CaptureCompilationDatabase.ml +++ b/infer/src/integration/CaptureCompilationDatabase.ml @@ -125,7 +125,7 @@ let get_compilation_database_files_buck db_deps ~prog ~args = (** Compute the compilation database files. *) let get_compilation_database_files_xcodebuild ~prog ~args = - let tmp_file = Filename.temp_file ~in_dir:Config.temp_file_dir "cdb" ".json" in + let tmp_file = Filename.temp_file ~in_dir:Config.temp_dir "cdb" ".json" in let xcodebuild_prog, xcodebuild_args = (prog, prog :: args) in let xcpretty_prog = "xcpretty" in let xcpretty_args = diff --git a/infer/src/integration/ClangQuotes.ml b/infer/src/integration/ClangQuotes.ml index 8f8cf4817..4c0c39c0e 100644 --- a/infer/src/integration/ClangQuotes.ml +++ b/infer/src/integration/ClangQuotes.ml @@ -28,7 +28,7 @@ let quote style = let mk_arg_file prefix style args = - let file = Filename.temp_file prefix ~in_dir:Config.temp_file_dir ".txt" in + let file = Filename.temp_file prefix ~in_dir:Config.temp_dir ".txt" in let write_args outc = List.iter ~f:(fun arg -> diff --git a/infer/src/integration/Gradle.ml b/infer/src/integration/Gradle.ml index 91565eff1..5a1744f3e 100644 --- a/infer/src/integration/Gradle.ml +++ b/infer/src/integration/Gradle.ml @@ -59,7 +59,7 @@ let capture ~prog ~args = else let javac_data = parse_gradle_line ~line:content in let tmpfile, oc = - Core.Filename.open_temp_file ~in_dir:Config.temp_file_dir "gradle_files" "" + Core.Filename.open_temp_file ~in_dir:Config.temp_dir "gradle_files" "" in List.iter javac_data.files ~f:(fun file -> Out_channel.output_string oc (normalize file ^ "\n") ) ; @@ -69,7 +69,7 @@ let capture ~prog ~args = | None -> seen in - let gradle_output_file = Filename.temp_file ~in_dir:Config.temp_file_dir "gradle_output" ".log" in + let gradle_output_file = Filename.temp_file ~in_dir:Config.temp_dir "gradle_output" ".log" in let shell_cmd = List.map ~f:Escape.escape_shell (prog :: "--debug" :: args) |> String.concat ~sep:" " diff --git a/infer/src/integration/Javac.ml b/infer/src/integration/Javac.ml index b8ea12d7e..bc1342adc 100644 --- a/infer/src/integration/Javac.ml +++ b/infer/src/integration/Javac.ml @@ -30,7 +30,7 @@ let compile compiler build_prog build_args = in (* Pass non-special args via a file to avoid exceeding the command line size limit. *) let args_file = - let file = Filename.temp_file ~in_dir:Config.temp_file_dir "javac_args" "" in + let file = Filename.temp_file ~in_dir:Config.temp_dir "javac_args" "" in let quoted_file_args = List.map file_args ~f:(fun arg -> if String.contains arg '\'' then arg else F.sprintf "'%s'" arg ) @@ -41,7 +41,7 @@ let compile compiler build_prog build_args = let cli_file_args = cli_args @ ["@" ^ args_file] in let args = prog_args @ cli_file_args in L.(debug Capture Quiet) "Current working directory: '%s'@." (Sys.getcwd ()) ; - let verbose_out_file = Filename.temp_file ~in_dir:Config.temp_file_dir "javac" ".out" in + let verbose_out_file = Filename.temp_file ~in_dir:Config.temp_dir "javac" ".out" in let try_run cmd error_k = let shell_cmd = List.map ~f:Escape.escape_shell cmd |> String.concat ~sep:" " in let shell_cmd_redirected = Printf.sprintf "%s 2>'%s'" shell_cmd verbose_out_file in