def test_build_project_no_app_config(self, mock_prepare_toolchain, mock_exists, _, __): """ Test that build_project correctly deals with no app_config :param mock_prepare_toolchain: mock of function prepare_toolchain :param mock_exists: mock of function os.path.exists :param _: mock of function mkdir (not tested) :param __: mock of function scan_resources (not tested) :return: """ notify = MockNotifier() mock_exists.return_value = False # Needed for the unpacking of the returned value mock_prepare_toolchain().link_program.return_value = 1, 2 mock_prepare_toolchain().config = namedtuple( "Config", "has_regions name lib_config_data")(None, None, {}) build_project(self.src_paths, self.build_path, self.target, self.toolchain_name, notify=notify) args = mock_prepare_toolchain.call_args self.assertTrue('app_config' in args[1], "prepare_toolchain was not called with app_config") self.assertEqual(args[1]['app_config'], None, "prepare_toolchain was called with an incorrect app_config")
def test_build_project_app_config(self, mock_prepare_toolchain, mock_exists, _, __): """ Test that build_project uses app_config correctly :param mock_prepare_toolchain: mock of function prepare_toolchain :param mock_exists: mock of function os.path.exists :param _: mock of function mkdir (not tested) :param __: mock of function scan_resources (not tested) :return: """ app_config = "app_config" mock_exists.return_value = False mock_prepare_toolchain().link_program.return_value = 1, 2 build_project(self.src_paths, self.build_path, self.target, self.toolchain_name, app_config=app_config) args = mock_prepare_toolchain.call_args self.assertTrue('app_config' in args[1], "prepare_toolchain was not called with app_config") self.assertEqual( args[1]['app_config'], app_config, "prepare_toolchain was called with an incorrect app_config")
def test_build_project_app_config(self, mock_prepare_toolchain, mock_exists, _, __): """ Test that build_project uses app_config correctly :param mock_prepare_toolchain: mock of function prepare_toolchain :param mock_exists: mock of function os.path.exists :param _: mock of function mkdir (not tested) :param __: mock of class Resources (not tested) :return: """ notify = MockNotifier() app_config = "app_config" mock_exists.return_value = False mock_prepare_toolchain().link_program.return_value = 1, 2 mock_prepare_toolchain().config = namedtuple( "Config", "has_regions name lib_config_data")(None, None, {}) build_project(self.src_paths, self.build_path, self.target, self.toolchain_name, app_config=app_config, notify=notify) args = mock_prepare_toolchain.call_args self.assertTrue('app_config' in args[1], "prepare_toolchain was not called with app_config") self.assertEqual(args[1]['app_config'], app_config, "prepare_toolchain was called with an incorrect app_config")
def test_build_project_no_app_config(self, mock_prepare_toolchain, mock_exists, _, __): """ Test that build_project correctly deals with no app_config :param mock_prepare_toolchain: mock of function prepare_toolchain :param mock_exists: mock of function os.path.exists :param _: mock of function mkdir (not tested) :param __: mock of function scan_resources (not tested) :return: """ mock_exists.return_value = False # Needed for the unpacking of the returned value mock_prepare_toolchain().link_program.return_value = 1, 2 mock_prepare_toolchain().config = namedtuple("Config", "has_regions name")(None, None) build_project(self.src_paths, self.build_path, self.target, self.toolchain_name) args = mock_prepare_toolchain.call_args self.assertTrue('app_config' in args[1], "prepare_toolchain was not called with app_config") self.assertEqual( args[1]['app_config'], None, "prepare_toolchain was called with an incorrect app_config")
def test_build_project_no_app_config(self, mock_prepare_toolchain, mock_exists, _, __): """ Test that build_project correctly deals with no app_config :param mock_prepare_toolchain: mock of function prepare_toolchain :param mock_exists: mock of function os.path.exists :param _: mock of function mkdir (not tested) :param __: mock of class Resources (not tested) :return: """ notify = MockNotifier() mock_exists.return_value = False # Needed for the unpacking of the returned value mock_prepare_toolchain().link_program.return_value = 1, 2 mock_prepare_toolchain().config = MagicMock( has_regions=None, name=None, lib_config_data=None, ) mock_prepare_toolchain().config.deliver_into.return_value = (None, None) mock_prepare_toolchain().config.name = None build_project(self.src_paths, self.build_path, self.target, self.toolchain_name, notify=notify) args = mock_prepare_toolchain.call_args self.assertTrue('app_config' in args[1], "prepare_toolchain was not called with app_config") self.assertEqual(args[1]['app_config'], None, "prepare_toolchain was called with an incorrect app_config")
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 wrapped_build_project(src_dir, build_dir, mcu, end_warnings, options, *args, **kwargs): error = False try: bin_file, update_file = build_project(src_dir, build_dir, mcu, *args, **kwargs) if update_file: print('Update Image: %s' % update_file) print('Image: %s' % bin_file) except KeyboardInterrupt as e: print("\n[CTRL+c] exit") except NotSupportedException as e: print("\nCould not compile for {}: {}".format(mcu, str(e))) error = True except Exception as e: if options.verbose: import traceback traceback.print_exc(file=sys.stdout) else: print("[ERROR] {}".format(str(e))) error = True print_end_warnings(end_warnings) if error: sys.exit(1)
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 test_build_project_app_config(self, mock_prepare_toolchain, mock_exists, _, __): """ Test that build_project uses app_config correctly :param mock_prepare_toolchain: mock of function prepare_toolchain :param mock_exists: mock of function os.path.exists :param _: mock of function mkdir (not tested) :param __: mock of function scan_resources (not tested) :return: """ app_config = "app_config" mock_exists.return_value = False mock_prepare_toolchain().link_program.return_value = 1, 2 build_project(self.src_paths, self.build_path, self.target, self.toolchain_name, app_config=app_config) args = mock_prepare_toolchain.call_args self.assertTrue('app_config' in args[1], "prepare_toolchain was not called with app_config") self.assertEqual(args[1]['app_config'], app_config, "prepare_toolchain was called with an incorrect app_config")
def wrapped_build_project(src_dir, build_dir, mcu, *args, **kwargs): try: bin_file, update_file = build_project(src_dir, build_dir, mcu, *args, **kwargs) if update_file: print('Update Image: %s' % update_file) print('Image: %s' % bin_file) except KeyboardInterrupt as e: print("\n[CTRL+c] exit") except NotSupportedException as e: print("\nCould not compile for %s: %s" % (mcu, str(e))) except Exception as e: if options.verbose: import traceback traceback.print_exc(file=sys.stdout) else: print("[ERROR] %s" % str(e)) sys.exit(1)
test.source_dir = options.source_dir build_dir = options.source_dir if options.build_dir is not None: build_dir = options.build_dir try: bin_file = build_project(test.source_dir, build_dir, mcu, toolchain, set(test.dependencies), linker_script=options.linker_script, clean=options.clean, verbose=options.verbose, notify=notify, report=build_data_blob, silent=options.silent, macros=options.macros, jobs=options.jobs, name=options.artifact_name, app_config=options.app_config, inc_dirs=[dirname(MBED_LIBRARIES)], build_profile=extract_profile( parser, options, toolchain)) print 'Image: %s' % bin_file if options.disk: # Simple copy to the mbed disk copy(bin_file, options.disk) if options.serial:
if options.testlib: test.dependencies.append(TEST_MBED_LIB) build_dir = join(BUILD_DIR, "test", mcu, toolchain, test.id) if options.source_dir is not None: test.source_dir = options.source_dir build_dir = options.source_dir if options.build_dir is not None: build_dir = options.build_dir try: bin_file = build_project(test.source_dir, build_dir, mcu, toolchain, test.dependencies, options.options, linker_script=options.linker_script, clean=options.clean, verbose=options.verbose, notify=notify, silent=options.silent, macros=options.macros, jobs=options.jobs, name=options.artifact_name, app_config=options.app_config) print 'Image: %s'% bin_file if options.disk: # Simple copy to the mbed disk copy(bin_file, options.disk) if options.serial: # Import pyserial: https://pypi.python.org/pypi/pyserial from serial import Serial sleep(TARGET_MAP[mcu].program_cycle_s)
if options.source_dir is not None: test.source_dir = options.source_dir build_dir = options.source_dir if options.build_dir is not None: build_dir = options.build_dir try: bin_file = build_project(test.source_dir, build_dir, mcu, toolchain, test.dependencies, linker_script=options.linker_script, clean=options.clean, verbose=options.verbose, notify=notify, silent=options.silent, macros=options.macros, jobs=options.jobs, name=options.artifact_name, app_config=options.app_config, inc_dirs=[dirname(MBED_LIBRARIES)], build_profile=extract_profile(parser, options, toolchain)) print 'Image: %s'% bin_file if options.disk: # Simple copy to the mbed disk copy(bin_file, options.disk) if options.serial: # Import pyserial: https://pypi.python.org/pypi/pyserial
if options.source_dir is not None: test.source_dir = options.source_dir build_dir = options.source_dir if options.build_dir is not None: build_dir = options.build_dir try: bin_file = build_project(test.source_dir, build_dir, mcu, toolchain, set(test.dependencies), linker_script=options.linker_script, clean=options.clean, notify=notify, report=build_data_blob, macros=options.macros, jobs=options.jobs, name=options.artifact_name, app_config=options.app_config, inc_dirs=[dirname(MBED_LIBRARIES)], build_profile=extract_profile(parser, options, toolchain), stats_depth=options.stats_depth, ignore=options.ignore) print('Image: %s'% bin_file) if options.disk: # Simple copy to the mbed disk copy(bin_file, options.disk) if options.serial: # Import pyserial: https://pypi.python.org/pypi/pyserial
if options.ublox: test.dependencies.append(UBLOX_LIBRARY) if options.testlib: test.dependencies.append(TEST_MBED_LIB) build_dir = join(BUILD_DIR, "test", mcu, toolchain, test.id) if options.source_dir is not None: test.source_dir = options.source_dir build_dir = options.source_dir if options.build_dir is not None: build_dir = options.build_dir try: bin_file = build_project(test.source_dir, build_dir, mcu, toolchain, test.dependencies, options.options, linker_script=options.linker_script, clean=options.clean, verbose=options.verbose, silent=options.silent, macros=options.macros, jobs=options.jobs, name=options.artifact_name) print 'Image: %s'% bin_file if options.disk: # Simple copy to the mbed disk copy(bin_file, options.disk) if options.serial: # Import pyserial: https://pypi.python.org/pypi/pyserial from serial import Serial sleep(TARGET_MAP[mcu].program_cycle_s())
build_dir = join(BUILD_DIR, "test", mcu, toolchain, test.id) if options.source_dir is not None: test.source_dir = options.source_dir build_dir = options.source_dir if options.build_dir is not None: build_dir = options.build_dir target = TARGET_MAP[mcu] try: bin_file = build_project(test.source_dir, build_dir, target, toolchain, test.dependencies, options.options, linker_script=options.linker_script, clean=options.clean, verbose=options.verbose, silent=options.silent, macros=options.macros, jobs=options.jobs) print 'Image: %s' % bin_file if options.disk: # Simple copy to the mbed disk copy(bin_file, options.disk) if options.serial: # Import pyserial: https://pypi.python.org/pypi/pyserial from serial import Serial