예제 #1
0
    def compile(self, cc, source, object, includes):
        # Check dependencies
        base, _ = splitext(object)
        dep_path = base + '.d'
        if (not exists(dep_path) or self.need_update(
                object, self.parse_dependencies(dep_path))):
            self.progress("compile", source)

            # Compile
            command = cc + ['-D%s' % s for s in self.symbols
                            ] + ["-I%s" % i
                                 for i in includes] + ["-o", object, source]
            if hasattr(self, "get_dep_opt"):
                command.extend(self.get_dep_opt(dep_path))

            if hasattr(self, "cc_extra"):
                command.extend(self.cc_extra(base))

            self.debug(command)
            _, stderr, rc = run_cmd(command,
                                    dirname(object),
                                    chroot=self.CHROOT)

            # Parse output for Warnings and Errors
            self.parse_output(stderr)

            # Check return code
            if rc != 0:
                raise ToolException(stderr)
예제 #2
0
파일: __init__.py 프로젝트: teddokano/mbed
 def compile(self, cc, source, object, includes):
     # Check dependencies
     base, _ = splitext(object)
     dep_path = base + '.d'
     
     self.compiled += 1
     if (not exists(dep_path) or
         self.need_update(object, self.parse_dependencies(dep_path))):
         
         self.progress("compile", source, build_update=True)
         
         # Compile
         command = cc + ['-D%s' % s for s in self.get_symbols()] + ["-I%s" % i for i in includes] + ["-o", object, source]
         if hasattr(self, "get_dep_opt"):
             command.extend(self.get_dep_opt(dep_path))
         
         if hasattr(self, "cc_extra"):
             command.extend(self.cc_extra(base))
         
         self.debug(command)
         _, stderr, rc = run_cmd(command, dirname(object))
         
         # Parse output for Warnings and Errors
         self.parse_output(stderr)
         
         # Check return code
         if rc != 0:
             raise ToolException(stderr)
예제 #3
0
파일: toolchains.py 프로젝트: alejmrm/mbed
 def default_cmd(self, command):
     self.debug(command)
     stdout, stderr, rc = run_cmd(command)
     self.debug(stdout)
     if rc != 0:
         self.tool_error(stderr)
         raise ToolException(stderr)
예제 #4
0
파일: __init__.py 프로젝트: teddokano/mbed
 def default_cmd(self, command):
     self.debug(command)
     stdout, stderr, rc = run_cmd(command)
     self.debug(stdout)
     if rc != 0:
         for line in stderr.splitlines():
             self.tool_error(line)
         raise ToolException(stderr)
예제 #5
0
 def default_cmd(self, command):
     self.debug(command)
     stdout, stderr, rc = run_cmd(command, chroot=self.CHROOT)
     self.debug(stdout)
     if rc != 0:
         for line in stderr.splitlines():
             self.tool_error(line)
         raise ToolException(stderr)
예제 #6
0
파일: __init__.py 프로젝트: yzdel7/mbed
    def default_cmd(self, command):
        self.debug("Command: %s" % ' '.join(command))
        stdout, stderr, rc = run_cmd(command)
        self.debug("Return: %s" % rc)
        self.debug("Output: %s" % ' '.join(stdout))

        if rc != 0:
            for line in stderr.splitlines():
                self.tool_error(line)
            raise ToolException(stderr)
예제 #7
0
파일: __init__.py 프로젝트: haydar9/mbed
    def default_cmd(self, command):
        self.debug("Command: %s" % ' '.join(command))
        stdout, stderr, rc = run_cmd(command)
        self.debug("Return: %s" % rc)
        self.debug("Output: %s" % ' '.join(stdout))

        if rc != 0:
            for line in stderr.splitlines():
                self.tool_error(line)
            raise ToolException(stderr)
예제 #8
0
def compile_worker(job):
    results = []
    for command in job['commands']:
        _, _stderr, _rc = run_cmd(command, job['work_dir'])
        results.append({'code': _rc, 'output': _stderr, 'command': command})

    return {
        'source': job['source'],
        'object': job['object'],
        'commands': job['commands'],
        'results': results
    }
예제 #9
0
파일: synch.py 프로젝트: rsethuram/mbed
    def publish(self):
        # The maintainer has to evaluate the changes first and explicitly accept them
        cmd(['hg', 'addremove'], cwd=self.path)
        stdout, _, _ = run_cmd(['hg', 'status'], wd=self.path)
        if stdout == '':
            print "No changes"
            return

        print stdout
        commit = raw_input("Do you want to commit and push? Y/N: ")
        if commit == 'Y':
            cmd(['hg', 'commit', '-u', MBED_ORG_USER], cwd=self.path)
            cmd(['hg', 'push'], cwd=self.path)
예제 #10
0
 def publish(self):
     # The maintainer has to evaluate the changes first and explicitly accept them
     cmd(['hg', 'addremove'], cwd=self.path)
     stdout, _, _ = run_cmd(['hg', 'status'], wd=self.path)
     if stdout == '':
         print "No changes"
         return
     
     print stdout
     commit = raw_input("Do you want to commit and push? Y/N: ")
     if commit == 'Y':
         cmd(['hg', 'commit', '-u', MBED_ORG_USER], cwd=self.path)
         cmd(['hg', 'push'], cwd=self.path)
예제 #11
0
파일: __init__.py 프로젝트: Shirlies/mbed
def compile_worker(job):
    results = []
    for command in job['commands']:
        _, _stderr, _rc = run_cmd(command, job['work_dir'])
        results.append({
            'code': _rc,
            'output': _stderr,
            'command': command
        })

    return {
        'source': job['source'],
        'object': job['object'],
        'commands': job['commands'],
        'results': results
    }
예제 #12
0
    def default_cmd(self, command):
        _stdout, _stderr, _rc = run_cmd(command)
        # Print all warning / erros from stderr to console output
        for error_line in _stderr.splitlines():
            print error_line

        self.debug("Command: %s" % ' '.join(command))
        self.debug("Return: %s" % _rc)

        for output_line in _stdout.splitlines():
            self.debug("Output: %s" % output_line)
        for error_line in _stderr.splitlines():
            self.debug("Errors: %s" % error_line)

        if _rc != 0:
            for line in _stderr.splitlines():
                self.tool_error(line)
            raise ToolException(_stderr)
예제 #13
0
파일: __init__.py 프로젝트: Shirlies/mbed
    def default_cmd(self, command):
        _stdout, _stderr, _rc = run_cmd(command)
        # Print all warning / erros from stderr to console output
        for error_line in _stderr.splitlines():
            print error_line

        self.debug("Command: %s"% ' '.join(command))
        self.debug("Return: %s"% _rc)

        for output_line in _stdout.splitlines():
            self.debug("Output: %s"% output_line)
        for error_line in _stderr.splitlines():
            self.debug("Errors: %s"% error_line)

        if _rc != 0:
            for line in _stderr.splitlines():
                self.tool_error(line)
            raise ToolException(_stderr)
예제 #14
0
파일: synch.py 프로젝트: ProxxiTech/mbed
 def publish(self):
     # The maintainer has to evaluate the changes first and explicitly accept them
     self.run_and_print(['hg', 'addremove'], cwd=self.path)
     stdout, _, _ = run_cmd(['hg', 'status'], wd=self.path)
     if stdout == '':
         print "No changes"
         return False
     print stdout
     if quiet:
         commit = 'Y'
     else:
         commit = raw_input(push_remote and "Do you want to commit and push? Y/N: " or "Do you want to commit? Y/N: ")
     if commit == 'Y':
         args = ['hg', 'commit', '-u', MBED_ORG_USER]
         if commit_msg:
             args = args + ['-m', commit_msg]
         self.run_and_print(args, cwd=self.path)
         if push_remote:
             self.run_and_print(['hg', 'push'], cwd=self.path)
     return True
예제 #15
0
 def publish(self):
     # The maintainer has to evaluate the changes first and explicitly accept them
     self.run_and_print(['hg', 'addremove'], cwd=self.path)
     stdout, _, _ = run_cmd(['hg', 'status'], wd=self.path)
     if stdout == '':
         print "No changes"
         return False
     print stdout
     if quiet:
         commit = 'Y'
     else:
         commit = raw_input(push_remote and "Do you want to commit and push? Y/N: " or "Do you want to commit? Y/N: ")
     if commit == 'Y':
         args = ['hg', 'commit', '-u', MBED_ORG_USER]
         if commit_msg:
             args = args + ['-m', commit_msg]
         self.run_and_print(args, cwd=self.path)
         if push_remote:
             self.run_and_print(['hg', 'push'], cwd=self.path)
     return True
예제 #16
0
 def publish(self):
     # The maintainer has to evaluate the changes first and explicitly accept them
     self.run_and_print(["hg", "addremove"], cwd=self.path)
     stdout, _, _ = run_cmd(["hg", "status"], wd=self.path)
     if stdout == "":
         print "No changes"
         return False
     print stdout
     if quiet:
         commit = "Y"
     else:
         commit = raw_input(
             push_remote and "Do you want to commit and push? Y/N: " or "Do you want to commit? Y/N: "
         )
     if commit == "Y":
         args = ["hg", "commit", "-u", MBED_ORG_USER]
         if commit_msg:
             args = args + ["-m", commit_msg]
         self.run_and_print(args, cwd=self.path)
         if push_remote:
             self.run_and_print(["hg", "push"], cwd=self.path)
     return True
예제 #17
0
 def run_and_print(command, cwd):
     stdout, _, _ = run_cmd(command, wd=cwd, redirect=True)
     print(stdout)
예제 #18
0
파일: synch.py 프로젝트: ProxxiTech/mbed
 def run_and_print(command, cwd):
     stdout, _, _ = run_cmd(command, wd=cwd, redirect=True)
     print(stdout)
예제 #19
0
파일: build_api.py 프로젝트: unos/mbed
def static_analysis_scan(target, toolchain_name, CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, options=None, verbose=False, clean=False, macros=None, notify=None):
    # Toolchain
    toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, macros=macros, notify=notify)
    toolchain.VERBOSE = verbose
    toolchain.build_all = clean

    # Source and Build Paths
    BUILD_TARGET = join(MBED_LIBRARIES, "TARGET_" + target.name)
    BUILD_TOOLCHAIN = join(BUILD_TARGET, "TOOLCHAIN_" + toolchain.name)
    mkdir(BUILD_TOOLCHAIN)

    TMP_PATH = join(MBED_LIBRARIES, '.temp', toolchain.obj_path)
    mkdir(TMP_PATH)

    # CMSIS
    toolchain.info(">>>> STATIC ANALYSIS FOR %s (%s, %s)" % ('CMSIS', target.name, toolchain_name))
    cmsis_src = join(MBED_TARGETS_PATH, "cmsis")
    resources = toolchain.scan_resources(cmsis_src)

    # Copy files before analysis
    toolchain.copy_files(resources.headers, BUILD_TARGET)
    toolchain.copy_files(resources.linker_script, BUILD_TOOLCHAIN)

    # Gather include paths, c, cpp sources and macros to transfer to cppcheck command line
    includes = ["-I%s"% i for i in resources.inc_dirs]
    includes.append("-I%s"% str(BUILD_TARGET))
    c_sources = " ".join(resources.c_sources)
    cpp_sources = " ".join(resources.cpp_sources)
    macros = ["-D%s"% s for s in toolchain.get_symbols() + toolchain.macros]

    includes = map(str.strip, includes)
    macros = map(str.strip, macros)

    check_cmd = CPPCHECK_CMD
    check_cmd += CPPCHECK_MSG_FORMAT
    check_cmd += includes
    check_cmd += macros

    # We need to pass some params via file to avoid "command line too long in some OSs"
    tmp_file = tempfile.NamedTemporaryFile(delete=False)
    tmp_file.writelines(line + '\n' for line in c_sources.split())
    tmp_file.writelines(line + '\n' for line in cpp_sources.split())
    tmp_file.close()
    check_cmd += ["--file-list=%s"% tmp_file.name]

    _stdout, _stderr, _rc = run_cmd(check_cmd)
    if verbose:
        print _stdout
    print _stderr

    # =========================================================================

    # MBED
    toolchain.info(">>> STATIC ANALYSIS FOR %s (%s, %s)" % ('MBED', target.name, toolchain_name))

    # Common Headers
    toolchain.copy_files(toolchain.scan_resources(MBED_API).headers, MBED_LIBRARIES)
    toolchain.copy_files(toolchain.scan_resources(MBED_HAL).headers, MBED_LIBRARIES)

    # Target specific sources
    HAL_SRC = join(MBED_TARGETS_PATH, "hal")
    hal_implementation = toolchain.scan_resources(HAL_SRC)

    # Copy files before analysis
    toolchain.copy_files(hal_implementation.headers + hal_implementation.hex_files, BUILD_TARGET, HAL_SRC)
    incdirs = toolchain.scan_resources(BUILD_TARGET)

    target_includes = ["-I%s" % i for i in incdirs.inc_dirs]
    target_includes.append("-I%s"% str(BUILD_TARGET))
    target_includes.append("-I%s"% str(HAL_SRC))
    target_c_sources = " ".join(incdirs.c_sources)
    target_cpp_sources = " ".join(incdirs.cpp_sources)
    target_macros = ["-D%s"% s for s in toolchain.get_symbols() + toolchain.macros]

    # Common Sources
    mbed_resources = toolchain.scan_resources(MBED_COMMON)

    # Gather include paths, c, cpp sources and macros to transfer to cppcheck command line
    mbed_includes = ["-I%s" % i for i in mbed_resources.inc_dirs]
    mbed_includes.append("-I%s"% str(BUILD_TARGET))
    mbed_includes.append("-I%s"% str(MBED_COMMON))
    mbed_includes.append("-I%s"% str(MBED_API))
    mbed_includes.append("-I%s"% str(MBED_HAL))
    mbed_c_sources = " ".join(mbed_resources.c_sources)
    mbed_cpp_sources = " ".join(mbed_resources.cpp_sources)

    target_includes = map(str.strip, target_includes)
    mbed_includes = map(str.strip, mbed_includes)
    target_macros = map(str.strip, target_macros)

    check_cmd = CPPCHECK_CMD
    check_cmd += CPPCHECK_MSG_FORMAT
    check_cmd += target_includes
    check_cmd += mbed_includes
    check_cmd += target_macros

    # We need to pass some parames via file to avoid "command line too long in some OSs"
    tmp_file = tempfile.NamedTemporaryFile(delete=False)
    tmp_file.writelines(line + '\n' for line in target_c_sources.split())
    tmp_file.writelines(line + '\n' for line in target_cpp_sources.split())
    tmp_file.writelines(line + '\n' for line in mbed_c_sources.split())
    tmp_file.writelines(line + '\n' for line in mbed_cpp_sources.split())
    tmp_file.close()
    check_cmd += ["--file-list=%s"% tmp_file.name]

    _stdout, _stderr, _rc = run_cmd_ext(check_cmd)
    if verbose:
        print _stdout
    print _stderr
예제 #20
0
def static_analysis_scan(target, toolchain_name, CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, options=None, verbose=False, clean=False, macros=None, notify=None, jobs=1):
    # Toolchain
    toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, macros=macros, notify=notify)
    toolchain.VERBOSE = verbose
    toolchain.jobs = jobs
    toolchain.build_all = clean

    # Source and Build Paths
    BUILD_TARGET = join(MBED_LIBRARIES, "TARGET_" + target.name)
    BUILD_TOOLCHAIN = join(BUILD_TARGET, "TOOLCHAIN_" + toolchain.name)
    mkdir(BUILD_TOOLCHAIN)

    TMP_PATH = join(MBED_LIBRARIES, '.temp', toolchain.obj_path)
    mkdir(TMP_PATH)

    # CMSIS
    toolchain.info("Static analysis for %s (%s, %s)" % ('CMSIS', target.name, toolchain_name))
    cmsis_src = join(MBED_TARGETS_PATH, "cmsis")
    resources = toolchain.scan_resources(cmsis_src)

    # Copy files before analysis
    toolchain.copy_files(resources.headers, BUILD_TARGET)
    toolchain.copy_files(resources.linker_script, BUILD_TOOLCHAIN)

    # Gather include paths, c, cpp sources and macros to transfer to cppcheck command line
    includes = ["-I%s"% i for i in resources.inc_dirs]
    includes.append("-I%s"% str(BUILD_TARGET))
    c_sources = " ".join(resources.c_sources)
    cpp_sources = " ".join(resources.cpp_sources)
    macros = ["-D%s"% s for s in toolchain.get_symbols() + toolchain.macros]

    includes = map(str.strip, includes)
    macros = map(str.strip, macros)

    check_cmd = CPPCHECK_CMD
    check_cmd += CPPCHECK_MSG_FORMAT
    check_cmd += includes
    check_cmd += macros

    # We need to pass some params via file to avoid "command line too long in some OSs"
    tmp_file = tempfile.NamedTemporaryFile(delete=False)
    tmp_file.writelines(line + '\n' for line in c_sources.split())
    tmp_file.writelines(line + '\n' for line in cpp_sources.split())
    tmp_file.close()
    check_cmd += ["--file-list=%s"% tmp_file.name]

    _stdout, _stderr, _rc = run_cmd(check_cmd)
    if verbose:
        print _stdout
    print _stderr

    # =========================================================================

    # MBED
    toolchain.info("Static analysis for %s (%s, %s)" % ('MBED', target.name, toolchain_name))

    # Common Headers
    toolchain.copy_files(toolchain.scan_resources(MBED_API).headers, MBED_LIBRARIES)
    toolchain.copy_files(toolchain.scan_resources(MBED_HAL).headers, MBED_LIBRARIES)

    # Target specific sources
    HAL_SRC = join(MBED_TARGETS_PATH, "hal")
    hal_implementation = toolchain.scan_resources(HAL_SRC)

    # Copy files before analysis
    toolchain.copy_files(hal_implementation.headers + hal_implementation.hex_files, BUILD_TARGET, HAL_SRC)
    incdirs = toolchain.scan_resources(BUILD_TARGET)

    target_includes = ["-I%s" % i for i in incdirs.inc_dirs]
    target_includes.append("-I%s"% str(BUILD_TARGET))
    target_includes.append("-I%s"% str(HAL_SRC))
    target_c_sources = " ".join(incdirs.c_sources)
    target_cpp_sources = " ".join(incdirs.cpp_sources)
    target_macros = ["-D%s"% s for s in toolchain.get_symbols() + toolchain.macros]

    # Common Sources
    mbed_resources = toolchain.scan_resources(MBED_COMMON)

    # Gather include paths, c, cpp sources and macros to transfer to cppcheck command line
    mbed_includes = ["-I%s" % i for i in mbed_resources.inc_dirs]
    mbed_includes.append("-I%s"% str(BUILD_TARGET))
    mbed_includes.append("-I%s"% str(MBED_COMMON))
    mbed_includes.append("-I%s"% str(MBED_API))
    mbed_includes.append("-I%s"% str(MBED_HAL))
    mbed_c_sources = " ".join(mbed_resources.c_sources)
    mbed_cpp_sources = " ".join(mbed_resources.cpp_sources)

    target_includes = map(str.strip, target_includes)
    mbed_includes = map(str.strip, mbed_includes)
    target_macros = map(str.strip, target_macros)

    check_cmd = CPPCHECK_CMD
    check_cmd += CPPCHECK_MSG_FORMAT
    check_cmd += target_includes
    check_cmd += mbed_includes
    check_cmd += target_macros

    # We need to pass some parames via file to avoid "command line too long in some OSs"
    tmp_file = tempfile.NamedTemporaryFile(delete=False)
    tmp_file.writelines(line + '\n' for line in target_c_sources.split())
    tmp_file.writelines(line + '\n' for line in target_cpp_sources.split())
    tmp_file.writelines(line + '\n' for line in mbed_c_sources.split())
    tmp_file.writelines(line + '\n' for line in mbed_cpp_sources.split())
    tmp_file.close()
    check_cmd += ["--file-list=%s"% tmp_file.name]

    _stdout, _stderr, _rc = run_cmd_ext(check_cmd)
    if verbose:
        print _stdout
    print _stderr