new flag to find infer-deps when `buck target` fails to

Reviewed By: skcho

Differential Revision: D18201162

fbshipit-source-id: 2ae4fd7f5
master
Martin Trojer 5 years ago committed by Facebook Github Bot
parent e9b0ca9ce4
commit 5508a64d60

@ -69,6 +69,9 @@ def create_argparser(group_name=MODULE_NAME):
help='Pass values as command-line arguments to '
'invocations of `buck build`.'
'NOTE: value should be wrapped in single quotes')
group.add_argument('--buck-merge-all-deps',
action='store_true',
help='Find and merge all deps produced by buck')
return parser
@ -195,6 +198,19 @@ class BuckAnalyzer:
print('time elapsed in finding captured files in buck-out: % 6.2fs'
% elapsed_time)
def _find_depsfiles_and_merge(self, merge_out_path):
""" Sometimes buck targets --show-output gets confused and returns a
folder that doesn't contain infer-deps.txt. This can happen with on
for example objc targes with a certain combination of BUCK modes and
flavours. This function will walk buck-out and find infer-deps.txt
It will merge ALL infer-deps.txt in buck-out, so you might want
to do a buck clean first."""
fs = []
for root, dirs, files in os.walk(config.BUCK_OUT_GEN):
fs += [os.path.dirname(os.path.join(root, f)) for f in files
if f == config.INFER_BUCK_DEPS_FILENAME]
self._merge_infer_dep_files(fs, merge_out_path)
def _move_buck_out(self):
""" If keep-going is passed, we may need to compute the infer-deps
file with the paths to the captured files. To make sure that
@ -249,8 +265,10 @@ class BuckAnalyzer:
merged_deps_path = os.path.join(
self.args.infer_out, config.INFER_BUCK_DEPS_FILENAME)
self._merge_infer_report_files(result_paths, merged_reports_path)
if not ret == os.EX_OK and self.keep_going:
if (not ret == os.EX_OK and self.keep_going):
self._find_deps_and_merge(merged_deps_path)
elif self.args.buck_merge_all_deps:
self._find_depsfiles_and_merge(merged_deps_path)
else:
self._merge_infer_dep_files(result_paths, merged_deps_path)
infer_out = self.args.infer_out

@ -129,6 +129,11 @@ BUCK FLAVORS OPTIONS
(only the "flavors (C++)" Buck integration is supported, not
Java).
--buck-merge-all-deps
Activates: Find and merge all infer dependencies produced by buck.
Use this flag if infer doesn't find any files to analyze after a
successful capture. (Conversely: --no-buck-merge-all-deps)
--capture-blacklist regex
Skip capture of files matched by the specified OCaml regular
expression (only supported by the javac integration for now).

@ -150,6 +150,12 @@ OPTIONS
option. By default, all recursive dependencies are captured.
See also infer-capture(1).
--buck-merge-all-deps
Activates: Find and merge all infer dependencies produced by buck.
Use this flag if infer doesn't find any files to analyze after a
successful capture. (Conversely: --no-buck-merge-all-deps)
See also infer-capture(1).
--buck-out dir
Specify the root directory of buck-out See also infer-capture(1).

@ -150,6 +150,12 @@ OPTIONS
option. By default, all recursive dependencies are captured.
See also infer-capture(1).
--buck-merge-all-deps
Activates: Find and merge all infer dependencies produced by buck.
Use this flag if infer doesn't find any files to analyze after a
successful capture. (Conversely: --no-buck-merge-all-deps)
See also infer-capture(1).
--buck-out dir
Specify the root directory of buck-out See also infer-capture(1).

@ -914,6 +914,13 @@ and buck_compilation_database =
~symbols:[("no-deps", `NoDeps); ("deps", `DepsTmp)]
and buck_merge_all_deps =
CLOpt.mk_bool ~long:"buck-merge-all-deps" ~default:false
~in_help:InferCommand.[(Capture, manual_buck_flavors)]
"Find and merge all infer dependencies produced by buck. Use this flag if infer doesn't find \
any files to analyze after a successful capture."
and buck_out =
CLOpt.mk_path_opt ~long:"buck-out"
~in_help:InferCommand.[(Capture, manual_buck_java)]
@ -2749,6 +2756,8 @@ and buck_compilation_database =
None
and buck_merge_all_deps = !buck_merge_all_deps
and buck_out = !buck_out
and buck_targets_blacklist = !buck_targets_blacklist

@ -249,6 +249,8 @@ val buck_cache_mode : bool
val buck_compilation_database : compilation_database_dependencies option
val buck_merge_all_deps : bool
val buck_out : string option
val buck_targets_blacklist : string list

@ -256,6 +256,7 @@ let python_capture build_system build_cmd =
[]
| Some d ->
["--xcode-developer-dir"; d] )
@ (if not Config.buck_merge_all_deps then [] else ["--buck-merge-all-deps"])
@ ("--" :: updated_build_cmd) )
in
if in_buck_mode && Config.flavors then ( RunState.set_merge_capture true ; RunState.store () ) ;

Loading…
Cancel
Save