[buck] filter out incompatible options for the `targets` subcommand

Summary:
The options passed via `--Xbuck` are usually meant for `buck build` but we also
use them for `buck targets`. It's hard to know which options to take into
account for which Buck subcommand, so just filter out known-incompatible ones.

Reviewed By: dulmarod

Differential Revision: D6123459

fbshipit-source-id: 976b978
master
Jules Villard 7 years ago committed by Facebook Github Bot
parent 12d73e67dc
commit 1b4a5729ed

@ -127,3 +127,12 @@ let store_targets_in_file buck_targets =
L.(debug Capture Quiet) "Buck targets options stored in file '%s'@\n" file ;
Printf.sprintf "@%s" file
let filter_compatible subcommand args =
match subcommand with
| `Targets ->
let blacklist = "--keep-going" in
List.filter args ~f:(fun arg -> not (String.equal blacklist arg))
| _ ->
args

@ -33,3 +33,6 @@ val inline_argument_files : string list -> string list
val store_targets_in_file : string list -> string
(** Given a list of buck targets, stores them in a file and returns the file name *)
val filter_compatible : [> `Targets] -> string list -> string list
(** keep only the options compatible with the given Buck subcommand *)

@ -111,7 +111,8 @@ let get_compilation_database_files_buck ~prog ~args =
(String.concat ~sep:" " build_args) ;
Process.create_process_and_wait ~prog ~args:build_args ;
let buck_targets_shell =
List.append [prog; "targets"; "--show-output"; targets_in_file] no_targets_no_build
Buck.filter_compatible `Targets no_targets_no_build
|> List.append [prog; "targets"; "--show-output"; targets_in_file]
|> Utils.shell_escape_command
in
let output, exit_or_signal =

Loading…
Cancel
Save