Skip the Buck build command when the list of target is empty

Summary: public
Since we are only running the analysis on the Buck targets that are of type java_library or android_library, it may happen that the filtering gives an empty list of targets.

This diff does two things:
 1) it filters out the empty strings `''` that can be returned when parsing the `buck query` command, and
 2) skip the analysis when the list of targets to analyze is empty.

It also fixes the debug output for the list of targets to analyze, which was previously always printing the list of targets passed in the command line argument, which led for this issue to be unoticed even though it may have been there for a while already.

Reviewed By: sblackshear

Differential Revision: D2704949

fb-gh-sync-id: 83c62d8
master
jrm 9 years ago committed by facebook-github-bot-1
parent a49b0965ef
commit 1aa354cf1f

@ -147,10 +147,12 @@ def get_normalized_targets(targets):
buck_cmd = BUCK_GET_JAVA_TARGETS + targets
try:
targets = subprocess.check_output(buck_cmd).decode().strip().split('\n')
if args.verbose:
targets = filter(
lambda line: len(line) > 0,
subprocess.check_output(buck_cmd).decode().strip().split('\n'))
if len(targets) > 0 and args.verbose:
logging.debug('Targets to analyze:')
for target in args.targets:
for target in targets:
logging.debug(target)
return targets
except subprocess.CalledProcessError as e:
@ -474,6 +476,9 @@ if __name__ == '__main__':
normalized_targets = get_normalized_targets(args.targets)
timer.stop('%d targets computed', len(normalized_targets))
if len(normalized_targets) == 0:
logging.info('Nothing to analyze')
else:
timer.start('Running buck...')
buck_cmd = ['buck', 'build']
if args.no_cache:

Loading…
Cancel
Save