tt_id = "%s::%s" % (toolchain, target) try: mcu = TARGET_MAP[target] lib_build_res = build_mbed_libs(mcu, toolchain, options=options.options, 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: build_lib(lib_id, mcu, toolchain, options=options.options, extra_verbose=options.extra_verbose_notify, verbose=options.verbose, silent=options.silent, clean=options.clean, macros=options.macros, jobs=options.jobs) if lib_build_res: successes.append(tt_id) else: skipped.append(tt_id) except Exception, e: if options.verbose: import traceback traceback.print_exc(file=sys.stdout) sys.exit(1) failures.append(tt_id) print e
name=options.artifact_name) else: lib_build_res = build_mbed_libs(mcu, toolchain, options=options.options, 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: build_lib(lib_id, mcu, toolchain, options=options.options, extra_verbose=options.extra_verbose_notify, verbose=options.verbose, silent=options.silent, clean=options.clean, macros=options.macros, jobs=options.jobs) if lib_build_res: successes.append(tt_id) else: skipped.append(tt_id) except Exception, e: if options.verbose: import traceback traceback.print_exc(file=sys.stdout) sys.exit(1) failures.append(tt_id) print e
def main(): start = time() # Parse Options parser = get_default_options_parser() parser.add_argument("--source", dest="source_dir", type=argparse_filestring_type, default=None, help="The source (input) directory", action="append") parser.add_argument("--build", dest="build_dir", type=argparse_dir_not_parent(ROOT), default=None, help="The build (output) directory") parser.add_argument("--no-archive", dest="no_archive", action="store_true", default=False, help="Do not produce archive (.ar) file, but rather .o") # Extra libraries parser.add_argument("-r", "--rtos", action="store_true", dest="rtos", default=False, help="Compile the rtos") parser.add_argument("--rpc", action="store_true", dest="rpc", default=False, help="Compile the rpc library") parser.add_argument("-u", "--usb", action="store_true", dest="usb", default=False, help="Compile the USB Device library") parser.add_argument("-d", "--dsp", action="store_true", dest="dsp", default=False, help="Compile the DSP library") parser.add_argument( "--cpputest", action="store_true", dest="cpputest_lib", default=False, help="Compiles 'cpputest' unit test library (library should be on the same directory level as mbed repository)") parser.add_argument("-D", action="append", dest="macros", help="Add a macro definition") parser.add_argument("-S", "--supported-toolchains", action="store_true", dest="supported_toolchains", default=False, help="Displays supported matrix of MCUs and toolchains") parser.add_argument('-f', '--filter', dest='general_filter_regex', default=None, help='For some commands you can use filter to filter out results') parser.add_argument("-j", "--jobs", type=int, dest="jobs", default=0, help="Number of concurrent jobs. Default: 0/auto (based on host machine's number of CPUs)") parser.add_argument("-N", "--artifact-name", dest="artifact_name", default=None, help="The built project's name") parser.add_argument("-v", "--verbose", action="store_true", dest="verbose", default=False, help="Verbose diagnostic output") parser.add_argument("--silent", action="store_true", dest="silent", default=False, help="Silent diagnostic output (no copy, compile notification)") parser.add_argument("-x", "--extra-verbose-notifications", action="store_true", dest="extra_verbose_notify", default=False, help="Makes compiler more verbose, CI friendly.") parser.add_argument("--ignore", dest="ignore", type=argparse_many(str), default=None, help="Comma separated list of patterns to add to mbedignore (eg. ./main.cpp)") options = parser.parse_args() # Only prints matrix of supported toolchains if options.supported_toolchains: print(mcu_toolchain_matrix(platform_filter=options.general_filter_regex)) exit(0) # Get target list targets = extract_mcus(parser, options) if options.mcu else TARGET_NAMES # Get toolchains list toolchains = options.tool if options.tool else TOOLCHAINS if options.source_dir and not options.build_dir: args_error(parser, "argument --build is required by argument --source") # Get libraries list libraries = [] # Additional Libraries if options.rpc: libraries.extend(["rpc"]) if options.usb: libraries.append("usb") if options.dsp: libraries.extend(["dsp"]) if options.cpputest_lib: libraries.extend(["cpputest"]) # Build results failures = [] successes = [] skipped = [] end_warnings = [] if options.clean: clean_psa_autogen() for toolchain in toolchains: for target_name in targets: target = Target.get_target(target_name) try: toolchain_name, internal_tc_name, end_warnings = find_valid_toolchain( target, toolchain ) except NoValidToolchainException as e: print_end_warnings(e.end_warnings) args_error(parser, str(e)) tt_id = "%s::%s" % (internal_tc_name, target_name) if not target_supports_toolchain(target, toolchain_name): # Log this later print("%s skipped: toolchain not supported" % tt_id) skipped.append(tt_id) else: try: notifier = TerminalNotifier(options.verbose, options.silent) profile = extract_profile(parser, options, internal_tc_name) if options.source_dir: if target.is_PSA_target: generate_psa_sources( source_dirs=options.source_dir, ignore_paths=[options.build_dir] ) resource_filter = None if target.is_PSA_secure_target: resource_filter = OsAndSpeResourceFilter() lib_build_res = build_library( options.source_dir, options.build_dir, target, toolchain_name, jobs=options.jobs, clean=options.clean, archive=(not options.no_archive), macros=options.macros, name=options.artifact_name, build_profile=profile, ignore=options.ignore, notify=notifier, resource_filter=resource_filter ) else: lib_build_res = build_mbed_libs( target, toolchain_name, jobs=options.jobs, clean=options.clean, macros=options.macros, build_profile=profile, ignore=options.ignore, notify=notifier, ) for lib_id in libraries: build_lib( lib_id, target, toolchain_name, clean=options.clean, macros=options.macros, jobs=options.jobs, build_profile=profile, ignore=options.ignore, ) if lib_build_res: successes.append(tt_id) else: skipped.append(tt_id) except KeyboardInterrupt as e: print("\n[CTRL+c] exit") print_end_warnings(end_warnings) sys.exit(0) except Exception as e: if options.verbose: import traceback traceback.print_exc(file=sys.stdout) print_end_warnings(end_warnings) sys.exit(1) failures.append(tt_id) print(e) # Write summary of the builds print("\nCompleted in: (%.2f)s\n" % (time() - start)) for report, report_name in [(successes, "Build successes:"), (skipped, "Build skipped:"), (failures, "Build failures:"), ]: if report: print(print_build_results(report, report_name)) print_end_warnings(end_warnings) if failures: sys.exit(1)
else: lib_build_res = build_mbed_libs( mcu, toolchain, jobs=options.jobs, clean=options.clean, macros=options.macros, build_profile=profile, ignore=options.ignore, notify=notifier, ) for lib_id in libraries: build_lib( lib_id, mcu, toolchain, clean=options.clean, macros=options.macros, jobs=options.jobs, build_profile=profile, ignore=options.ignore, ) if lib_build_res: successes.append(tt_id) else: skipped.append(tt_id) except Exception as e: if options.verbose: import traceback traceback.print_exc(file=sys.stdout) sys.exit(1) failures.append(tt_id) print(e)