def benchmarks(): # CSV Data csv_data = csv.writer(open(BENCHMARK_DATA_PATH, 'wb')) csv_data.writerow( ['Toolchain', "Target", "Benchmark", "code", "data", "bss", "flash"]) # Build for toolchain in ['ARM', 'uARM', 'GCC_CR', 'GCC_ARM']: for mcu in ["LPC1768", "LPC11U24"]: # Build Libraries build_mbed_libs(mcu, toolchain) # Build benchmarks build_dir = join(BUILD_DIR, "benchmarks", mcu, toolchain) for test_id, title in BENCHMARKS: # Build Benchmark try: test = TEST_MAP[test_id] path = build_project(test.source_dir, join(build_dir, test_id), mcu, toolchain, test.dependencies) base, ext = splitext(path) # Check Size code, data, bss, flash = get_size(base + '.elf') csv_data.writerow( [toolchain, mcu, title, code, data, bss, flash]) except Exception, e: print "Unable to build %s for toolchain %s targeting %s" % ( test_id, toolchain, mcu) print e
def benchmarks(): # CSV Data csv_data = csv.writer(open(BENCHMARK_DATA_PATH, 'wb')) csv_data.writerow(['Toolchain', "Target", "Benchmark", "code", "data", "bss", "flash"]) # Build for toolchain in ['ARM', 'uARM', 'GCC_CR', 'GCC_ARM']: for mcu in ["LPC1768", "LPC11U24"]: # Build Libraries build_mbed_libs(mcu, toolchain) # Build benchmarks build_dir = join(BUILD_DIR, "benchmarks", mcu, toolchain) for test_id, title in BENCHMARKS: # Build Benchmark try: test = TEST_MAP[test_id] path = build_project(test.source_dir, join(build_dir, test_id), mcu, toolchain, test.dependencies) base, ext = splitext(path) # Check Size code, data, bss, flash = get_size(base+'.elf') csv_data.writerow([toolchain, mcu, title, code, data, bss, flash]) except Exception, e: print "Unable to build %s for toolchain %s targeting %s" % (test_id, toolchain, mcu) print e
if options.verbose: import traceback traceback.print_exc(file=sys.stdout) sys.exit(1) print e else: # Build for toolchain in toolchains: for target in targets: 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:
if options.source_dir: lib_build_res = build_library(options.source_dir, options.build_dir, mcu, toolchain, options=options.options, extra_verbose=options.extra_verbose_notify, verbose=options.verbose, silent=options.silent, jobs=options.jobs, clean=options.clean, archive=(not options.no_archive), macros=options.macros, 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)
options.source_dir, options.build_dir, mcu, toolchain, 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, ) 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:
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: toolchains = toolchain_list if options.toolchains: print("Building using the following toolchains: {}".format( options.toolchains)) toolchainSet = set(toolchains) toolchains = toolchainSet.intersection( set((options.toolchains).split(','))) for toolchain in toolchains: built_mbed_lib = build_mbed_libs( TARGET_MAP[target_name], toolchain, notify=TerminalNotifier(options.verbose), jobs=options.jobs, report=build_report, properties=build_properties, build_profile=extract_profile(parser, options, toolchain), ) # copy targets.json file as part of the release copy(join(dirname(abspath(__file__)), '..', 'targets', 'targets.json'), MBED_LIBRARIES) # Write summary of the builds if options.report_build_file_name: file_report_exporter = ReportExporter(ResultExporterType.JUNIT, package="build") file_report_exporter.report_to_file( build_report,
if options.toolchains: print "Only building using the following toolchains: %s" % (options.toolchains) toolchainSet = set(toolchains) toolchains = toolchainSet.intersection(set((options.toolchains).split(','))) for toolchain in toolchains: id = "%s::%s" % (target_name, toolchain) profile = extract_profile(parser, options, toolchain) try: built_mbed_lib = build_mbed_libs(TARGET_MAP[target_name], toolchain, verbose=options.verbose, jobs=options.jobs, report=build_report, properties=build_properties, build_profile=profile) except Exception, e: print str(e) # copy targets.json file as part of the release copy(join(dirname(abspath(__file__)), '..', 'targets', 'targets.json'), MBED_LIBRARIES) # Write summary of the builds if options.report_build_file_name: file_report_exporter = ReportExporter(ResultExporterType.JUNIT, package="build") file_report_exporter.report_to_file(build_report, options.report_build_file_name, test_suite_properties=build_properties)
if options.toolchains: print "Only building using the following toolchains: %s" % ( options.toolchains) toolchainSet = set(toolchains) toolchains = toolchainSet.intersection( set((options.toolchains).split(','))) for toolchain in toolchains: id = "%s::%s" % (target_name, toolchain) try: built_mbed_lib = build_mbed_libs( TARGET_MAP[target_name], toolchain, verbose=options.verbose, jobs=options.jobs, report=build_report, properties=build_properties) except Exception, e: print str(e) # Write summary of the builds if options.report_build_file_name: file_report_exporter = ReportExporter(ResultExporterType.JUNIT, package="build") file_report_exporter.report_to_file( build_report, options.report_build_file_name, test_suite_properties=build_properties)
options.toolchains) toolchainSet = set(toolchains) toolchains = toolchainSet.intersection( set((options.toolchains).split(','))) for toolchain in toolchains: id = "%s::%s" % (target_name, toolchain) profile = extract_profile(parser, options, toolchain) notify = TerminalNotifier(options.verbose) try: built_mbed_lib = build_mbed_libs( TARGET_MAP[target_name], toolchain, notify=notify, jobs=options.jobs, report=build_report, properties=build_properties, build_profile=profile) except Exception, e: print str(e) # copy targets.json file as part of the release copy(join(dirname(abspath(__file__)), '..', 'targets', 'targets.json'), MBED_LIBRARIES) # Write summary of the builds if options.report_build_file_name: file_report_exporter = ReportExporter(ResultExporterType.JUNIT, package="build")