From 5fae8ca7123477eacd269be81825afcdca8915a3 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Mon, 5 Jun 2017 03:40:41 -0700 Subject: [PATCH] [CLI] deprecate `-a capture/compile` and `-- analyze` Summary: This also allows us to better test that the new commands will keep working. Reviewed By: jeremydubreil Differential Revision: D5172891 fbshipit-source-id: 169bd6f --- infer/lib/python/inferlib/jwlib.py | 2 +- infer/src/backend/infer.ml | 3 +++ infer/src/base/CommandLineOption.ml | 6 +++--- infer/src/base/CommandLineOption.mli | 2 +- infer/src/base/Config.ml | 9 +++++++++ infer/tests/build_systems/clang_translation/Makefile | 2 +- infer/tests/build_systems/cmake/Makefile | 2 +- infer/tests/build_systems/reactive/Makefile | 8 ++++---- infer/tests/build_systems/utf8_in_pwd/Makefile | 2 +- infer/tests/clang-frontend.make | 2 +- 10 files changed, 25 insertions(+), 13 deletions(-) diff --git a/infer/lib/python/inferlib/jwlib.py b/infer/lib/python/inferlib/jwlib.py index 2a6c1ebc1..383ee1a4e 100644 --- a/infer/lib/python/inferlib/jwlib.py +++ b/infer/lib/python/inferlib/jwlib.py @@ -26,7 +26,7 @@ class InferJavacCapture(): # pass --continue to prevent removing the results-dir cmd = [ infer, - '--analyzer', 'capture', + 'capture', '--continue', '--', 'javac' ] + self.javac_args diff --git a/infer/src/backend/infer.ml b/infer/src/backend/infer.ml index dadf7f4d0..bb26c36d1 100644 --- a/infer/src/backend/infer.ml +++ b/infer/src/backend/infer.ml @@ -456,6 +456,9 @@ let driver_mode_of_build_cmd build_cmd = assert_supported_build_system build_system; match build_system_of_exe_name (Filename.basename prog) with | BAnalyze -> + CLOpt.warnf + "WARNING: `infer -- analyze` is deprecated; \ + use the `infer analyze` subcommand instead@."; Analyze | BBuck when Option.is_some Config.buck_compilation_database -> BuckCompilationDB (prog, List.append args (List.rev Config.buck_build_args)) diff --git a/infer/src/base/CommandLineOption.ml b/infer/src/base/CommandLineOption.ml index 92d86df23..93ccd8f96 100644 --- a/infer/src/base/CommandLineOption.ml +++ b/infer/src/base/CommandLineOption.ml @@ -455,13 +455,13 @@ let mk_symbol ~default ~symbols ~eq ?(deprecated=[]) ~long ?short ?parse_mode ?i ~decode_json:(string_json_decoder ~long) ~mk_spec:(fun set -> Symbol (strings, set)) -let mk_symbol_opt ~symbols ?(deprecated=[]) ~long ?short ?parse_mode ?in_help ?meta doc = +let mk_symbol_opt ~symbols ?(f=Fn.id) ?(deprecated=[]) ~long ?short ?parse_mode ?in_help ?meta doc = let strings = List.map ~f:fst symbols in let of_string str = List.Assoc.find_exn ~equal:String.equal symbols str in let meta = Option.value meta ~default:(mk_symbols_meta symbols) in mk ~deprecated ~long ?short ~default:None ?parse_mode ?in_help ~meta doc ~default_to_string:(fun _ -> "") - ~mk_setter:(fun var str -> var := Some (of_string str)) + ~mk_setter:(fun var str -> var := Some (f (of_string str))) ~decode_json:(string_json_decoder ~long) ~mk_spec:(fun set -> Symbol (strings, set)) @@ -705,7 +705,7 @@ let encode_argv_to_env argv = (List.filter ~f:(fun arg -> not (String.contains arg env_var_sep) || ( - warnf "Ignoring unsupported option containing '%c' character: %s@\n" + warnf "WARNING: Ignoring unsupported option containing '%c' character: %s@\n" env_var_sep arg ; false ) diff --git a/infer/src/base/CommandLineOption.mli b/infer/src/base/CommandLineOption.mli index c8975917b..133cd4094 100644 --- a/infer/src/base/CommandLineOption.mli +++ b/infer/src/base/CommandLineOption.mli @@ -120,7 +120,7 @@ val mk_path_list : ?default:string list -> string list ref t val mk_symbol : default:'a -> symbols:(string * 'a) list -> eq:('a -> 'a -> bool) -> 'a ref t (** [mk_symbol_opt] is similar to [mk_symbol] but defaults to [None]. *) -val mk_symbol_opt : symbols:(string * 'a) list -> 'a option ref t +val mk_symbol_opt : symbols:(string * 'a) list -> ?f:('a -> 'a) -> 'a option ref t (** [mk_symbol_seq long symbols] defines a command line flag [--long ] where [] is a comma-separated sequence of []s such that [(,_)] is an diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 314f38029..a34e43a5c 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -498,6 +498,15 @@ and analyzer = - $(b,crashcontext): experimental (see $(b,--crashcontext))\n\ - $(b,linters): run linters based on the ast only (Objective-C and Objective-C++ only, \ activated by default)" + ~f:(function + | CaptureOnly | CompileOnly as x -> + let analyzer_str = List.find_map_exn string_to_analyzer + ~f:(fun (s, y) -> if equal_analyzer x y then Some s else None) in + CLOpt.warnf + "WARNING: The analyzer '%s' is deprecated, use the '%s' subcommand instead:@\n\ + @\n infer %s ..." analyzer_str analyzer_str analyzer_str; + x + | _ as x -> x) ~symbols:string_to_analyzer and android_harness = diff --git a/infer/tests/build_systems/clang_translation/Makefile b/infer/tests/build_systems/clang_translation/Makefile index 3d25a7961..7983c3393 100644 --- a/infer/tests/build_systems/clang_translation/Makefile +++ b/infer/tests/build_systems/clang_translation/Makefile @@ -24,7 +24,7 @@ CLEAN_EXTRA = $(DOT_FILES) $(foreach source,$(SOURCES),infer-out-$(basename $(no include $(TESTS_DIR)/clang-frontend.make -INFER_OPTIONS = -a capture --frontend-tests --skip-translation-headers exclude_dir --no-failures-allowed +INFER_OPTIONS = capture --frontend-tests --skip-translation-headers exclude_dir --no-failures-allowed capture: $(DOT_FILES) diff --git a/infer/tests/build_systems/cmake/Makefile b/infer/tests/build_systems/cmake/Makefile index f844c9c32..cd9f8d06c 100644 --- a/infer/tests/build_systems/cmake/Makefile +++ b/infer/tests/build_systems/cmake/Makefile @@ -35,7 +35,7 @@ infer-out/report.json: $(SOURCES) $(CMAKE_DIR)/CMakeLists.txt $(CLANG_DEPS) $(QUIET)$(MKDIR_P) $(CMAKE_ANALYZE_DIR) $(QUIET)cd $(CMAKE_ANALYZE_DIR) && \ $(call silent_on_success,Testing CMake integration: Generate Makefiles,\ - $(INFER_BIN) -a compile $(INFER_OPTIONS) -- cmake ..) + $(INFER_BIN) compile $(INFER_OPTIONS) -- cmake ..) $(QUIET)$(call silent_on_success,Testing CMake integration: Run Makefiles,\ $(INFER_BIN) -a $(ANALYZER) $(INFER_OPTIONS) -- $(MAKE) -C $(CMAKE_ANALYZE_DIR)) # cmake makes all paths absolute diff --git a/infer/tests/build_systems/reactive/Makefile b/infer/tests/build_systems/reactive/Makefile index ca1a32470..83e32cc4b 100644 --- a/infer/tests/build_systems/reactive/Makefile +++ b/infer/tests/build_systems/reactive/Makefile @@ -22,14 +22,14 @@ include $(TESTS_DIR)/clang.make infer-out/report.json: $(CLANG_DEPS) $(SOURCES) $(HEADERS) $(QUIET)$(call silent_on_success,Testing reactive mode: capture 1/3,\ - $(INFER_BIN) $(INFER_OPTIONS) -a capture -- \ + $(INFER_BIN) $(INFER_OPTIONS) capture -- \ clang $(CLANG_OPTIONS) $(SOURCES1)) $(QUIET)$(call silent_on_success,Testing reactive mode: capture 2/3,\ - $(INFER_BIN) $(INFER_OPTIONS) -a capture --reactive --continue -- \ + $(INFER_BIN) $(INFER_OPTIONS) capture --reactive --continue -- \ clang $(CLANG_OPTIONS) $(SOURCES2)) $(QUIET)$(call silent_on_success,Testing reactive mode: capture 3/3,\ - $(INFER_BIN) $(INFER_OPTIONS) -a capture --reactive --continue -- \ + $(INFER_BIN) $(INFER_OPTIONS) capture --reactive --continue -- \ clang $(CLANG_OPTIONS) $(SOURCES3)) $(QUIET)$(call silent_on_success,Testing reactive mode: analysis,\ - $(INFER_BIN) --dump-duplicate-symbols $(INFER_OPTIONS) -a $(ANALYZER) -- analyze) + $(INFER_BIN) analyze --dump-duplicate-symbols $(INFER_OPTIONS) -a $(ANALYZER)) $(QUIET)$(call check_no_duplicates,infer-out/duplicates.txt) diff --git a/infer/tests/build_systems/utf8_in_pwd/Makefile b/infer/tests/build_systems/utf8_in_pwd/Makefile index 05e08f890..35253c64e 100644 --- a/infer/tests/build_systems/utf8_in_pwd/Makefile +++ b/infer/tests/build_systems/utf8_in_pwd/Makefile @@ -65,7 +65,7 @@ infer-out-cmake/report.json: $(CMAKE_DIR) $(CMAKE_SOURCES_DIR)/CMakeLists.txt $( $(QUIET)cd $(CMAKE_ANALYZE_DIR) && \ $(call silent_on_success,Testing\ Infer/CMake is immune to UTF-8 in PWD: Makefile generation,\ - $(INFER_BIN) -a compile --project-root $(CMAKE_DIR) --results-dir $(CURDIR)/$(@D) -- cmake ..) + $(INFER_BIN) compile --project-root $(CMAKE_DIR) --results-dir $(CURDIR)/$(@D) -- cmake ..) $(QUIET)cd $(CMAKE_ANALYZE_DIR) && \ $(call silent_on_success,Testing\ Infer/CMake is immune to UTF-8 in PWD: Makefile execution,\ diff --git a/infer/tests/clang-frontend.make b/infer/tests/clang-frontend.make index c28ffe4f6..6f9831340 100644 --- a/infer/tests/clang-frontend.make +++ b/infer/tests/clang-frontend.make @@ -18,7 +18,7 @@ compile: $(OBJECTS) $(ONE_SOURCE).test.dot: $(CLANG_DEPS) $(SOURCES) $(HEADERS) $(QUIET)$(call silent_on_success,Testing the infer/clang frontend in $(TEST_REL_DIR),\ - $(INFER_BIN) -a capture --frontend-tests --project-root $(TESTS_DIR) $(INFER_OPTIONS) -- \ + $(INFER_BIN) capture --frontend-tests --project-root $(TESTS_DIR) $(INFER_OPTIONS) -- \ clang $(CLANG_OPTIONS) $(SOURCES)) .PHONY: capture