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