Skip to content

Commit 50eb4f9

Browse files
committed
Build tools changes to support AC6 and AC5
1 parent 76f90c2 commit 50eb4f9

File tree

2 files changed

+48
-17
lines changed

2 files changed

+48
-17
lines changed

tools/build_api.py

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,21 @@ def add_result_to_report(report, result):
122122
report[target][toolchain][id_name].append(result_wrap)
123123

124124
def get_toolchain_name(target, toolchain_name):
125-
if toolchain_name == "ARM":
126-
if CORE_ARCH[target.core] == 8:
125+
126+
if toolchain_name == "ARM" or toolchain_name == "ARMC6" :
127+
if("ARM" in target.supported_toolchains or "ARMC6" in target.supported_toolchains):
127128
return "ARMC6"
128-
elif getattr(target, "default_toolchain", None) == "uARM":
129-
return "uARM"
129+
elif ("ARMC5" in target.supported_toolchains):
130+
if toolchain_name == "ARM":
131+
return "ARM" #note that returning ARM here means, use ARMC5 toolchain
132+
else:
133+
return None #ARMC6 explicitly specified by user, but target doesnt seem to support ARMC6, so return error.
134+
elif toolchain_name == "uARM":
135+
if ("ARMC5" in target.supported_toolchains):
136+
return "uARM" #use ARM_MICRO to use AC5+microlib
137+
else:
138+
target.default_toolchain = "uARM"
139+
return "ARMC6" #use AC6+microlib
130140

131141
return toolchain_name
132142

@@ -284,13 +294,18 @@ def get_mbed_official_release(version):
284294

285295
return mbed_official_release
286296

287-
ARM_COMPILERS = ("ARM", "ARMC6", "uARM")
288297
def target_supports_toolchain(target, toolchain_name):
289-
if toolchain_name in ARM_COMPILERS:
290-
return any(tc in target.supported_toolchains for tc in ARM_COMPILERS)
298+
if toolchain_name in target.supported_toolchains:
299+
return True
291300
else:
292-
return toolchain_name in target.supported_toolchains
293-
301+
if(toolchain_name == "ARM"):
302+
#we cant find ARM, see if one ARMC5, ARMC6 or uARM listed
303+
return any(tc in target.supported_toolchains for tc in ("ARMC5","ARMC6","uARM"))
304+
if(toolchain_name == "ARMC6"):
305+
#we did not find ARMC6, but check for ARM is listed
306+
return any(tc in target.supported_toolchains for tc in ("ARM",))
307+
308+
return False
294309

295310
def prepare_toolchain(src_paths, build_dir, target, toolchain_name,
296311
macros=None, clean=False, jobs=1,
@@ -321,12 +336,14 @@ def prepare_toolchain(src_paths, build_dir, target, toolchain_name,
321336
# If the configuration object was not yet created, create it now
322337
config = config or Config(target, src_paths, app_config=app_config)
323338
target = config.target
339+
324340
if not target_supports_toolchain(target, toolchain_name):
325341
raise NotSupportedException(
326342
"Target {} is not supported by toolchain {}".format(
327343
target.name, toolchain_name))
328344

329345
toolchain_name = get_toolchain_name(target, toolchain_name)
346+
notify.debug("Selected toolchain: %s" % (toolchain_name))
330347

331348
try:
332349
cur_tc = TOOLCHAIN_CLASSES[toolchain_name]

tools/toolchains/arm.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,9 @@ def __init__(self, target, notify=None, macros=None,
342342
build_profile=None, build_dir=None):
343343
ARM.__init__(self, target, notify, macros, build_dir=build_dir,
344344
build_profile=build_profile)
345-
if not set(("ARM", "uARM")).intersection(set(target.supported_toolchains)):
346-
raise NotSupportedException("ARM/uARM compiler support is required for ARM build")
347-
345+
#check only for ARMC5 because ARM_STD means using ARMC5, and thus supported_toolchains must include ARMC5
346+
if not set(("ARMC5",)).intersection(set(target.supported_toolchains)):
347+
raise NotSupportedException("ARM compiler 5 support is required for ARM build")
348348

349349
class ARM_MICRO(ARM):
350350
PATCHED_LIBRARY = False
@@ -353,13 +353,17 @@ def __init__(self, target, notify=None, macros=None,
353353
silent=False, extra_verbose=False, build_profile=None,
354354
build_dir=None):
355355
target.default_toolchain = "uARM"
356-
ARM.__init__(self, target, notify, macros, build_dir=build_dir,
357-
build_profile=build_profile)
358-
if not set(("ARM", "uARM")).intersection(set(target.supported_toolchains)):
356+
357+
#At this point we already know that we want to use ARMC5+Microlib, so check for if they are supported
358+
#For, AC6+Microlib we still use ARMC6 class
359+
if not set(("uARM","ARMC5")).intersection(set(target.supported_toolchains)) == set(("uARM","ARMC5")):
359360
raise NotSupportedException("ARM/uARM compiler support is required for ARM build")
361+
ARM.__init__(self, target, notify, macros, build_dir=build_dir,
362+
build_profile=build_profile)
363+
360364

361365
class ARMC6(ARM_STD):
362-
OFFICIALLY_SUPPORTED = False
366+
OFFICIALLY_SUPPORTED = True
363367
SHEBANG = "#! armclang -E --target=arm-arm-none-eabi -x c"
364368
SUPPORTED_CORES = ["Cortex-M0", "Cortex-M0+", "Cortex-M3", "Cortex-M4",
365369
"Cortex-M4F", "Cortex-M7", "Cortex-M7F", "Cortex-M7FD",
@@ -378,8 +382,18 @@ def __init__(self, target, *args, **kwargs):
378382
raise NotSupportedException(
379383
"this compiler does not support the core %s" % target.core)
380384

381-
if not set(("ARM", "ARMC6")).intersection(set(target.supported_toolchains)):
385+
if not set(("ARM", "ARMC6", "uARM")).intersection(set(target.supported_toolchains)):
382386
raise NotSupportedException("ARM/ARMC6 compiler support is required for ARMC6 build")
387+
388+
if getattr(target, "default_toolchain", "ARMC6") == "uARM":
389+
if "-DMBED_RTOS_SINGLE_THREAD" not in self.flags['common']:
390+
self.flags['common'].append("-DMBED_RTOS_SINGLE_THREAD")
391+
if "-D__MICROLIB" not in self.flags['common']:
392+
self.flags['common'].append("-D__MICROLIB")
393+
if "-Wl,--library_type=microlib" not in self.flags['ld']:
394+
self.flags['ld'].append("-Wl,--library_type=microlib")
395+
if "-Wl,--library_type=microlib" not in self.flags['common']:
396+
self.flags['common'].append("-Wl,--library_type=microlib")
383397

384398
core = target.core
385399
if CORE_ARCH[target.core] == 8:

0 commit comments

Comments
 (0)