diff --git a/infer/lib/python/inferlib/capture/buck.py b/infer/lib/python/inferlib/capture/buck.py index 01cb00b29..1d2fe218e 100644 --- a/infer/lib/python/inferlib/capture/buck.py +++ b/infer/lib/python/inferlib/capture/buck.py @@ -33,6 +33,8 @@ def gen_instance(*args): return BuckAnalyzer(*args) +def string_in_quotes(value): + return value.strip('\'') # This creates an empty argparser for the module, which provides only # description/usage information and no arguments. def create_argparser(group_name=MODULE_NAME): @@ -64,6 +66,12 @@ def create_argparser(group_name=MODULE_NAME): help='Merge the infer-deps.txt files generated by Buck ' 'during the analysis (requires --use-flavors to ' 'work)') + group.add_argument('--Xbuck', action='append', default=[], + type=string_in_quotes, + help='Pass values as command-line arguments to ' + 'invocations of `buck build`.' + 'NOTE: value should be wrapped in single quotes') + return parser @@ -110,7 +118,8 @@ class BuckAnalyzer: 'infer.clang_compiler={clang}'.format(clang=clang_path), '--config', 'infer.clang_plugin={plugin}'.format(plugin=plugin_path), - ] + ] + self.args.Xbuck + if self.args.xcode_developer_dir is not None: args.append('--config') args.append('apple.xcode_developer_dir={devdir}'.format( diff --git a/infer/src/backend/config.ml b/infer/src/backend/config.ml index 6e93ba193..d0b074a22 100644 --- a/infer/src/backend/config.ml +++ b/infer/src/backend/config.ml @@ -526,6 +526,10 @@ and buck = CLOpt.mk_bool ~long:"buck" "To use when run with buck" +and buck_build_args = + CLOpt.mk_string_list ~long:"Xbuck" + "Pass values as command-line arguments to invocations of `buck build`" + and buck_out = CLOpt.mk_string_opt ~long:"buck-out" ~exes:CLOpt.[StatsAggregator] ~meta:"dir" "Specify the root directory of buck-out" @@ -1293,6 +1297,7 @@ and array_level = !array_level and ast_file = !ast_file and blacklist = !blacklist and buck = !buck +and buck_build_args = !buck_build_args and buck_out = !buck_out and bugs_csv = !bugs_csv and bugs_json = !bugs_json diff --git a/infer/src/backend/config.mli b/infer/src/backend/config.mli index e0ed1d851..1136c2252 100644 --- a/infer/src/backend/config.mli +++ b/infer/src/backend/config.mli @@ -136,6 +136,7 @@ val array_level : int val ast_file : string option val blacklist : string option val buck : bool +val buck_build_args : string list val buck_out : string option val bugs_csv : outfile option val bugs_json : outfile option diff --git a/infer/src/backend/infer.ml b/infer/src/backend/infer.ml index 3f2c59ce1..68a8d7178 100644 --- a/infer/src/backend/infer.ml +++ b/infer/src/backend/infer.ml @@ -57,6 +57,10 @@ let () = ["--android-harness"]) @ (if not Config.buck then [] else ["--buck"]) @ + (match IList.rev Config.buck_build_args with + | args when buck -> + IList.map (fun arg -> ["--Xbuck"; "'" ^ arg ^ "'"]) args |> IList.flatten + | _ -> []) @ (if not Config.debug_mode then [] else ["--debug"]) @ (if not Config.debug_exceptions then [] else