Skip to content

Commit

Permalink
[java][buck2/bxl] java buck2/bxl integration
Browse files Browse the repository at this point in the history
Summary:
New integration for buck2/java that relies on an external BXL script for capture.

The previous buck2/java integration is removed.

Reviewed By: martintrojer

Differential Revision: D50740886

fbshipit-source-id: 56044566da5126582f8f52d275f545df9dfd8fd8
  • Loading branch information
ngorogiannis authored and facebook-github-bot committed Oct 30, 2023
1 parent d1af775 commit f4bc5cd
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 67 deletions.
4 changes: 4 additions & 0 deletions infer/man/man1/infer-capture.txt
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ BUCK OPTIONS
Buck2 BXL script (as a buck target) to run when capturing with
buck2/clang integration.

--buck2-inferconfig-target string
Buck2 target representing the inferconfig file; used in BXL
capture.

--buck2-isolation-dir string
Run buck bxl capture with the given isolation directory as
parameter.
Expand Down
7 changes: 7 additions & 0 deletions infer/man/man1/infer-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ OPTIONS
Buck2 BXL script (as a buck target) to run when capturing with
buck2/clang integration. See also infer-capture(1).

--buck2-inferconfig-target string
Buck2 target representing the inferconfig file; used in BXL
capture. See also infer-capture(1).

--buck2-isolation-dir string
Run buck bxl capture with the given isolation directory as
parameter. See also infer-capture(1).
Expand Down Expand Up @@ -2124,6 +2128,9 @@ INTERNAL OPTIONS
--buck2-bxl-target-reset
Cancel the effect of --buck2-bxl-target.

--buck2-inferconfig-target-reset
Cancel the effect of --buck2-inferconfig-target.

--buck2-isolation-dir-reset
Cancel the effect of --buck2-isolation-dir.

Expand Down
4 changes: 4 additions & 0 deletions infer/man/man1/infer.txt
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ OPTIONS
Buck2 BXL script (as a buck target) to run when capturing with
buck2/clang integration. See also infer-capture(1).

--buck2-inferconfig-target string
Buck2 target representing the inferconfig file; used in BXL
capture. See also infer-capture(1).

--buck2-isolation-dir string
Run buck bxl capture with the given isolation directory as
parameter. See also infer-capture(1).
Expand Down
8 changes: 8 additions & 0 deletions infer/src/base/Config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,12 @@ and buck2_bxl_target =
"Buck2 BXL script (as a buck target) to run when capturing with buck2/clang integration."


and buck2_inferconfig_target =
CLOpt.mk_string_opt ~long:"buck2-inferconfig-target"
~in_help:InferCommand.[(Capture, manual_buck)]
"Buck2 target representing the inferconfig file; used in BXL capture."


and buck2_isolation_dir =
CLOpt.mk_string_opt ~long:"buck2-isolation-dir" ~deprecated:["-bxl-isolation-dir"]
~in_help:InferCommand.[(Capture, manual_buck)]
Expand Down Expand Up @@ -3751,6 +3757,8 @@ and buck2_build_args_no_inline = RevList.to_list !buck2_build_args_no_inline_rev

and buck2_bxl_target = !buck2_bxl_target

and buck2_inferconfig_target = !buck2_inferconfig_target

and buck2_isolation_dir = !buck2_isolation_dir

and buck2_use_bxl = !buck2_use_bxl
Expand Down
2 changes: 2 additions & 0 deletions infer/src/base/Config.mli
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ val buck2_build_args_no_inline : string list

val buck2_bxl_target : string option

val buck2_inferconfig_target : string option

val buck2_isolation_dir : string option

val buck2_query_deps : bool
Expand Down
40 changes: 0 additions & 40 deletions infer/src/integration/Buck2Java.ml

This file was deleted.

11 changes: 0 additions & 11 deletions infer/src/integration/Buck2Java.mli

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@ let capture build_cmd =
["--"]
@ Option.value_map Config.buck_dependency_depth ~default:[] ~f:(fun depth ->
["--depth"; Int.to_string depth] )
@ Option.value_map Config.buck2_inferconfig_target ~default:[] ~f:(fun target ->
["--inferconfig"; target] )
@ targets_with_arg
in
let buck2_build_cmd =
["bxl"; bxl_target; "--console=simple"]
@ List.rev rev_not_targets @ Config.buck2_build_args_no_inline
@ Buck.store_args_in_file ~identifier:"clang_buck2_bxl" args_to_store
@ Buck.store_args_in_file ~identifier:"buck2_bxl" args_to_store
in
run_capture buck2_build_cmd

Expand Down
File renamed without changes.
28 changes: 14 additions & 14 deletions infer/src/integration/Driver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ type mode =
| Analyze
| Ant of {prog: string; args: string list}
| Buck2Clang of {build_cmd: string list}
| Buck2Java of {build_cmd: string list}
| BuckClangFlavor of {build_cmd: string list}
| BuckCompilationDB of {deps: BuckMode.clang_compilation_db_deps; prog: string; args: string list}
| BuckErlang of {prog: string; args: string list}
| BuckGenrule of {prog: string}
| BuckJavaFlavor of {build_cmd: string list}
| BxlClang of {build_cmd: string list}
| BxlClangFile
| BxlJava of {build_cmd: string list}
| Clang of {compiler: Clang.compiler; prog: string; args: string list}
| ClangCompilationDB of {db_files: [`Escaped of string | `Raw of string] list}
| Gradle of {prog: string; args: string list}
Expand Down Expand Up @@ -57,8 +57,6 @@ let pp_mode fmt = function
F.fprintf fmt "Ant driver mode:@\nprog = '%s'@\nargs = %a" prog Pp.cli_args args
| Buck2Clang {build_cmd} ->
F.fprintf fmt "Buck2/Clang driver mode: build_cmd = %a" Pp.cli_args build_cmd
| Buck2Java {build_cmd} ->
F.fprintf fmt "Buck2/Java driver mode: build_cmd = %a" Pp.cli_args build_cmd
| BuckClangFlavor {build_cmd} ->
F.fprintf fmt "BuckClangFlavor driver mode: build_cmd = %a" Pp.cli_args build_cmd
| BuckCompilationDB {deps; prog; args} ->
Expand All @@ -74,6 +72,8 @@ let pp_mode fmt = function
F.fprintf fmt "BxlClang driver mode:@\nbuild command = %a" Pp.cli_args build_cmd
| BxlClangFile ->
F.fprintf fmt "BxlClang file driver mode"
| BxlJava {build_cmd} ->
F.fprintf fmt "BxlJava driver mode:@\nbuild command = %a" Pp.cli_args build_cmd
| Clang {prog; args} ->
F.fprintf fmt "Clang driver mode:@\nprog = '%s'@\nargs = %a" prog Pp.cli_args args
| ClangCompilationDB _ ->
Expand Down Expand Up @@ -161,9 +161,6 @@ let capture ~changed_files mode =
| Buck2Clang {build_cmd} ->
L.progress "Capturing in buck2/clang mode...@." ;
Buck2Clang.capture build_cmd
| Buck2Java {build_cmd} ->
L.progress "Capturing in buck2/java mode...@." ;
Buck2Java.capture build_cmd
| BuckClangFlavor {build_cmd} ->
L.progress "Capturing in buck mode...@." ;
BuckFlavors.capture build_cmd
Expand All @@ -184,10 +181,13 @@ let capture ~changed_files mode =
BuckJavaFlavor.capture build_cmd
| BxlClang {build_cmd} ->
L.progress "Capturing in bxl/clang mode...@." ;
BxlClang.capture build_cmd
BxlCapture.capture build_cmd
| BxlClangFile ->
L.progress "Capturing in bxl/clang file mode...@." ;
BxlClang.file_capture ()
BxlCapture.file_capture ()
| BxlJava {build_cmd} ->
L.progress "Capturing in bxl/java mode...@." ;
BxlCapture.capture build_cmd
| Clang {compiler; prog; args} ->
if Config.is_originator then L.progress "Capturing in make/cc mode...@." ;
Clang.capture compiler ~prog ~args
Expand Down Expand Up @@ -243,11 +243,11 @@ let capture ~changed_files mode =
let should_merge =
match mode with
| Buck2Clang _
| Buck2Java _
| BuckClangFlavor _
| BuckJavaFlavor _
| BxlClang _
| BxlClangFile
| BxlJava _
| Gradle _ ->
true
| _ ->
Expand All @@ -257,7 +257,7 @@ let capture ~changed_files mode =
if Config.export_changed_functions then MergeCapture.merge_changed_functions () ;
let root =
match mode with
| Buck2Clang _ | BxlClang _ | BxlClangFile ->
| Buck2Clang _ | BxlClang _ | BxlClangFile | BxlJava _ ->
Config.buck2_root
| _ ->
Config.project_root
Expand Down Expand Up @@ -537,14 +537,14 @@ let mode_of_build_command build_cmd (buck_mode : BuckMode.t option) =
match buck_mode with
| None ->
error_no_buck_mode_specified ()
| Some Erlang ->
BuckErlang {prog; args}
| Some Clang when Config.buck2_use_bxl ->
BxlClang {build_cmd}
| Some Clang ->
Buck2Clang {build_cmd}
| Some Java ->
Buck2Java {build_cmd}
| Some Erlang ->
BuckErlang {prog; args}
| Some Java when Config.buck2_use_bxl ->
BxlJava {build_cmd}
| Some buck_mode ->
L.die UserError "%a is not supported with buck2.@." BuckMode.pp buck_mode )
| BClang ->
Expand Down
2 changes: 1 addition & 1 deletion infer/src/integration/Driver.mli
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ type mode =
| Analyze
| Ant of {prog: string; args: string list}
| Buck2Clang of {build_cmd: string list}
| Buck2Java of {build_cmd: string list}
| BuckClangFlavor of {build_cmd: string list}
| BuckCompilationDB of {deps: BuckMode.clang_compilation_db_deps; prog: string; args: string list}
| BuckErlang of {prog: string; args: string list}
| BuckGenrule of {prog: string}
| BuckJavaFlavor of {build_cmd: string list}
| BxlClang of {build_cmd: string list}
| BxlClangFile
| BxlJava of {build_cmd: string list}
| Clang of {compiler: Clang.compiler; prog: string; args: string list}
| ClangCompilationDB of {db_files: [`Escaped of string | `Raw of string] list}
| Gradle of {prog: string; args: string list}
Expand Down

0 comments on commit f4bc5cd

Please sign in to comment.