[buck] kill some dead arguments and code

Summary:
`Buck.parse_command_and_targets` is never called with a `filter_kind:No` argument.

Open variants are not great for detecting dead code.

Reviewed By: jvillard

Differential Revision: D21685076

fbshipit-source-id: 68a89ef65
master
Nikos Gorogiannis 5 years ago committed by Facebook GitHub Bot
parent 719b72cb4f
commit 2b19166c70

@ -203,8 +203,6 @@ let get_accepted_buck_kinds_pattern (mode : BuckMode.t) =
let max_command_line_length = 50
let die_if_empty f = function [] -> f L.(die UserError) | l -> l
(** for genrule_master_mode, this is the label expected on the capture genrules *)
let infer_enabled_label = "infer_enabled"
@ -253,7 +251,7 @@ let config =
List.fold args ~init:[] ~f:(fun acc f -> "--config" :: f :: acc)
let resolve_pattern_targets (buck_mode : BuckMode.t) ~filter_kind targets =
let resolve_pattern_targets (buck_mode : BuckMode.t) targets =
targets |> List.rev_map ~f:Query.target |> Query.set
|> ( match buck_mode with
| ClangFlavors | ClangCompilationDB NoDependencies ->
@ -262,7 +260,7 @@ let resolve_pattern_targets (buck_mode : BuckMode.t) ~filter_kind targets =
Query.deps None
| ClangCompilationDB (DepsUpToDepth depth) ->
Query.deps (Some depth) )
|> (if filter_kind then Query.kind ~pattern:(get_accepted_buck_kinds_pattern buck_mode) else Fn.id)
|> Query.kind ~pattern:(get_accepted_buck_kinds_pattern buck_mode)
|> ( if BuckMode.is_java_genrule_master_or_combined buck_mode then
Query.label_filter ~label:infer_enabled_label
else Fn.id )
@ -273,16 +271,6 @@ let resolve_pattern_targets (buck_mode : BuckMode.t) ~filter_kind targets =
else Fn.id
let resolve_alias_targets aliases =
(* we could use buck query to resolve aliases but buck targets --resolve-alias is faster *)
let cmd = "buck" :: "targets" :: "--resolve-alias" :: aliases in
let on_result_lines =
die_if_empty (fun die ->
die "*** No alias found for: '%a'." (Pp.seq ~sep:"', '" F.pp_print_string) aliases )
in
wrap_buck_call ~label:"targets" cmd |> on_result_lines
type parsed_args =
{ rev_not_targets': string list
; normal_targets: string list
@ -357,18 +345,13 @@ let parse_command_and_targets (buck_mode : BuckMode.t) ~filter_kind original_buc
let parsed_args = parse_cmd_args empty_parsed_args args in
let targets =
match (filter_kind, buck_mode, parsed_args) with
| ( (`No | `Auto)
| ( `Auto
, (ClangFlavors | JavaGenruleMaster | CombinedGenrule)
, {pattern_targets= []; alias_targets= []; normal_targets} ) ->
normal_targets
| ( `No
, (ClangFlavors | JavaGenruleMaster | CombinedGenrule)
, {pattern_targets= []; alias_targets; normal_targets} ) ->
alias_targets |> resolve_alias_targets |> List.rev_append normal_targets
| (`Yes | `No | `Auto), _, {pattern_targets; alias_targets; normal_targets} ->
let filter_kind = match filter_kind with `No -> false | `Yes | `Auto -> true in
| (`Yes | `Auto), _, {pattern_targets; alias_targets; normal_targets} ->
pattern_targets |> List.rev_append alias_targets |> List.rev_append normal_targets
|> resolve_pattern_targets buck_mode ~filter_kind
|> resolve_pattern_targets buck_mode
in
let targets =
Option.value_map ~default:targets

@ -35,10 +35,7 @@ val config : BuckMode.t -> string list
given Buck mode. *)
val parse_command_and_targets :
BuckMode.t
-> filter_kind:[< `Yes | `No | `Auto]
-> string list
-> string * string list * string list
BuckMode.t -> filter_kind:[< `Yes | `Auto] -> string list -> string * string list * string list
(** parses given buck command, using the buck configuration returned by [config] above and returns a
triple [(buck_command, non_target_params, target_params)] *)

@ -11,7 +11,7 @@ type flavored_arguments = {command: string; rev_not_targets: string list; target
val add_flavors_to_buck_arguments :
BuckMode.t
-> filter_kind:[< `Yes | `No | `Auto]
-> filter_kind:[< `Yes | `Auto]
-> extra_flavors:string list
-> string list
-> flavored_arguments

Loading…
Cancel
Save