From 4b4183b4028c900d0c0997e1a2e8f531a3c31ef9 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Tue, 14 Jan 2020 08:22:13 -0800 Subject: [PATCH] [buck] stop supporting the pre-genrule Java integration Summary: You should use `--buck-java` instead, which uses the new "genrule master" integration. This diff makes it impossible to select the previous integration. Upcoming diffs will clean up the resulting dead code. This also make infer fail hard when no buck mode is specified in a buck capture command, eg `infer -- buck build //foo:foo`. The reason is that we need to choose between 3 incompatible integrations and making any of them the default will confuse at least one person in the future. Reviewed By: ngorogiannis Differential Revision: D19176391 fbshipit-source-id: 707d18b50 --- infer/man/man1/infer-capture.txt | 5 ++--- infer/man/man1/infer-full.txt | 10 ++-------- infer/man/man1/infer.txt | 5 ++--- infer/src/base/Config.ml | 26 ++++++++++++-------------- infer/src/integration/Driver.ml | 13 +++++++++++-- 5 files changed, 29 insertions(+), 30 deletions(-) diff --git a/infer/man/man1/infer-capture.txt b/infer/man/man1/infer-capture.txt index 9a42dbb39..25740983e 100644 --- a/infer/man/man1/infer-capture.txt +++ b/infer/man/man1/infer-capture.txt @@ -130,9 +130,8 @@ BUCK OPTIONS option. By default, all recursive dependencies are captured. --buck-java - Activates: Make the master Infer process merge capture artefacts - generated by the genrule integration, and report after analysis. - (Conversely: --no-buck-java) + Activates: Buck integration for Java targets. (Conversely: + --no-buck-java) --buck-merge-all-deps Activates: Find and merge all infer dependencies produced by buck. diff --git a/infer/man/man1/infer-full.txt b/infer/man/man1/infer-full.txt index 7f2003fea..6a177cf29 100644 --- a/infer/man/man1/infer-full.txt +++ b/infer/man/man1/infer-full.txt @@ -153,9 +153,8 @@ OPTIONS See also infer-capture(1). --buck-java - Activates: Make the master Infer process merge capture artefacts - generated by the genrule integration, and report after analysis. - (Conversely: --no-buck-java) See also infer-capture(1). + Activates: Buck integration for Java targets. (Conversely: + --no-buck-java) See also infer-capture(1). --buck-merge-all-deps Activates: Find and merge all infer dependencies produced by buck. @@ -1211,11 +1210,6 @@ INTERNAL OPTIONS --buck-compilation-database-reset Cancel the effect of --buck-compilation-database. - --buck-java-deprecated - Activates: [DO NOT USE] old Buck Java integration. Used to be the - default. Going away imminently (Conversely: - --no-buck-java-deprecated) - --buck-out-reset Cancel the effect of --buck-out. diff --git a/infer/man/man1/infer.txt b/infer/man/man1/infer.txt index 760412a1f..1a451e050 100644 --- a/infer/man/man1/infer.txt +++ b/infer/man/man1/infer.txt @@ -153,9 +153,8 @@ OPTIONS See also infer-capture(1). --buck-java - Activates: Make the master Infer process merge capture artefacts - generated by the genrule integration, and report after analysis. - (Conversely: --no-buck-java) See also infer-capture(1). + Activates: Buck integration for Java targets. (Conversely: + --no-buck-java) See also infer-capture(1). --buck-merge-all-deps Activates: Find and merge all infer dependencies produced by buck. diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 22a1110a2..014ef87e1 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -894,22 +894,27 @@ and buck_merge_all_deps = and buck_mode = let buck_mode = ref `None in let set_mode mode b = - if b then buck_mode := mode - else (* TODO: change to [`None] when we kill [`JavaDeprecated] *) buck_mode := `JavaDeprecated ; + if b then buck_mode := mode else buck_mode := `None ; b in CLOpt.mk_bool ~deprecated:["-flavors"; "-use-flavors"] ~long:"buck-clang" - ~deprecated_no:["-no-flavors"] ~in_help:InferCommand.[(Capture, manual_buck)] ~f:(set_mode `ClangFlavors) "Buck integration for clang-based targets (C/C++/Objective-C/Objective-C++)." |> ignore ; - CLOpt.mk_bool ~long:"buck-java" ~deprecated:["-genrule-master-mode"] - ~deprecated_no:["-no-genrule-master-mode"] + CLOpt.mk_bool ~long:"buck-java" + ~deprecated: + [ "-genrule-master-mode" + ; "-no-genrule-master-mode" + (* --no-genrule-master-mode was used in the past to enable a now-defunct Java integration, + so both --genrule-master-mode and --no-genrule-master-mode enable the Java + integration... sorry about that. *) + ; "-no-flavors" + (* --no-flavors was used in the past to enable the Java integration in some cases, let's + keep it that way for compatibility for now *) ] ~in_help:InferCommand.[(Capture, manual_buck)] ~f:(set_mode `Java) - "Make the master Infer process merge capture artefacts generated by the genrule integration, \ - and report after analysis." + "Buck integration for Java targets." |> ignore ; CLOpt.mk_symbol_opt ~long:"buck-compilation-database" ~deprecated:["-use-compilation-database"] ~in_help:InferCommand.[(Capture, manual_buck)] @@ -920,11 +925,6 @@ and buck_mode = clang targets, as per Buck's $(i,#compilation-database) flavor." ~symbols:[("no-deps", `NoDeps); ("deps", `DepsTmp)] |> ignore ; - (* TOOD: kill this *) - CLOpt.mk_bool ~long:"buck-java-deprecated" - ~f:(set_mode `JavaDeprecated) - "[DO NOT USE] old Buck Java integration. Used to be the default. Going away imminently" - |> ignore ; buck_mode @@ -2792,8 +2792,6 @@ and buck_mode : BuckMode.t option = Some (ClangCompilationDB DepsAllDepths) | `ClangCompilationDB `DepsTmp, Some depth -> Some (ClangCompilationDB (DepsUpToDepth depth)) - | `JavaDeprecated, _ -> - None and buck_out = !buck_out diff --git a/infer/src/integration/Driver.ml b/infer/src/integration/Driver.ml index 15b8d48b8..848a59ada 100644 --- a/infer/src/integration/Driver.ml +++ b/infer/src/integration/Driver.ml @@ -482,6 +482,13 @@ let assert_supported_mode required_analyzer requested_mode_string = requested_mode_string analyzer_string analyzer_string +let error_no_buck_mode_specified () = + L.die UserError + "`buck` command detected on the command line but no Buck integration has been selected. Please \ + specify `--buck-clang`, `--buck-java`, or `--buck-compilation-database`. See `infer capture \ + --help` for more information." + + let assert_supported_build_system build_system = match (build_system : Config.build_system) with | BAnt | BGradle | BJava | BJavac | BMvn -> @@ -494,7 +501,7 @@ let assert_supported_build_system build_system = let analyzer, build_string = match Config.buck_mode with | None -> - (`Java, "buck default java integration") + error_no_buck_mode_specified () | Some ClangFlavors -> (`Clang, "buck with flavors") | Some (ClangCompilationDB _) -> @@ -522,6 +529,8 @@ let mode_of_build_command build_cmd (buck_mode : BuckMode.t option) = in assert_supported_build_system build_system ; match ((build_system : Config.build_system), buck_mode) with + | BBuck, None -> + error_no_buck_mode_specified () | BBuck, Some (ClangCompilationDB deps) -> BuckCompilationDB (deps, prog, List.append args (List.rev Config.buck_build_args)) | BBuck, Some ClangFlavors when Config.linters -> @@ -543,7 +552,7 @@ let mode_of_build_command build_cmd (buck_mode : BuckMode.t option) = Maven (prog, args) | BXcode, _ when Config.xcpretty -> XcodeXcpretty (prog, args) - | (BBuck as build_system), (None | Some ClangFlavors) + | (BBuck as build_system), Some ClangFlavors | ((BAnt | BGradle | BNdk | BXcode) as build_system), _ -> PythonCapture (build_system, build_cmd) )