diff --git a/workspace_tools/build.py b/workspace_tools/build.py index 969ca03b6b..d1211e8f4f 100755 --- a/workspace_tools/build.py +++ b/workspace_tools/build.py @@ -28,7 +28,6 @@ sys.path.insert(0, ROOT) from workspace_tools.toolchains import TOOLCHAINS -from workspace_tools.toolchains import print_notify_verbose from workspace_tools.targets import TARGET_NAMES, TARGET_MAP from workspace_tools.options import get_default_options_parser from workspace_tools.build_api import build_mbed_libs, build_lib @@ -184,8 +183,6 @@ if __name__ == '__main__': if options.cpputest_lib: libraries.extend(["cpputest"]) - notify = print_notify_verbose if options.extra_verbose_notify else None # Special notify for CI (more verbose) - # Build results failures = [] successes = [] @@ -203,7 +200,7 @@ if __name__ == '__main__': # Static check for library static_analysis_scan_lib(lib_id, mcu, toolchain, CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, options=options.options, - notify=notify, verbose=options.verbose, jobs=options.jobs, clean=options.clean, + extra_verbose=options.extra_verbose_notify, verbose=options.verbose, jobs=options.jobs, clean=options.clean, macros=options.macros) pass except Exception, e: @@ -221,17 +218,16 @@ if __name__ == '__main__': mcu = TARGET_MAP[target] lib_build_res = build_mbed_libs(mcu, toolchain, options=options.options, - notify=notify, + extra_verbose=options.extra_verbose_notify, verbose=options.verbose, silent=options.silent, jobs=options.jobs, clean=options.clean, macros=options.macros) for lib_id in libraries: - notify = print_notify_verbose if options.extra_verbose_notify else None # Special notify for CI (more verbose) build_lib(lib_id, mcu, toolchain, options=options.options, - notify=notify, + extra_verbose=options.extra_verbose_notify, verbose=options.verbose, silent=options.silent, clean=options.clean, diff --git a/workspace_tools/build_api.py b/workspace_tools/build_api.py index ff56232592..b360d84c08 100644 --- a/workspace_tools/build_api.py +++ b/workspace_tools/build_api.py @@ -77,11 +77,11 @@ def add_result_to_report(report, result): def build_project(src_path, build_path, target, toolchain_name, libraries_paths=None, options=None, linker_script=None, clean=False, notify=None, verbose=False, name=None, macros=None, inc_dirs=None, - jobs=1, silent=False, report=None, properties=None, project_id=None, project_description=None): + jobs=1, silent=False, report=None, properties=None, project_id=None, project_description=None, extra_verbose=False): """ This function builds project. Project can be for example one test / UT """ # Toolchain instance - toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, notify, macros, silent) + toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, notify, macros, silent, extra_verbose=extra_verbose) toolchain.VERBOSE = verbose toolchain.jobs = jobs toolchain.build_all = clean @@ -100,17 +100,17 @@ def build_project(src_path, build_path, target, toolchain_name, # User used custom global project name to have the same name for the toolchain.info("Building project %s to %s (%s, %s)" % (PROJECT_BASENAME.upper(), name, target.name, toolchain_name)) - start = time() - id_name = project_id.upper() - description = project_description - cur_result = None if report != None: + start = time() + id_name = project_id.upper() + description = project_description + cur_result = None prep_report(report, target.name, toolchain_name, id_name) cur_result = create_result(target.name, toolchain_name, id_name, description) - if properties != None: - prep_properties(properties, target.name, toolchain_name, id_name) + if properties != None: + prep_properties(properties, target.name, toolchain_name, id_name) try: # Scan src_path and libraries_paths for resources @@ -158,17 +158,18 @@ def build_project(src_path, build_path, target, toolchain_name, return res except Exception, e: - end = time() - cur_result["result"] = "FAIL" - cur_result["elapsed_time"] = end - start + if report != None: + end = time() + cur_result["result"] = "FAIL" + cur_result["elapsed_time"] = end - start - toolchain_output = toolchain.get_output() - if toolchain_output: - cur_result["output"] += toolchain_output + toolchain_output = toolchain.get_output() + if toolchain_output: + cur_result["output"] += toolchain_output - cur_result["output"] += str(e) + cur_result["output"] += str(e) - add_result_to_report(report, cur_result) + add_result_to_report(report, cur_result) # Let Exception propagate raise e @@ -177,7 +178,7 @@ def build_project(src_path, build_path, target, toolchain_name, def build_library(src_paths, build_path, target, toolchain_name, dependencies_paths=None, options=None, name=None, clean=False, notify=None, verbose=False, macros=None, inc_dirs=None, inc_dirs_ext=None, - jobs=1, silent=False, report=None, properties=None): + jobs=1, silent=False, report=None, properties=None, extra_verbose=False): """ src_path: the path of the source directory build_path: the path of the build directory target: ['LPC1768', 'LPC11U24', 'LPC2368'] @@ -195,17 +196,16 @@ def build_library(src_paths, build_path, target, toolchain_name, # The first path will give the name to the library name = basename(src_paths[0]) - start = time() - id_name = name.upper() - description = name - cur_result = None - if report != None: + start = time() + id_name = name.upper() + description = name + cur_result = None prep_report(report, target.name, toolchain_name, id_name) cur_result = create_result(target.name, toolchain_name, id_name, description) - if properties != None: - prep_properties(properties, target.name, toolchain_name, id_name) + if properties != None: + prep_properties(properties, target.name, toolchain_name, id_name) for src_path in src_paths: if not exists(src_path): @@ -220,7 +220,7 @@ def build_library(src_paths, build_path, target, toolchain_name, try: # Toolchain instance - toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, macros=macros, notify=notify, silent=silent) + toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, macros=macros, notify=notify, silent=silent, extra_verbose=extra_verbose) toolchain.VERBOSE = verbose toolchain.jobs = jobs toolchain.build_all = clean @@ -293,7 +293,7 @@ def build_library(src_paths, build_path, target, toolchain_name, # Let Exception propagate raise e -def build_lib(lib_id, target, toolchain, options=None, verbose=False, clean=False, macros=None, notify=None, jobs=1, silent=False, report=None, properties=None): +def build_lib(lib_id, target, toolchain, options=None, verbose=False, clean=False, macros=None, notify=None, jobs=1, silent=False, report=None, properties=None, extra_verbose=False): """ Wrapper for build_library function. Function builds library in proper directory using all dependencies and macros defined by user. """ @@ -314,26 +314,27 @@ def build_lib(lib_id, target, toolchain, options=None, verbose=False, clean=Fals inc_dirs_ext=lib.inc_dirs_ext, jobs=jobs, report=report, - properties=properties) + properties=properties, + extra_verbose=extra_verbose) else: print 'Library "%s" is not yet supported on target %s with toolchain %s' % (lib_id, target.name, toolchain) return False # We do have unique legacy conventions about how we build and package the mbed library -def build_mbed_libs(target, toolchain_name, options=None, verbose=False, clean=False, macros=None, notify=None, jobs=1, silent=False, report=None, properties=None): +def build_mbed_libs(target, toolchain_name, options=None, verbose=False, clean=False, macros=None, notify=None, jobs=1, silent=False, report=None, properties=None, extra_verbose=False): """ Function returns True is library was built and false if building was skipped """ - start = time() - id_name = "MBED" - description = "mbed SDK" - cur_result = None if report != None: + start = time() + id_name = "MBED" + description = "mbed SDK" + cur_result = None prep_report(report, target.name, toolchain_name, id_name) cur_result = create_result(target.name, toolchain_name, id_name, description) - if properties != None: - prep_properties(properties, target.name, toolchain_name, id_name) + if properties != None: + prep_properties(properties, target.name, toolchain_name, id_name) # Check toolchain support if toolchain_name not in target.supported_toolchains: @@ -349,7 +350,7 @@ def build_mbed_libs(target, toolchain_name, options=None, verbose=False, clean=F try: # Toolchain - toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, macros=macros, notify=notify, silent=silent) + toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, macros=macros, notify=notify, silent=silent, extra_verbose=extra_verbose) toolchain.VERBOSE = verbose toolchain.jobs = jobs toolchain.build_all = clean @@ -500,9 +501,9 @@ def get_target_supported_toolchains(target): return TARGET_MAP[target].supported_toolchains if target in TARGET_MAP else None -def static_analysis_scan(target, toolchain_name, CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, options=None, verbose=False, clean=False, macros=None, notify=None, jobs=1): +def static_analysis_scan(target, toolchain_name, CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, options=None, verbose=False, clean=False, macros=None, notify=None, jobs=1, extra_verbose=False): # Toolchain - toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, macros=macros, notify=notify) + toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, macros=macros, notify=notify, extra_verbose=extra_verbose) toolchain.VERBOSE = verbose toolchain.jobs = jobs toolchain.build_all = clean @@ -613,19 +614,19 @@ def static_analysis_scan(target, toolchain_name, CPPCHECK_CMD, CPPCHECK_MSG_FORM def static_analysis_scan_lib(lib_id, target, toolchain, cppcheck_cmd, cppcheck_msg_format, - options=None, verbose=False, clean=False, macros=None, notify=None, jobs=1): + options=None, verbose=False, clean=False, macros=None, notify=None, jobs=1, extra_verbose=False): lib = Library(lib_id) if lib.is_supported(target, toolchain): static_analysis_scan_library(lib.source_dir, lib.build_dir, target, toolchain, cppcheck_cmd, cppcheck_msg_format, lib.dependencies, options, - verbose=verbose, clean=clean, macros=macros, notify=notify, jobs=jobs) + verbose=verbose, clean=clean, macros=macros, notify=notify, jobs=jobs, extra_verbose=extra_verbose) else: print 'Library "%s" is not yet supported on target %s with toolchain %s'% (lib_id, target.name, toolchain) def static_analysis_scan_library(src_paths, build_path, target, toolchain_name, cppcheck_cmd, cppcheck_msg_format, dependencies_paths=None, options=None, name=None, clean=False, - notify=None, verbose=False, macros=None, jobs=1): + notify=None, verbose=False, macros=None, jobs=1, extra_verbose=False): """ Function scans library (or just some set of sources/headers) for staticly detectable defects """ if type(src_paths) != ListType: src_paths = [src_paths] @@ -635,7 +636,7 @@ def static_analysis_scan_library(src_paths, build_path, target, toolchain_name, raise Exception("The library source folder does not exist: %s", src_path) # Toolchain instance - toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, macros=macros, notify=notify) + toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, macros=macros, notify=notify, extra_verbose=extra_verbose) toolchain.VERBOSE = verbose toolchain.jobs = jobs diff --git a/workspace_tools/toolchains/__init__.py b/workspace_tools/toolchains/__init__.py index 9e1596f96f..6e9e8c53b8 100644 --- a/workspace_tools/toolchains/__init__.py +++ b/workspace_tools/toolchains/__init__.py @@ -180,7 +180,7 @@ class mbedToolchain: GOANNA_FORMAT = "[Goanna] warning [%FILENAME%:%LINENO%] - [%CHECKNAME%(%SEVERITY%)] %MESSAGE%" GOANNA_DIAGNOSTIC_PATTERN = re.compile(r'"\[Goanna\] (?Pwarning) \[(?P[^:]+):(?P\d+)\] \- (?P.*)"') - def __init__(self, target, options=None, notify=None, macros=None, silent=False): + def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False): self.target = target self.name = self.__class__.__name__ self.hook = hooks.Hook(target, self) @@ -189,7 +189,13 @@ class mbedToolchain: self.legacy_ignore_dirs = LEGACY_IGNORE_DIRS - set([target.name, LEGACY_TOOLCHAIN_NAMES[self.name]]) - self.notify_fun = notify if notify is not None else self.print_notify + if notify: + self.notify_fun = notify + elif extra_verbose: + self.notify_fun = self.print_notify_verbose + else: + self.notify_fun = self.print_notify + self.options = options if options is not None else [] self.macros = macros or [] diff --git a/workspace_tools/toolchains/arm.py b/workspace_tools/toolchains/arm.py index 36cddd042d..19baf30ec9 100644 --- a/workspace_tools/toolchains/arm.py +++ b/workspace_tools/toolchains/arm.py @@ -30,8 +30,8 @@ class ARM(mbedToolchain): DIAGNOSTIC_PATTERN = re.compile('"(?P[^"]+)", line (?P\d+)( \(column (?P\d+)\)|): (?PWarning|Error): (?P.+)') DEP_PATTERN = re.compile('\S+:\s(?P.+)\n') - def __init__(self, target, options=None, notify=None, macros=None, silent=False): - mbedToolchain.__init__(self, target, options, notify, macros, silent) + def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False): + mbedToolchain.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose) if target.core == "Cortex-M0+": cpu = "Cortex-M0" @@ -118,10 +118,10 @@ class ARM(mbedToolchain): match.group('line'), match.group('message') ) - + def get_dep_opt(self, dep_path): return ["--depend", dep_path] - + def archive(self, objects, lib_path): self.default_cmd([self.ar, '-r', lib_path] + objects) @@ -149,8 +149,8 @@ class ARM(mbedToolchain): self.default_cmd(args) class ARM_STD(ARM): - def __init__(self, target, options=None, notify=None, macros=None, silent=False): - ARM.__init__(self, target, options, notify, macros, silent) + def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False): + ARM.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose) self.cc += ["-D__ASSERT_MSG"] self.cppc += ["-D__ASSERT_MSG"] self.ld.append("--libpath=%s" % ARM_LIB) @@ -159,8 +159,8 @@ class ARM_STD(ARM): class ARM_MICRO(ARM): PATCHED_LIBRARY = False - def __init__(self, target, options=None, notify=None, macros=None, silent=False): - ARM.__init__(self, target, options, notify, macros, silent) + def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False): + ARM.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose) # Compiler self.asm += ["-D__MICROLIB"] diff --git a/workspace_tools/toolchains/gcc.py b/workspace_tools/toolchains/gcc.py index d6746ccc4b..3c1a7c0b4f 100644 --- a/workspace_tools/toolchains/gcc.py +++ b/workspace_tools/toolchains/gcc.py @@ -30,8 +30,8 @@ class GCC(mbedToolchain): CIRCULAR_DEPENDENCIES = True DIAGNOSTIC_PATTERN = re.compile('((?P\d+):)(\d+:)? (?Pwarning|error): (?P.+)') - def __init__(self, target, options=None, notify=None, macros=None, silent=False, tool_path=""): - mbedToolchain.__init__(self, target, options, notify, macros, silent) + def __init__(self, target, options=None, notify=None, macros=None, silent=False, tool_path="", extra_verbose=False): + mbedToolchain.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose) if target.core == "Cortex-M0+": cpu = "cortex-m0plus" @@ -179,8 +179,8 @@ class GCC(mbedToolchain): class GCC_ARM(GCC): - def __init__(self, target, options=None, notify=None, macros=None, silent=False): - GCC.__init__(self, target, options, notify, macros, silent, GCC_ARM_PATH) + def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False): + GCC.__init__(self, target, options, notify, macros, silent, GCC_ARM_PATH, extra_verbose=extra_verbose) # Use latest gcc nanolib self.ld.append("--specs=nano.specs") @@ -193,8 +193,8 @@ class GCC_ARM(GCC): class GCC_CR(GCC): - def __init__(self, target, options=None, notify=None, macros=None, silent=False): - GCC.__init__(self, target, options, notify, macros, silent, GCC_CR_PATH) + def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False): + GCC.__init__(self, target, options, notify, macros, silent, GCC_CR_PATH, extra_verbose=extra_verbose) additional_compiler_flags = [ "-D__NEWLIB__", "-D__CODE_RED", "-D__USE_CMSIS", "-DCPP_USE_HEAP", @@ -210,8 +210,8 @@ class GCC_CR(GCC): class GCC_CS(GCC): - def __init__(self, target, options=None, notify=None, macros=None, silent=False): - GCC.__init__(self, target, options, notify, macros, silent, GCC_CS_PATH) + def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False): + GCC.__init__(self, target, options, notify, macros, silent, GCC_CS_PATH, extra_verbose=extra_verbose) class GCC_CW(GCC): @@ -219,13 +219,13 @@ class GCC_CW(GCC): "Cortex-M0+": "armv6-m", } - def __init__(self, target, options=None, notify=None, macros=None, silent=False): - GCC.__init__(self, target, options, notify, macros, silent, CW_GCC_PATH) + def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False): + GCC.__init__(self, target, options, notify, macros, silent, CW_GCC_PATH, extra_verbose=extra_verbose) class GCC_CW_EWL(GCC_CW): - def __init__(self, target, options=None, notify=None, macros=None, silent=False): - GCC_CW.__init__(self, target, options, notify, macros, silent) + def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False): + GCC_CW.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose) # Compiler common = [ @@ -253,5 +253,5 @@ class GCC_CW_EWL(GCC_CW): class GCC_CW_NEWLIB(GCC_CW): - def __init__(self, target, options=None, notify=None, macros=None, silent=False): - GCC_CW.__init__(self, target, options, notify, macros, silent) + def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False): + GCC_CW.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose) diff --git a/workspace_tools/toolchains/iar.py b/workspace_tools/toolchains/iar.py index 6aa8539656..594391f1bb 100644 --- a/workspace_tools/toolchains/iar.py +++ b/workspace_tools/toolchains/iar.py @@ -30,8 +30,8 @@ class IAR(mbedToolchain): DIAGNOSTIC_PATTERN = re.compile('"(?P[^"]+)",(?P[\d]+)\s+(?PWarning|Error)(?P.+)') - def __init__(self, target, options=None, notify=None, macros=None, silent=False): - mbedToolchain.__init__(self, target, options, notify, macros, silent) + def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False): + mbedToolchain.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose) c_flags = [ "--cpu=%s" % target.core, "--thumb", @@ -94,7 +94,7 @@ class IAR(mbedToolchain): def parse_dependencies(self, dep_path): return [path.strip() for path in open(dep_path).readlines() if (path and not path.isspace())] - + def assemble(self, source, object, includes): return [self.hook.get_cmdline_assembler(self.asm + ['-D%s' % s for s in self.get_symbols() + self.macros] + ["-I%s" % i for i in includes] + ["-o", object, source])]