[buck] introduce --buck-targets-blacklist so fbcode can exclude targets incompatible with C++ modules

Reviewed By: jvillard

Differential Revision: D14651180

fbshipit-source-id: 4d715a1a9
master
David Lively 6 years ago committed by Facebook Github Bot
parent 79dbb950c1
commit 757460ade7

@ -109,6 +109,10 @@ BUCK COMPILATION DATABASE OPTIONS
--buck-compilation-database-depth int
Depth of dependencies used by the --buck-compilation-database deps
option. By default, all recursive dependencies are captured.
--buck-targets-blacklist +regex
Skip capture of buck targets matched by the specified regular
expression.
BUCK FLAVORS OPTIONS
--append-buck-flavors +string
Additional Buck flavors to append to targets discovered by the

@ -116,6 +116,10 @@ OPTIONS
--buck-out dir
Specify the root directory of buck-out See also infer-capture(1).
--buck-targets-blacklist +regex
Skip capture of buck targets matched by the specified regular
expression. See also infer-capture(1) and infer-run(1).
--bufferoverrun
Activates: the buffer overrun analysis (Conversely:
--no-bufferoverrun) See also infer-analyze(1).
@ -976,6 +980,9 @@ INTERNAL OPTIONS
--buck-out-reset
Cancel the effect of --buck-out.
--buck-targets-blacklist-reset
Set --buck-targets-blacklist to the empty list.
--no-capture
Deactivates: capture and translate source files into infer's
intermediate language for analysis (Conversely: --capture)

@ -158,6 +158,10 @@ OPTIONS
-- Stop argument processing, use remaining arguments as a build
command
BUCK COMPILATION DATABASE OPTIONS
--buck-targets-blacklist +regex
Skip capture of buck targets matched by the specified regular
expression.
BUCK FLAVORS OPTIONS
--buck-blacklist +regex
Skip capture of files matched by the specified regular expression

@ -116,6 +116,10 @@ OPTIONS
--buck-out dir
Specify the root directory of buck-out See also infer-capture(1).
--buck-targets-blacklist +regex
Skip capture of buck targets matched by the specified regular
expression. See also infer-capture(1) and infer-run(1).
--bufferoverrun
Activates: the buffer overrun analysis (Conversely:
--no-bufferoverrun) See also infer-analyze(1).

@ -828,6 +828,13 @@ and buck_out =
~meta:"dir" "Specify the root directory of buck-out"
and buck_targets_blacklist =
CLOpt.mk_string_list ~long:"buck-targets-blacklist"
~in_help:
InferCommand.[(Run, manual_buck_compilation_db); (Capture, manual_buck_compilation_db)]
~meta:"regex" "Skip capture of buck targets matched by the specified regular expression."
and capture =
CLOpt.mk_bool ~long:"capture" ~default:true
"capture and translate source files into infer's intermediate language for analysis"
@ -2548,6 +2555,8 @@ and buck_compilation_database =
and buck_out = !buck_out
and buck_targets_blacklist = !buck_targets_blacklist
and bufferoverrun = !bufferoverrun
and capture =

@ -253,6 +253,8 @@ val buck_compilation_database : compilation_database_dependencies option
val buck_out : string option
val buck_targets_blacklist : string list
val bufferoverrun : bool
val capture : bool

@ -214,6 +214,12 @@ type flavored_arguments = {command: string; rev_not_targets: string list; target
let add_flavors_to_buck_arguments ~filter_kind ~dep_depth ~extra_flavors original_buck_args =
let expanded_buck_args = inline_argument_files original_buck_args in
let command, args = split_buck_command expanded_buck_args in
let buck_targets_blacklist_regexp =
if List.is_empty Config.buck_targets_blacklist then None
else
Some
(Str.regexp ("\\(" ^ String.concat ~sep:"\\)\\|\\(" Config.buck_targets_blacklist ^ "\\)"))
in
let rec parse_cmd_args parsed_args = function
| [] ->
parsed_args
@ -247,6 +253,11 @@ let add_flavors_to_buck_arguments ~filter_kind ~dep_depth ~extra_flavors origina
pattern_targets |> List.rev_append alias_targets |> List.rev_append normal_targets
|> resolve_pattern_targets ~filter_kind ~dep_depth
in
let targets =
Option.value_map ~default:targets
~f:(fun re -> List.filter ~f:(fun tgt -> not (Str.string_match re tgt 0)) targets)
buck_targets_blacklist_regexp
in
match targets with
| [] ->
L.(die UserError)

Loading…
Cancel
Save