mirror of https://github.com/ARMmbed/mbed-os.git
				
				
				
			Front-end scripts now use the ARM toolchain fallback.
Some unused imports were removed as well as some general clean up.pull/10193/head
							parent
							
								
									04e90c278c
								
							
						
					
					
						commit
						2b4960bffe
					
				| 
						 | 
				
			
			@ -29,24 +29,24 @@ ROOT = abspath(join(dirname(__file__), ".."))
 | 
			
		|||
sys.path.insert(0, ROOT)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
from tools.toolchains import TOOLCHAINS, TOOLCHAIN_CLASSES, TOOLCHAIN_PATHS
 | 
			
		||||
from tools.toolchains import mbedToolchain
 | 
			
		||||
from tools.targets import TARGET_NAMES, TARGET_MAP, Target
 | 
			
		||||
from tools.toolchains import TOOLCHAINS
 | 
			
		||||
from tools.targets import TARGET_NAMES, Target
 | 
			
		||||
from tools.options import get_default_options_parser
 | 
			
		||||
from tools.options import extract_profile
 | 
			
		||||
from tools.options import extract_mcus
 | 
			
		||||
from tools.build_api import build_library, build_mbed_libs, build_lib
 | 
			
		||||
from tools.build_api import mcu_toolchain_matrix
 | 
			
		||||
from tools.build_api import print_build_results
 | 
			
		||||
from tools.build_api import get_toolchain_name
 | 
			
		||||
from tools.settings import CPPCHECK_CMD, CPPCHECK_MSG_FORMAT
 | 
			
		||||
from tools.settings import CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, CLI_COLOR_MAP
 | 
			
		||||
from tools.build_api import target_supports_toolchain
 | 
			
		||||
from tools.build_api import find_valid_toolchain
 | 
			
		||||
from tools.notifier.term import TerminalNotifier
 | 
			
		||||
from tools.utils import argparse_filestring_type, args_error, argparse_many
 | 
			
		||||
from tools.utils import argparse_filestring_type, argparse_dir_not_parent
 | 
			
		||||
from tools.utils import argparse_dir_not_parent
 | 
			
		||||
from tools.utils import NoValidToolchainException
 | 
			
		||||
from tools.utils import print_end_warnings
 | 
			
		||||
from tools.paths import is_relative_to_root
 | 
			
		||||
 | 
			
		||||
if __name__ == '__main__':
 | 
			
		||||
def main():
 | 
			
		||||
    start = time()
 | 
			
		||||
 | 
			
		||||
    # Parse Options
 | 
			
		||||
| 
						 | 
				
			
			@ -169,40 +169,37 @@ if __name__ == '__main__':
 | 
			
		|||
    failures = []
 | 
			
		||||
    successes = []
 | 
			
		||||
    skipped = []
 | 
			
		||||
    end_warnings = []
 | 
			
		||||
 | 
			
		||||
    toolchain_names = set()
 | 
			
		||||
    for toolchain in toolchains:
 | 
			
		||||
        for target_name in targets:
 | 
			
		||||
            target = Target.get_target(target_name)
 | 
			
		||||
            toolchain_names.add(get_toolchain_name(target, toolchain))
 | 
			
		||||
 | 
			
		||||
    for toolchain_name in toolchain_names:
 | 
			
		||||
        if not TOOLCHAIN_CLASSES[toolchain_name].check_executable():
 | 
			
		||||
            search_path = TOOLCHAIN_PATHS[toolchain_name] or "No path set"
 | 
			
		||||
            args_error(parser, "Could not find executable for %s.\n"
 | 
			
		||||
                               "Currently set search path: %s"
 | 
			
		||||
                       % (toolchain_name, search_path))
 | 
			
		||||
            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))
 | 
			
		||||
 | 
			
		||||
    for toolchain in toolchains:
 | 
			
		||||
        for target in targets:
 | 
			
		||||
            tt_id = "%s::%s" % (toolchain, target)
 | 
			
		||||
            if toolchain not in TARGET_MAP[target].supported_toolchains:
 | 
			
		||||
            tt_id = "%s::%s" % (internal_tc_name, target_name)
 | 
			
		||||
            if not target_supports_toolchain(target, toolchain):
 | 
			
		||||
                # Log this later
 | 
			
		||||
                print("%s skipped: toolchain not supported" % tt_id)
 | 
			
		||||
                skipped.append(tt_id)
 | 
			
		||||
            else:
 | 
			
		||||
                try:
 | 
			
		||||
                    notifier = TerminalNotifier(options.verbose, options.silent)
 | 
			
		||||
                    mcu = TARGET_MAP[target]
 | 
			
		||||
                    profile = extract_profile(parser, options, toolchain)
 | 
			
		||||
                    profile = extract_profile(parser, options, internal_tc_name)
 | 
			
		||||
 | 
			
		||||
                    if mcu.is_PSA_secure_target and \
 | 
			
		||||
                    if target.is_PSA_secure_target and \
 | 
			
		||||
                            not is_relative_to_root(options.source_dir):
 | 
			
		||||
                        options.source_dir = ROOT
 | 
			
		||||
 | 
			
		||||
                    if options.source_dir:
 | 
			
		||||
                        lib_build_res = build_library(
 | 
			
		||||
                            options.source_dir, options.build_dir, mcu, toolchain,
 | 
			
		||||
                            options.source_dir, options.build_dir, target, toolchain_name,
 | 
			
		||||
                            jobs=options.jobs,
 | 
			
		||||
                            clean=options.clean,
 | 
			
		||||
                            archive=(not options.no_archive),
 | 
			
		||||
| 
						 | 
				
			
			@ -214,7 +211,7 @@ if __name__ == '__main__':
 | 
			
		|||
                        )
 | 
			
		||||
                    else:
 | 
			
		||||
                        lib_build_res = build_mbed_libs(
 | 
			
		||||
                            mcu, toolchain,
 | 
			
		||||
                            target, toolchain_name,
 | 
			
		||||
                            jobs=options.jobs,
 | 
			
		||||
                            clean=options.clean,
 | 
			
		||||
                            macros=options.macros,
 | 
			
		||||
| 
						 | 
				
			
			@ -225,7 +222,7 @@ if __name__ == '__main__':
 | 
			
		|||
 | 
			
		||||
                    for lib_id in libraries:
 | 
			
		||||
                        build_lib(
 | 
			
		||||
                            lib_id, mcu, toolchain,
 | 
			
		||||
                            lib_id, target, toolchain_name,
 | 
			
		||||
                            clean=options.clean,
 | 
			
		||||
                            macros=options.macros,
 | 
			
		||||
                            jobs=options.jobs,
 | 
			
		||||
| 
						 | 
				
			
			@ -236,10 +233,15 @@ if __name__ == '__main__':
 | 
			
		|||
                        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)
 | 
			
		||||
| 
						 | 
				
			
			@ -254,5 +256,10 @@ if __name__ == '__main__':
 | 
			
		|||
        if report:
 | 
			
		||||
            print(print_build_results(report, report_name))
 | 
			
		||||
 | 
			
		||||
    print_end_warnings(end_warnings)
 | 
			
		||||
    if failures:
 | 
			
		||||
        sys.exit(1)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if __name__ == '__main__':
 | 
			
		||||
    main()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -47,11 +47,12 @@ from tools.build_api import mcu_toolchain_matrix
 | 
			
		|||
from tools.build_api import mcu_toolchain_list
 | 
			
		||||
from tools.build_api import mcu_target_list
 | 
			
		||||
from tools.build_api import merge_build_data
 | 
			
		||||
from tools.build_api import get_toolchain_name
 | 
			
		||||
from utils import argparse_filestring_type
 | 
			
		||||
from utils import argparse_many
 | 
			
		||||
from utils import argparse_dir_not_parent
 | 
			
		||||
from tools.toolchains import TOOLCHAIN_CLASSES, TOOLCHAIN_PATHS
 | 
			
		||||
from tools.build_api import find_valid_toolchain
 | 
			
		||||
from tools.utils import argparse_filestring_type
 | 
			
		||||
from tools.utils import argparse_many
 | 
			
		||||
from tools.utils import argparse_dir_not_parent
 | 
			
		||||
from tools.utils import NoValidToolchainException
 | 
			
		||||
from tools.utils import print_end_warnings
 | 
			
		||||
from tools.settings import ROOT
 | 
			
		||||
from tools.targets import Target
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -68,8 +69,8 @@ def default_args_dict(options):
 | 
			
		|||
        ignore=options.ignore
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def wrapped_build_project(src_dir, build_dir, mcu, *args, **kwargs):
 | 
			
		||||
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
 | 
			
		||||
| 
						 | 
				
			
			@ -80,17 +81,22 @@ def wrapped_build_project(src_dir, build_dir, mcu, *args, **kwargs):
 | 
			
		|||
    except KeyboardInterrupt as e:
 | 
			
		||||
        print("\n[CTRL+c] exit")
 | 
			
		||||
    except NotSupportedException as e:
 | 
			
		||||
        print("\nCould not compile for %s: %s" % (mcu, str(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] %s" % str(e))
 | 
			
		||||
            print("[ERROR] {}".format(str(e)))
 | 
			
		||||
 | 
			
		||||
        error = True
 | 
			
		||||
 | 
			
		||||
    print_end_warnings(end_warnings)
 | 
			
		||||
    if error:
 | 
			
		||||
        sys.exit(1)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if __name__ == '__main__':
 | 
			
		||||
def main():
 | 
			
		||||
    # Parse Options
 | 
			
		||||
    parser = get_default_options_parser(add_app_config=True)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -282,6 +288,8 @@ if __name__ == '__main__':
 | 
			
		|||
    )
 | 
			
		||||
    options = parser.parse_args()
 | 
			
		||||
 | 
			
		||||
    end_warnings = []
 | 
			
		||||
 | 
			
		||||
    if options.supported_toolchains:
 | 
			
		||||
        if options.supported_toolchains == "matrix":
 | 
			
		||||
            print(mcu_toolchain_matrix(
 | 
			
		||||
| 
						 | 
				
			
			@ -323,21 +331,24 @@ if __name__ == '__main__':
 | 
			
		|||
 | 
			
		||||
        notify = TerminalNotifier(options.verbose, options.silent, options.color)
 | 
			
		||||
 | 
			
		||||
        toolchain_name = get_toolchain_name(target, toolchain)
 | 
			
		||||
        if not TOOLCHAIN_CLASSES[toolchain_name].check_executable():
 | 
			
		||||
            search_path = TOOLCHAIN_PATHS[toolchain_name] or "No path set"
 | 
			
		||||
            args_error(parser, "Could not find executable for %s.\n"
 | 
			
		||||
                               "Currently set search path: %s"
 | 
			
		||||
                               %(toolchain_name, search_path))
 | 
			
		||||
        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))
 | 
			
		||||
 | 
			
		||||
        if options.source_dir is not None:
 | 
			
		||||
            wrapped_build_project(
 | 
			
		||||
                options.source_dir,
 | 
			
		||||
                options.build_dir,
 | 
			
		||||
                mcu,
 | 
			
		||||
                toolchain,
 | 
			
		||||
                end_warnings,
 | 
			
		||||
                options,
 | 
			
		||||
                toolchain_name,
 | 
			
		||||
                notify=notify,
 | 
			
		||||
                build_profile=extract_profile(parser, options, toolchain),
 | 
			
		||||
                build_profile=extract_profile(parser, options, internal_tc_name),
 | 
			
		||||
                **default_args_dict(options)
 | 
			
		||||
            )
 | 
			
		||||
        else:
 | 
			
		||||
| 
						 | 
				
			
			@ -389,13 +400,18 @@ if __name__ == '__main__':
 | 
			
		|||
                    test.source_dir,
 | 
			
		||||
                    build_dir,
 | 
			
		||||
                    mcu,
 | 
			
		||||
                    toolchain,
 | 
			
		||||
                    end_warnings,
 | 
			
		||||
                    options,
 | 
			
		||||
                    toolchain_name,
 | 
			
		||||
                    set(test.dependencies),
 | 
			
		||||
                    notify=notify,
 | 
			
		||||
                    report=build_data_blob,
 | 
			
		||||
                    inc_dirs=[dirname(MBED_LIBRARIES)],
 | 
			
		||||
                    build_profile=extract_profile(parser, options, toolchain),
 | 
			
		||||
                    build_profile=extract_profile(parser, options, internal_tc_name),
 | 
			
		||||
                    **default_args_dict(options)
 | 
			
		||||
                )
 | 
			
		||||
            if options.build_data:
 | 
			
		||||
                merge_build_data(options.build_data, build_data_blob, "application")
 | 
			
		||||
 | 
			
		||||
if __name__ == '__main__':
 | 
			
		||||
    main()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -28,27 +28,25 @@ sys.path.insert(0, ROOT)
 | 
			
		|||
 | 
			
		||||
from tools.config import ConfigException, Config
 | 
			
		||||
from tools.test_configs import get_default_config
 | 
			
		||||
from tools.config import ConfigException
 | 
			
		||||
from tools.test_api import find_tests, get_test_config, print_tests, build_tests, test_spec_from_test_builds
 | 
			
		||||
import tools.test_configs as TestConfig
 | 
			
		||||
from tools.options import get_default_options_parser, extract_profile, extract_mcus
 | 
			
		||||
from tools.build_api import build_project, build_library
 | 
			
		||||
from tools.build_api import build_library
 | 
			
		||||
from tools.build_api import print_build_memory_usage
 | 
			
		||||
from tools.build_api import merge_build_data
 | 
			
		||||
from tools.build_api import get_toolchain_name
 | 
			
		||||
from tools.targets import TARGET_MAP
 | 
			
		||||
from tools.build_api import find_valid_toolchain
 | 
			
		||||
from tools.notifier.term import TerminalNotifier
 | 
			
		||||
from tools.utils import mkdir, ToolException, NotSupportedException, args_error, write_json_to_file
 | 
			
		||||
from tools.utils import ToolException, NotSupportedException, args_error, write_json_to_file
 | 
			
		||||
from tools.utils import NoValidToolchainException
 | 
			
		||||
from tools.test_exporters import ReportExporter, ResultExporterType
 | 
			
		||||
from tools.utils import argparse_filestring_type, argparse_lowercase_type, argparse_many
 | 
			
		||||
from tools.utils import argparse_dir_not_parent
 | 
			
		||||
from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS, TOOLCHAIN_CLASSES
 | 
			
		||||
from tools.settings import CLI_COLOR_MAP
 | 
			
		||||
from tools.utils import print_end_warnings
 | 
			
		||||
from tools.settings import ROOT
 | 
			
		||||
from tools.targets import Target
 | 
			
		||||
from tools.paths import is_relative_to_root
 | 
			
		||||
 | 
			
		||||
if __name__ == '__main__':
 | 
			
		||||
def main():
 | 
			
		||||
    error = False
 | 
			
		||||
    try:
 | 
			
		||||
        # Parse Options
 | 
			
		||||
        parser = get_default_options_parser(add_app_config=True)
 | 
			
		||||
| 
						 | 
				
			
			@ -140,6 +138,7 @@ if __name__ == '__main__':
 | 
			
		|||
 | 
			
		||||
        all_tests = {}
 | 
			
		||||
        tests = {}
 | 
			
		||||
        end_warnings = []
 | 
			
		||||
 | 
			
		||||
        # As default both test tools are enabled
 | 
			
		||||
        if not (options.greentea or options.icetea):
 | 
			
		||||
| 
						 | 
				
			
			@ -158,12 +157,13 @@ if __name__ == '__main__':
 | 
			
		|||
            args_error(parser, "argument -t/--tool is required")
 | 
			
		||||
        toolchain = options.tool[0]
 | 
			
		||||
 | 
			
		||||
        toolchain_name = get_toolchain_name(target, toolchain)
 | 
			
		||||
        if not TOOLCHAIN_CLASSES[toolchain_name].check_executable():
 | 
			
		||||
            search_path = TOOLCHAIN_PATHS[toolchain_name] or "No path set"
 | 
			
		||||
            args_error(parser, "Could not find executable for %s.\n"
 | 
			
		||||
                               "Currently set search path: %s"
 | 
			
		||||
                       % (toolchain_name, search_path))
 | 
			
		||||
        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))
 | 
			
		||||
 | 
			
		||||
        # Assign config file. Precedence: test_config>app_config
 | 
			
		||||
        # TODO: merge configs if both given
 | 
			
		||||
| 
						 | 
				
			
			@ -185,7 +185,7 @@ if __name__ == '__main__':
 | 
			
		|||
            all_tests.update(find_tests(
 | 
			
		||||
                base_dir=path,
 | 
			
		||||
                target_name=mcu,
 | 
			
		||||
                toolchain_name=toolchain,
 | 
			
		||||
                toolchain_name=toolchain_name,
 | 
			
		||||
                icetea=options.icetea,
 | 
			
		||||
                greentea=options.greentea,
 | 
			
		||||
                app_config=config))
 | 
			
		||||
| 
						 | 
				
			
			@ -229,12 +229,12 @@ if __name__ == '__main__':
 | 
			
		|||
            build_properties = {}
 | 
			
		||||
 | 
			
		||||
            library_build_success = False
 | 
			
		||||
            profile = extract_profile(parser, options, toolchain)
 | 
			
		||||
            profile = extract_profile(parser, options, internal_tc_name)
 | 
			
		||||
            try:
 | 
			
		||||
                # Build sources
 | 
			
		||||
                notify = TerminalNotifier(options.verbose)
 | 
			
		||||
                build_library(base_source_paths, options.build_dir, mcu,
 | 
			
		||||
                              toolchain, jobs=options.jobs,
 | 
			
		||||
                              toolchain_name, jobs=options.jobs,
 | 
			
		||||
                              clean=options.clean, report=build_report,
 | 
			
		||||
                              properties=build_properties, name="mbed-build",
 | 
			
		||||
                              macros=options.macros,
 | 
			
		||||
| 
						 | 
				
			
			@ -267,7 +267,7 @@ if __name__ == '__main__':
 | 
			
		|||
                    [os.path.relpath(options.build_dir)],
 | 
			
		||||
                    options.build_dir,
 | 
			
		||||
                    mcu,
 | 
			
		||||
                    toolchain,
 | 
			
		||||
                    toolchain_name,
 | 
			
		||||
                    clean=options.clean,
 | 
			
		||||
                    report=build_report,
 | 
			
		||||
                    properties=build_properties,
 | 
			
		||||
| 
						 | 
				
			
			@ -310,8 +310,16 @@ if __name__ == '__main__':
 | 
			
		|||
    except ConfigException as e:
 | 
			
		||||
        # Catching ConfigException here to prevent a traceback
 | 
			
		||||
        print("[ERROR] %s" % str(e))
 | 
			
		||||
        error = True
 | 
			
		||||
    except Exception as e:
 | 
			
		||||
        import traceback
 | 
			
		||||
        traceback.print_exc(file=sys.stdout)
 | 
			
		||||
        print("[ERROR] %s" % str(e))
 | 
			
		||||
        error = True
 | 
			
		||||
 | 
			
		||||
    print_end_warnings(end_warnings)
 | 
			
		||||
    if error:
 | 
			
		||||
        sys.exit(1)
 | 
			
		||||
 | 
			
		||||
if __name__ == '__main__':
 | 
			
		||||
    main()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue