From 1b4a5729edd4165212476c4d67e7d8ed51a873be Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Mon, 23 Oct 2017 06:54:45 -0700 Subject: [PATCH] [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 --- infer/src/integration/Buck.ml | 9 +++++++++ infer/src/integration/Buck.mli | 3 +++ infer/src/integration/CaptureCompilationDatabase.ml | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/infer/src/integration/Buck.ml b/infer/src/integration/Buck.ml index 87b58a352..7d6c929ff 100644 --- a/infer/src/integration/Buck.ml +++ b/infer/src/integration/Buck.ml @@ -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 + diff --git a/infer/src/integration/Buck.mli b/infer/src/integration/Buck.mli index c0f1f2031..98b31aeb4 100644 --- a/infer/src/integration/Buck.mli +++ b/infer/src/integration/Buck.mli @@ -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 *) diff --git a/infer/src/integration/CaptureCompilationDatabase.ml b/infer/src/integration/CaptureCompilationDatabase.ml index c9e1fd50d..68b617f08 100644 --- a/infer/src/integration/CaptureCompilationDatabase.ml +++ b/infer/src/integration/CaptureCompilationDatabase.ml @@ -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 =