Skip to content

Commit

Permalink
[buck2][bxl] allow setting isolation dir
Browse files Browse the repository at this point in the history
Summary:
Buck/bxl can run in an "isolation directory" meaning that several daemons can hold internal state with different configurations. Essentially, using different isolation directories allows not invalidating the daemon's internal state if using a fixed set of configurations, one per isolation directory.

We cannot use existing `Xbuck*` options because the isolation directory has to go before the buck subcommand, eg `buck --isolation-dir=x build foo`.

Reviewed By: martintrojer

Differential Revision:
D50268051

Privacy Context Container: L1122176

fbshipit-source-id: 28ec6ea707c95efd2a7d4b7eeb6ffea976bdc7ae
  • Loading branch information
ngorogiannis authored and facebook-github-bot committed Oct 16, 2023
1 parent 95db034 commit f1b1b70
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 2 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 @@ -237,6 +237,10 @@ BUCK OPTIONS
specified by --buck2_bxl_target. (Conversely:
--no-bxl-file-capture)

--bxl-isolation-dir string
Run buck bxl capture with the given isolation directory as
parameter.

--Xbuck +string
Pass values as command-line arguments to invocations of `buck
build`. Only valid for --buck-clang.
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 @@ -260,6 +260,10 @@ OPTIONS
specified by --buck2_bxl_target. (Conversely:
--no-bxl-file-capture) See also infer-capture(1).

--bxl-isolation-dir string
Run buck bxl capture with the given isolation directory as
parameter. See also infer-capture(1).

--capture-block-list json
Matcher or list of matchers for names of files that should not be
captured, hence not analyzed either. Clang and Java only.
Expand Down Expand Up @@ -2105,6 +2109,9 @@ INTERNAL OPTIONS
--buck2-root-reset
Cancel the effect of --buck2-root.

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

--no-capture
Deactivates: capture and translate source files into infer's
intermediate language for analysis (Conversely: --capture)
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 @@ -260,6 +260,10 @@ OPTIONS
specified by --buck2_bxl_target. (Conversely:
--no-bxl-file-capture) See also infer-capture(1).

--bxl-isolation-dir string
Run buck bxl capture with the given isolation directory as
parameter. See also infer-capture(1).

--capture-block-list json
Matcher or list of matchers for names of files that should not be
captured, hence not analyzed either. Clang and Java only.
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 @@ -984,6 +984,12 @@ and bxl_file_capture =
dependencies using the BXL script specified by $(b, --buck2_bxl_target)."


and bxl_isolation_dir =
CLOpt.mk_string_opt ~long:"bxl-isolation-dir"
~in_help:InferCommand.[(Capture, manual_buck)]
"Run buck bxl capture with the given isolation directory as parameter."


and capture =
CLOpt.mk_bool ~long:"capture" ~default:true
"capture and translate source files into infer's intermediate language for analysis"
Expand Down Expand Up @@ -3758,6 +3764,8 @@ and buck_targets_block_list = RevList.to_list !buck_targets_block_list

and bxl_file_capture = !bxl_file_capture

and bxl_isolation_dir = !bxl_isolation_dir

and capture = !capture

and capture_block_list = match capture_block_list with k, r -> (k, !r)
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 @@ -218,6 +218,8 @@ val buck_clang_use_toolchain_config : bool

val buck_dependency_depth : int option

val bxl_isolation_dir : string option

val buck_java_suppress_config : bool

val buck_java_heap_size_gb : int option
Expand Down
8 changes: 6 additions & 2 deletions infer/src/integration/BxlClang.ml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ let capture build_cmd =
@ targets_with_arg
in
let buck2_build_cmd =
["bxl"; bxl_target; "--console=simple"]
Option.value_map Config.bxl_isolation_dir ~default:[] ~f:(fun dir ->
["--isolation-dir=" ^ dir] )
@ ["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
in
Expand Down Expand Up @@ -115,7 +117,9 @@ let file_capture () =
@ files_with_arg
in
let buck2_build_cmd =
["bxl"; bxl_target] @ Config.buck2_build_args @ Config.buck2_build_args_no_inline
Option.value_map Config.bxl_isolation_dir ~default:[] ~f:(fun dir ->
["--isolation-dir=" ^ dir] )
@ ["bxl"; bxl_target] @ Config.buck2_build_args @ Config.buck2_build_args_no_inline
@ Buck.store_args_in_file ~identifier:"clang_buck2_bxl_file" args_to_store
in
run_capture buck2_build_cmd

0 comments on commit f1b1b70

Please sign in to comment.