diff --git a/tools/export/sw4stm32.py b/tools/export/sw4stm32.py index 3b52cafbe9e..fa38f53abe8 100644 --- a/tools/export/sw4stm32.py +++ b/tools/export/sw4stm32.py @@ -18,7 +18,6 @@ from os.path import splitext, basename, join from random import randint from tools.utils import mkdir -from targets import Target class Sw4STM32(Exporter): @@ -80,7 +79,7 @@ def __generate_uid(self): def generate(self): fp_hardware = "no" fp_abi = "soft" - core = Target.get_target(self.target).core + core = self.target.core if core == "Cortex-M4F" or core == "Cortex-M7F": fp_hardware = "fpv4-sp-d16" fp_abi = "soft-fp" diff --git a/tools/export/uvision4.py b/tools/export/uvision4.py index 1bc41e46a96..02c630f26d1 100644 --- a/tools/export/uvision4.py +++ b/tools/export/uvision4.py @@ -19,6 +19,7 @@ from tools.export.exporters import Exporter, ExporterTargetsProperty from tools.targets import TARGET_MAP, TARGET_NAMES +from tools.utils import remove_if_in # If you wish to add a new target, add it to project_generator_definitions, and then # define progen_target name in the target class (`` self.progen_target = 'my_target_name' ``) @@ -87,11 +88,11 @@ def generate(self): + self.flags['c_flags'] + self.flags['cxx_flags'])) # not compatible with c99 flag set in the template - project_data['misc']['c_flags'].remove("--c99") + remove_if_in(project_data['misc']['c_flags'], "--c99") # cpp is not required as it's implicit for cpp files - project_data['misc']['c_flags'].remove("--cpp") + remove_if_in(project_data['misc']['c_flags'], "--cpp") # we want no-vla for only cxx, but it's also applied for C in IDE, thus we remove it - project_data['misc']['c_flags'].remove("--no_vla") + remove_if_in(project_data['misc']['c_flags'], "--no_vla") project_data['misc']['ld_flags'] = self.flags['ld_flags'] project_data['build_dir'] = project_data['build_dir'] + '\\' + 'uvision4' diff --git a/tools/export/uvision5.py b/tools/export/uvision5.py index 5eb08a58039..5b4a6756e07 100644 --- a/tools/export/uvision5.py +++ b/tools/export/uvision5.py @@ -19,6 +19,7 @@ from tools.export.exporters import Exporter, ExporterTargetsProperty from tools.targets import TARGET_MAP, TARGET_NAMES +from tools.utils import remove_if_in # If you wish to add a new target, add it to project_generator_definitions, and then # define progen_target name in the target class (`` self.progen_target = 'my_target_name' ``) @@ -83,11 +84,12 @@ def generate(self): + self.flags['c_flags'] + self.flags['cxx_flags'])) # not compatible with c99 flag set in the template - project_data['misc']['c_flags'].remove("--c99") + remove_if_in(project_data['misc']['c_flags'], "--c99") # cpp is not required as it's implicit for cpp files - project_data['misc']['c_flags'].remove("--cpp") + remove_if_in(project_data['misc']['c_flags'], "--cpp") # we want no-vla for only cxx, but it's also applied for C in IDE, thus we remove it - project_data['misc']['c_flags'].remove("--no_vla") + remove_if_in(project_data['misc']['c_flags'], "--no_vla") + # not compatible with c99 flag set in the template project_data['misc']['ld_flags'] = self.flags['ld_flags'] i = 0 diff --git a/tools/project.py b/tools/project.py index 1b7cd885b82..c75e7a94b41 100644 --- a/tools/project.py +++ b/tools/project.py @@ -10,7 +10,7 @@ from argparse import ArgumentParser from os.path import normpath, realpath -from tools.paths import EXPORT_DIR, MBED_BASE, MBED_LIBRARIES +from tools.paths import EXPORT_DIR, MBED_HAL, MBED_LIBRARIES from tools.export import EXPORTERS, mcu_ide_matrix from tools.tests import TESTS, TEST_MAP from tools.tests import test_known, test_name_known, Test @@ -18,7 +18,7 @@ from tools.utils import argparse_filestring_type, argparse_many, args_error from tools.utils import argparse_force_lowercase_type from tools.utils import argparse_force_uppercase_type -from tools.project_api import export_project +from tools.project_api import export_project, get_exporter_toolchain from tools.options import extract_profile @@ -53,7 +53,8 @@ def setup_project(ide, target, program=None, source_dir=None, build=None, export # Substitute the mbed library builds with their sources if MBED_LIBRARIES in test.dependencies: test.dependencies.remove(MBED_LIBRARIES) - test.dependencies.append(MBED_BASE) + test.dependencies.append(MBED_HAL) + src_paths = [test.source_dir] lib_paths = test.dependencies diff --git a/tools/test/export/build_test.py b/tools/test/export/build_test.py index 4d3e99e02f6..3d8b284b9ba 100644 --- a/tools/test/export/build_test.py +++ b/tools/test/export/build_test.py @@ -36,12 +36,14 @@ from tools.project import export from Queue import Queue from threading import Thread, Lock -from tools.project_api import print_results +from tools.project_api import print_results, get_exporter_toolchain from tools.tests import test_name_known, test_known, Test from tools.export.exporters import FailedBuildException, \ TargetNotSupportedException from tools.utils import argparse_force_lowercase_type, \ - argparse_many, columnate, args_error + argparse_many, columnate, args_error, \ + argparse_filestring_type +from tools.options import extract_profile print_lock = Lock() @@ -72,13 +74,15 @@ def start(self) : class ExportBuildTest(object): """Object to encapsulate logic for progen build testing""" - def __init__(self, tests): + def __init__(self, tests, parser, options): """ Initialize an instance of class ProgenBuildTest Args: tests: array of TestCase instances """ self.total = len(tests) + self.parser = parser + self.options = options self.counter = 0 self.successes = [] self.failures = [] @@ -155,11 +159,13 @@ def perform_exports(self, test_case): test_case.name)) try: + _, toolchain = get_exporter_toolchain(test_case.ide) + profile = extract_profile(self.parser, self.options, toolchain) exporter = export(test_case.mcu, test_case.ide, project_id=test_case.id, zip_proj=None, clean=True, src=test_case.src, export_path=join(EXPORT_DIR,name_str), - silent=True) + silent=True, build_profile=profile) exporter.generated_files.append(join(EXPORT_DIR,name_str,test_case.log)) self.build_queue.put((exporter,test_case)) except TargetNotSupportedException: @@ -243,6 +249,12 @@ def main(): help="Which version of mbed to test", default=RELEASE_VERSIONS[-1]) + parser.add_argument("--profile", + dest="profile", + action="append", + type=argparse_filestring_type, + default=[]) + options = parser.parse_args() # targets in chosen release targetnames = [target[0] for target in @@ -273,7 +285,7 @@ def main(): for test in v5_tests: default_test.update({'name':test[0],'src':[test[1],ROOT]}) tests.append(copy(default_test)) - test = ExportBuildTest(tests) + test = ExportBuildTest(tests, parser, options) test.batch_tests(clean=options.clean) print_results(test.successes, test.failures, test.skips) sys.exit(len(test.failures)) diff --git a/tools/utils.py b/tools/utils.py index b250491dc0c..9ad74de63dd 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -28,6 +28,10 @@ from collections import OrderedDict import logging +def remove_if_in(lst, thing): + if thing in lst: + lst.remove(thing) + def compile_worker(job): """Standard task runner used for compiling