[Config] Warn about deprecated args only from Driver exe

Reviewed By: jvillard

Differential Revision: D4449747

fbshipit-source-id: 9c613f7
master
Andrzej Kotulski 8 years ago committed by Facebook Github Bot
parent 3f8ee7df49
commit cceffddd78

@ -382,7 +382,7 @@ let () =
(* re-set log files, as default files were in results_dir removed above *)
L.set_log_file_identifier Config.current_exe None ;
if Config.print_builtins then Builtin.print_and_exit () ;
if Config.is_originator then L.do_out "%s@\n" Config.version_string ;
if CLOpt.is_originator then L.do_out "%s@\n" Config.version_string ;
if Config.debug_mode || Config.stats_mode then log_infer_args driver_mode ;
(* infer might be called from a Makefile and itself uses `make` to run the analysis in parallel,
but cannot communicate with the parent make command. Since infer won't interfere with them
@ -393,7 +393,7 @@ let () =
touch_start_file () ;
capture driver_mode ;
analyze driver_mode ;
if Config.is_originator then (
if CLOpt.is_originator then (
StatsAggregator.generate_files () ;
let in_buck_mode = match driver_mode with | PythonCapture (BBuck, _) -> true | _ -> false in
if Config.analyzer = Config.Crashcontext then

@ -32,8 +32,6 @@ let to_arg_spec = function
let is_env_var_set v =
Option.value (Option.map (Sys.getenv v) ~f:((=) "1")) ~default:false
let warnf = if is_env_var_set "INFER_STRICT_MODE" then failwithf else F.eprintf
(** Each command line option may appear in the --help list of any executable, these tags are used to
specify which executables for which an option will be documented. *)
type exe = Analyze | Clang | Driver | Interactive | Print
@ -55,6 +53,22 @@ let exe_name =
let frontend_exes = [Clang]
(** The working directory of the initial invocation of infer, to which paths passed as command line
options are relative. *)
let init_work_dir, is_originator =
match Sys.getenv "INFER_CWD" with
| Some dir ->
(dir, false)
| None ->
let real_cwd = Utils.realpath (Sys.getcwd ()) in
Unix.putenv ~key:"INFER_CWD" ~data:real_cwd;
(real_cwd, true)
let warnf =
if is_env_var_set "INFER_STRICT_MODE" then failwithf
else if not is_originator then fun fmt -> F.ifprintf F.err_formatter fmt
else F.eprintf
type desc = {
long: string; short: string; meta: string; doc: string; spec: spec;
(** how to go from an option in the json config file to a list of command-line options *)
@ -226,7 +240,7 @@ let deprecate_desc ~long ~short ~deprecated desc =
| Symbol (symbols, f) -> Symbol (symbols, warn_then_f f)
| Rest _ as spec -> spec in
let deprecated_decode_json j =
F.eprintf "WARNING: in .inferconfig: '%s' is deprecated. Use '%s' instead.@." deprecated long;
warnf "WARNING: in .inferconfig: '%s' is deprecated. Use '%s' instead.@." deprecated long;
desc.decode_json j in
{ long = ""; short = deprecated; meta = ""; doc = "";
spec = deprecated_spec; decode_json = deprecated_decode_json }
@ -663,15 +677,12 @@ let parse ?(incomplete=false) ?(accept_unknown=false) ?config_file current_exe e
current exe *)
(* reset the speclist between calls to this function *)
curr_speclist := [];
if current_exe = Driver then
add_to_curr_speclist ~add_help:true ~header:"Driver options" current_exe
else
add_to_curr_speclist ~add_help:true current_exe
;
if current_exe = Driver then (
add_to_curr_speclist ~add_help:true ~header:"Driver options" current_exe;
add_to_curr_speclist ~header:"Analysis (backend) options" Analyze;
add_to_curr_speclist ~header:"Clang frontend options" Clang;
)
add_to_curr_speclist ~header:"Clang frontend options" Clang
) else
add_to_curr_speclist ~add_help:true current_exe
;
assert( check_no_duplicates !curr_speclist )
;

@ -20,6 +20,10 @@ val exe_name : exe -> string
val frontend_exes: exe list
val is_originator : bool
val init_work_dir : string
(** The [mk_*] functions declare command line options, while [parse] parses then according to the
declared options.

@ -292,20 +292,9 @@ let os_type = match Sys.os_type with
| _ -> Unix
(** The working directory of the initial invocation of infer, to which paths passed as command line
options are relative. *)
let init_work_dir, is_originator =
match Sys.getenv "INFER_CWD" with
| Some dir ->
(dir, false)
| None ->
let real_cwd = Utils.realpath (Sys.getcwd ()) in
Unix.putenv ~key:"INFER_CWD" ~data:real_cwd;
(real_cwd, true)
(** Resolve relative paths passed as command line options, i.e., with respect to the working
directory of the initial invocation of infer. *)
let resolve = Utils.filename_to_absolute ~root:init_work_dir
let resolve = Utils.filename_to_absolute ~root:CLOpt.init_work_dir
let infer_inside_maven_env_var = "INFER_INSIDE_MAVEN"
@ -331,7 +320,7 @@ let inferconfig_home =
and project_root =
CLOpt.mk_path ~deprecated:["project_root"; "-project_root"] ~long:"project-root" ~short:"pr"
~default:init_work_dir
~default:CLOpt.init_work_dir
~exes:CLOpt.[Analyze;Clang;Driver;Print]
~meta:"dir" "Specify the root directory of the project"
@ -1043,7 +1032,7 @@ and report_hook =
and results_dir =
CLOpt.mk_path ~deprecated:["results_dir"; "-out"] ~long:"results-dir" ~short:"o"
~default:(init_work_dir ^/ "infer-out")
~default:(CLOpt.init_work_dir ^/ "infer-out")
~exes:CLOpt.[Analyze;Clang;Driver;Print]
~meta:"dir" "Write results and internal files in the specified directory"
@ -1229,7 +1218,7 @@ and xml_specs =
CLOpt.mk_bool ~deprecated:["xml"] ~long:"xml-specs"
"Export specs into XML files file1.xml ... filen.xml"
let javac_classes_out = ref init_work_dir
let javac_classes_out = ref CLOpt.init_work_dir
(* The "rest" args must appear after "--" on the command line, and hence after other args, so they
are allowed to refer to the other arg variables. *)

@ -204,9 +204,7 @@ val generated_classes : string option
val headers : bool
val icfg_dotty_outfile : string option
val infer_cache : string option
val init_work_dir : string
val iphoneos_target_sdk_version : string option
val is_originator : bool
val iterations : int
val java_jar_compiler : string option
val javac_classes_out : string

@ -35,7 +35,7 @@ let infer_profile = lazy
\n </profile>\
" infer_profile_name (Config.(bin_dir ^/ string_of_analyzer Infer)))
let pom_worklist = ref [Config.init_work_dir]
let pom_worklist = ref [CLOpt.init_work_dir]
let add_infer_profile_to_xml maven_xml infer_xml =
let copy xml_in xml_out = Xmlm.output xml_out (Xmlm.input xml_in) in
@ -90,7 +90,7 @@ let add_infer_profile_to_xml maven_xml infer_xml =
L.do_out "Found infer profile, not adding one@.";
found_infer_profile := true
| "module"::"modules"::_ ->
let abs_data = Config.init_work_dir ^/ data in
let abs_data = CLOpt.init_work_dir ^/ data in
L.do_out "Adding maven module %s@." abs_data;
pom_worklist := abs_data::!pom_worklist
| _ -> ()

Loading…
Cancel
Save