print more info about ant/gradle/make/mvn capture

Summary: public
Print "Capturing..." message, and some info in case it fails, eg:

  $ cd examples/android_hello/
  $ infer -- ./gradlew build
  Running and capturing gradle compilation...
  [... stuff ...]
  $ infer -- ./gradlew build
  Running and capturing gradle compilation...
  Nothing to compile. Try running `./gradlew clean` first.

Reviewed By: jeremydubreil

Differential Revision: D2637024

fb-gh-sync-id: 0e8867d
master
Jules Villard 9 years ago committed by facebook-github-bot-7
parent 571bb306cf
commit 5f57d199f3

@ -77,4 +77,5 @@ class AntCapture:
def capture(self):
cmds = self.get_infer_commands(util.get_build_output(self.build_cmd))
return util.run_commands(cmds)
clean_cmd = '%s clean' % self.build_cmd[0]
return util.run_compilation_commands(cmds, clean_cmd)

@ -80,5 +80,7 @@ class GradleCapture:
return calls
def capture(self):
print('Running and capturing gradle compilation...')
cmds = self.get_infer_commands(util.get_build_output(self.build_cmd))
return util.run_commands(cmds)
clean_cmd = '%s clean' % self.build_cmd[0]
return util.run_compilation_commands(cmds, clean_cmd)

@ -58,6 +58,15 @@ class MakeCapture:
env = self.get_envvars()
logging.info('Running command %s with env:\n%s' % (self.cmd, env))
subprocess.check_call(self.cmd, env=env)
capture_dir = os.path.join(self.args.infer_out, 'captured')
if len(os.listdir(capture_dir)) < 1:
# Don't return with a failure code unless we're
# running make. It could be normal to have captured
# nothing (eg, empty source file). Further output will
# alert the user that there was nothing to analyze.
if self.cmd[0] == 'make':
# reuse code from gradle, etc. integration
return util.run_compilation_commands([], 'make clean')
return os.EX_OK
except subprocess.CalledProcessError as exc:
if self.args.debug:

@ -61,4 +61,5 @@ class MavenCapture:
def capture(self):
cmds = self.get_infer_commands(util.get_build_output(self.build_cmd))
return util.run_commands(cmds)
clean_cmd = '%s clean' % self.build_cmd[0]
return util.run_compilation_commands(cmds, clean_cmd)

@ -33,9 +33,13 @@ def get_build_output(build_cmd):
return verbose_out_chars.split('\n')
def run_commands(cmds):
def run_compilation_commands(cmds, clean_cmd):
"""runs compilation commands, and suggests a project cleaning command
in case there is nothing to compile.
"""
# TODO call it in parallel
if len(cmds) == 0:
print('Nothing to compile. Try running `%s` first.' % clean_cmd)
return os.EX_NOINPUT
for cmd in cmds:
if cmd.start() != os.EX_OK:

Loading…
Cancel
Save