r295043 - [scan-build-py] use subprocess wrapper to execute build
Laszlo Nagy via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 14 02:30:51 PST 2017
Author: rizsotto
Date: Tue Feb 14 04:30:50 2017
New Revision: 295043
URL: http://llvm.org/viewvc/llvm-project?rev=295043&view=rev
Log:
[scan-build-py] use subprocess wrapper to execute build
Modified:
cfe/trunk/tools/scan-build-py/libscanbuild/__init__.py
cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py
cfe/trunk/tools/scan-build-py/libscanbuild/intercept.py
Modified: cfe/trunk/tools/scan-build-py/libscanbuild/__init__.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build-py/libscanbuild/__init__.py?rev=295043&r1=295042&r2=295043&view=diff
==============================================================================
--- cfe/trunk/tools/scan-build-py/libscanbuild/__init__.py (original)
+++ cfe/trunk/tools/scan-build-py/libscanbuild/__init__.py Tue Feb 14 04:30:50 2017
@@ -39,6 +39,19 @@ def tempdir():
return os.getenv('TMPDIR', os.getenv('TEMP', os.getenv('TMP', '/tmp')))
+def run_build(command, *args, **kwargs):
+ """ Run and report build command execution
+
+ :param command: array of tokens
+ :return: exit code of the process
+ """
+ environment = kwargs.get('env', os.environ)
+ logging.debug('run build %s, in environment: %s', command, environment)
+ exit_code = subprocess.call(command, *args, **kwargs)
+ logging.debug('build finished with exit code: %d', exit_code)
+ return exit_code
+
+
def run_command(command, cwd=None):
""" Run a given command and report the execution.
Modified: cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py?rev=295043&r1=295042&r2=295043&view=diff
==============================================================================
--- cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py (original)
+++ cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py Tue Feb 14 04:30:50 2017
@@ -20,7 +20,8 @@ import argparse
import logging
import subprocess
import multiprocessing
-from libscanbuild import initialize_logging, tempdir, command_entry_point
+from libscanbuild import initialize_logging, tempdir, command_entry_point, \
+ run_build
from libscanbuild.runner import run
from libscanbuild.intercept import capture
from libscanbuild.report import report_directory, document
@@ -70,9 +71,7 @@ def analyze_build_main(bin_dir, from_bui
# run the build command with compiler wrappers which
# execute the analyzer too. (interposition)
environment = setup_environment(args, target_dir, bin_dir)
- logging.debug('run build in environment: %s', environment)
- exit_code = subprocess.call(args.build, env=environment)
- logging.debug('build finished with exit code: %d', exit_code)
+ exit_code = run_build(args.build, env=environment)
# cover report generation and bug counting
number_of_bugs = document(args, target_dir, False)
# set exit status as it was requested
Modified: cfe/trunk/tools/scan-build-py/libscanbuild/intercept.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build-py/libscanbuild/intercept.py?rev=295043&r1=295042&r2=295043&view=diff
==============================================================================
--- cfe/trunk/tools/scan-build-py/libscanbuild/intercept.py (original)
+++ cfe/trunk/tools/scan-build-py/libscanbuild/intercept.py Tue Feb 14 04:30:50 2017
@@ -31,7 +31,7 @@ import argparse
import logging
import subprocess
from libear import build_libear, TemporaryDirectory
-from libscanbuild import command_entry_point, run_command
+from libscanbuild import command_entry_point, run_build, run_command
from libscanbuild import duplicate_check, tempdir, initialize_logging
from libscanbuild.compilation import split_command
from libscanbuild.shell import encode, decode
@@ -95,9 +95,7 @@ def capture(args, bin_dir):
with TemporaryDirectory(prefix='intercept-', dir=tempdir()) as tmp_dir:
# run the build command
environment = setup_environment(args, tmp_dir, bin_dir)
- logging.debug('run build in environment: %s', environment)
- exit_code = subprocess.call(args.build, env=environment)
- logging.info('build finished with exit code: %d', exit_code)
+ exit_code = run_build(args.build, env=environment)
# read the intercepted exec calls
exec_traces = itertools.chain.from_iterable(
parse_exec_trace(os.path.join(tmp_dir, filename))
More information about the cfe-commits
mailing list