cppcheck Linux / Windows support

pull/353/head
Przemek Wirkus 2014-06-11 15:51:32 +01:00
parent fb9ea201d4
commit d58d532ebc
2 changed files with 12 additions and 4 deletions

View File

@ -16,11 +16,12 @@ limitations under the License.
""" """
import tempfile import tempfile
import os
from os.path import join, exists, basename from os.path import join, exists, basename
from shutil import rmtree from shutil import rmtree
from types import ListType from types import ListType
from workspace_tools.utils import mkdir, run_cmd from workspace_tools.utils import mkdir, run_cmd, run_cmd_ext
from workspace_tools.toolchains import TOOLCHAIN_CLASSES from workspace_tools.toolchains import TOOLCHAIN_CLASSES
from workspace_tools.paths import MBED_TARGETS_PATH, MBED_LIBRARIES, MBED_API, MBED_HAL, MBED_COMMON from workspace_tools.paths import MBED_TARGETS_PATH, MBED_LIBRARIES, MBED_API, MBED_HAL, MBED_COMMON
from workspace_tools.libraries import Library from workspace_tools.libraries import Library
@ -290,7 +291,7 @@ def static_analysis_scan(target, toolchain_name, CPPCHECK_CMD, CPPCHECK_MSG_FORM
tmp_file.close() tmp_file.close()
check_cmd += " --file-list=%s"% tmp_file.name check_cmd += " --file-list=%s"% tmp_file.name
_stdout, _stderr, _rc = run_cmd(check_cmd) _stdout, _stderr, _rc = run_cmd_ext(check_cmd.split() if os.name == 'posix' else check_cmd)
if verbose: if verbose:
print _stdout print _stdout
print _stderr print _stderr
@ -351,7 +352,7 @@ def static_analysis_scan(target, toolchain_name, CPPCHECK_CMD, CPPCHECK_MSG_FORM
tmp_file.close() tmp_file.close()
check_cmd += " --file-list=%s"% tmp_file.name check_cmd += " --file-list=%s"% tmp_file.name
_stdout, _stderr, _rc = run_cmd(check_cmd) _stdout, _stderr, _rc = run_cmd_ext(check_cmd.split() if os.name == 'posix' else check_cmd)
if verbose: if verbose:
print _stdout print _stdout
print _stderr print _stderr
@ -433,7 +434,7 @@ def static_analysis_scan_library(src_paths, build_path, target, toolchain_name,
tmp_file.close() tmp_file.close()
check_cmd += " --file-list=%s"% tmp_file.name check_cmd += " --file-list=%s"% tmp_file.name
_stdout, _stderr, _rc = run_cmd(check_cmd) _stdout, _stderr, _rc = run_cmd_ext(check_cmd.split() if os.name == 'posix' else check_cmd)
if verbose: if verbose:
print _stdout print _stdout
print _stderr print _stderr

View File

@ -36,6 +36,13 @@ def run_cmd(command, wd=None, redirect=False):
return _stdout, _stderr, p.returncode return _stdout, _stderr, p.returncode
def run_cmd_ext(command):
import subprocess
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
_stdout, _stderr = p.communicate()
return _stdout, _stderr, p.returncode
def mkdir(path): def mkdir(path):
if not exists(path): if not exists(path):
makedirs(path) makedirs(path)