Skip to content

Commit cd96b21

Browse files
committed
Correct check for the ARM toolchain binary in the PATH.
The compiler used for the ARM toolchain changes depending on the target. This changes the front end scripts to do the proper toolchain look up before checking the system PATH for the compiler executable. The tools were always checking for the ARMC5 compiler, now it should check for the right version.
1 parent 83d7019 commit cd96b21

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

tools/build.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from tools.build_api import build_library, build_mbed_libs, build_lib
3939
from tools.build_api import mcu_toolchain_matrix
4040
from tools.build_api import print_build_results
41+
from tools.build_api import get_toolchain_name
4142
from tools.settings import CPPCHECK_CMD, CPPCHECK_MSG_FORMAT
4243
from tools.settings import CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, CLI_COLOR_MAP
4344
from tools.notifier.term import TerminalNotifier
@@ -169,12 +170,18 @@
169170
successes = []
170171
skipped = []
171172

173+
toolchain_names = set()
172174
for toolchain in toolchains:
173-
if not TOOLCHAIN_CLASSES[toolchain].check_executable():
174-
search_path = TOOLCHAIN_PATHS[toolchain] or "No path set"
175+
for target_name in targets:
176+
target = Target.get_target(target_name)
177+
toolchain_names.add(get_toolchain_name(target, toolchain))
178+
179+
for toolchain_name in toolchain_names:
180+
if not TOOLCHAIN_CLASSES[toolchain_name].check_executable():
181+
search_path = TOOLCHAIN_PATHS[toolchain_name] or "No path set"
175182
args_error(parser, "Could not find executable for %s.\n"
176183
"Currently set search path: %s"
177-
% (toolchain, search_path))
184+
% (toolchain_name, search_path))
178185

179186
for toolchain in toolchains:
180187
for target in targets:

tools/make.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
from tools.build_api import mcu_toolchain_list
4848
from tools.build_api import mcu_target_list
4949
from tools.build_api import merge_build_data
50+
from tools.build_api import get_toolchain_name
5051
from utils import argparse_filestring_type
5152
from utils import argparse_many
5253
from utils import argparse_dir_not_parent
@@ -308,7 +309,8 @@ def wrapped_build_project(src_dir, build_dir, mcu, *args, **kwargs):
308309
args_error(parser, "argument -t/--tool is required")
309310
toolchain = options.tool[0]
310311

311-
if Target.get_target(mcu).is_PSA_secure_target and \
312+
target = Target.get_target(mcu)
313+
if target.is_PSA_secure_target and \
312314
not is_relative_to_root(options.source_dir):
313315
options.source_dir = ROOT
314316

@@ -321,11 +323,12 @@ def wrapped_build_project(src_dir, build_dir, mcu, *args, **kwargs):
321323

322324
notify = TerminalNotifier(options.verbose, options.silent, options.color)
323325

324-
if not TOOLCHAIN_CLASSES[toolchain].check_executable():
325-
search_path = TOOLCHAIN_PATHS[toolchain] or "No path set"
326+
toolchain_name = get_toolchain_name(target, toolchain)
327+
if not TOOLCHAIN_CLASSES[toolchain_name].check_executable():
328+
search_path = TOOLCHAIN_PATHS[toolchain_name] or "No path set"
326329
args_error(parser, "Could not find executable for %s.\n"
327330
"Currently set search path: %s"
328-
%(toolchain, search_path))
331+
%(toolchain_name, search_path))
329332

330333
if options.source_dir is not None:
331334
wrapped_build_project(

tools/test.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from tools.build_api import build_project, build_library
3636
from tools.build_api import print_build_memory_usage
3737
from tools.build_api import merge_build_data
38+
from tools.build_api import get_toolchain_name
3839
from tools.targets import TARGET_MAP
3940
from tools.notifier.term import TerminalNotifier
4041
from tools.utils import mkdir, ToolException, NotSupportedException, args_error, write_json_to_file
@@ -149,18 +150,20 @@
149150
if options.mcu is None:
150151
args_error(parser, "argument -m/--mcu is required")
151152
mcu = extract_mcus(parser, options)[0]
152-
mcu_secured = Target.get_target(mcu).is_PSA_secure_target
153+
target = Target.get_target(mcu)
154+
mcu_secured = target.is_PSA_secure_target
153155

154156
# Toolchain
155157
if options.tool is None:
156158
args_error(parser, "argument -t/--tool is required")
157159
toolchain = options.tool[0]
158160

159-
if not TOOLCHAIN_CLASSES[toolchain].check_executable():
160-
search_path = TOOLCHAIN_PATHS[toolchain] or "No path set"
161+
toolchain_name = get_toolchain_name(target, toolchain)
162+
if not TOOLCHAIN_CLASSES[toolchain_name].check_executable():
163+
search_path = TOOLCHAIN_PATHS[toolchain_name] or "No path set"
161164
args_error(parser, "Could not find executable for %s.\n"
162165
"Currently set search path: %s"
163-
% (toolchain, search_path))
166+
% (toolchain_name, search_path))
164167

165168
# Assign config file. Precedence: test_config>app_config
166169
# TODO: merge configs if both given
@@ -312,4 +315,3 @@
312315
traceback.print_exc(file=sys.stdout)
313316
print("[ERROR] %s" % str(e))
314317
sys.exit(1)
315-

0 commit comments

Comments
 (0)