[buck] Automatically filter target kinds on target patterns and aliases

Summary:
Target patterns/aliases rarely contain only targets supporting infer flavor, so it makes sense to automatically filter kinds with handle in those cases.
No need for `$(buck query ...)` anymore in your infer commands!

Reviewed By: dulmarod

Differential Revision: D6335463

fbshipit-source-id: 16c8b70
master
Mehdi Bouaziz 7 years ago committed by Facebook Github Bot
parent 262bb4171d
commit cdd3208cd6

@ -228,11 +228,12 @@ let add_flavors_to_buck_arguments ~filter_kind ~dep_depth ~extra_flavors origina
let parsed_args = parse_cmd_args empty_parsed_args args in let parsed_args = parse_cmd_args empty_parsed_args args in
let targets = let targets =
match (filter_kind, dep_depth, parsed_args) with match (filter_kind, dep_depth, parsed_args) with
| false, None, {pattern_targets= []; alias_targets= []; normal_targets} -> | (`No | `Auto), None, {pattern_targets= []; alias_targets= []; normal_targets} ->
normal_targets normal_targets
| false, None, {pattern_targets= []; alias_targets; normal_targets} -> | `No, None, {pattern_targets= []; alias_targets; normal_targets} ->
alias_targets |> resolve_alias_targets |> List.rev_append normal_targets alias_targets |> resolve_alias_targets |> List.rev_append normal_targets
| _, _, {pattern_targets; alias_targets; normal_targets} -> | (`Yes | `No | `Auto), _, {pattern_targets; alias_targets; normal_targets} ->
let filter_kind = match filter_kind with `No -> false | `Yes | `Auto -> true in
pattern_targets |> List.rev_append alias_targets |> List.rev_append normal_targets pattern_targets |> List.rev_append alias_targets |> List.rev_append normal_targets
|> resolve_pattern_targets ~filter_kind ~dep_depth |> resolve_pattern_targets ~filter_kind ~dep_depth
in in

@ -12,8 +12,8 @@ open! IStd
type flavored_arguments = {command: string; rev_not_targets: string list; targets: string list} type flavored_arguments = {command: string; rev_not_targets: string list; targets: string list}
val add_flavors_to_buck_arguments : val add_flavors_to_buck_arguments :
filter_kind:bool -> dep_depth:int option option -> extra_flavors:string list -> string list filter_kind:[< `Yes | `No | `Auto] -> dep_depth:int option option -> extra_flavors:string list
-> flavored_arguments -> string list -> flavored_arguments
(** Add infer flavors to the targets in the given buck arguments, depending on the infer analyzer. For (** Add infer flavors to the targets in the given buck arguments, depending on the infer analyzer. For
instance, in capture mode, the buck command: instance, in capture mode, the buck command:
build //foo/bar:baz#some,flavor build //foo/bar:baz#some,flavor

@ -94,7 +94,7 @@ let get_compilation_database_files_buck ~prog ~args =
match Config.buck_compilation_database with Some Deps depth -> Some depth | _ -> None match Config.buck_compilation_database with Some Deps depth -> Some depth | _ -> None
in in
match match
Buck.add_flavors_to_buck_arguments ~filter_kind:true ~dep_depth Buck.add_flavors_to_buck_arguments ~filter_kind:`Yes ~dep_depth
~extra_flavors:Config.append_buck_flavors args ~extra_flavors:Config.append_buck_flavors args
with with
| {command= "build" as command; rev_not_targets; targets} -> | {command= "build" as command; rev_not_targets; targets} ->

@ -289,7 +289,7 @@ let capture ~changed_files mode =
Unix.putenv ~key:CLOpt.args_env_var ~data:infer_args_with_buck ; Unix.putenv ~key:CLOpt.args_env_var ~data:infer_args_with_buck ;
let prog, buck_args = IList.uncons_exn build_cmd in let prog, buck_args = IList.uncons_exn build_cmd in
let {Buck.command; rev_not_targets; targets} = let {Buck.command; rev_not_targets; targets} =
Buck.add_flavors_to_buck_arguments ~filter_kind:false ~dep_depth:None Buck.add_flavors_to_buck_arguments ~filter_kind:`Auto ~dep_depth:None
~extra_flavors:[] buck_args ~extra_flavors:[] buck_args
in in
let all_args = List.rev_append rev_not_targets targets in let all_args = List.rev_append rev_not_targets targets in

Loading…
Cancel
Save