Skip to content

Commit abd2e02

Browse files
urutvaPatater
authored andcommitted
psa: Remove exporters for TF-M targets
Targets that use TF-M for their PSA implementation are not compatible with exporters at this time. Explicitly block use of exporters with TF-M using targets, for better error messages. Signed-off-by: Devaraj Ranganna <[email protected]>
1 parent d2d12e8 commit abd2e02

File tree

8 files changed

+112
-81
lines changed

8 files changed

+112
-81
lines changed

tools/export/cces/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,12 @@ def is_target_supported(cls, target_name):
5353
target_name - the name of the target.
5454
"""
5555
target = TARGET_MAP[target_name]
56-
return (cls.TOOLCHAIN in target.supported_toolchains) \
57-
and hasattr(target, "device_name") \
58-
and (target.device_name in SUPPORTED_DEVICES)
56+
if not target.is_TFM_target:
57+
return (cls.TOOLCHAIN in target.supported_toolchains) \
58+
and hasattr(target, "device_name") \
59+
and (target.device_name in SUPPORTED_DEVICES)
60+
else:
61+
return False
5962

6063
@property
6164
def flags(self):

tools/export/cdt/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,13 @@ class EclipseArmc5(Eclipse, Armc5):
122122
@classmethod
123123
def is_target_supported(cls, target_name):
124124
target = TARGET_MAP[target_name]
125-
if int(target.build_tools_metadata["version"]) > 0:
126-
return "ARMC5" in target.supported_toolchains
125+
if not target.is_TFM_target:
126+
if int(target.build_tools_metadata["version"]) > 0:
127+
return "ARMC5" in target.supported_toolchains
128+
else:
129+
return True
127130
else:
128-
return True
131+
return False
129132

130133
class EclipseIAR(Eclipse, IAR):
131134
LOAD_EXE = True

tools/export/cmsis/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ class CMSIS(Exporter):
129129
@classmethod
130130
def is_target_supported(cls, target_name):
131131
target = TARGET_MAP[target_name]
132-
return cls.TOOLCHAIN in target.supported_toolchains
132+
if not target.is_TFM_target:
133+
return cls.TOOLCHAIN in target.supported_toolchains
134+
else:
135+
return False
133136

134137
def make_key(self, src):
135138
"""turn a source file into its group name"""

tools/export/exporters.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,11 @@ def is_target_supported(cls, target_name):
325325
target_name - the name of the target.
326326
"""
327327
target = TARGET_MAP[target_name]
328-
return bool(set(target.resolution_order_names).intersection(set(cls.TARGETS))) \
329-
and cls.TOOLCHAIN in target.supported_toolchains
328+
if not target.is_TFM_target:
329+
return bool(set(target.resolution_order_names).intersection(set(cls.TARGETS))) \
330+
and cls.TOOLCHAIN in target.supported_toolchains
331+
else:
332+
return False
330333

331334

332335
@classmethod
@@ -351,11 +354,14 @@ def filter_dot(str):
351354
def apply_supported_whitelist(compiler, whitelist, target):
352355
"""Generate a list of supported targets for a given compiler and post-binary hook
353356
white-list."""
354-
if compiler not in target.supported_toolchains:
355-
return False
356-
if not hasattr(target, "post_binary_hook"):
357-
return True
358-
if target.post_binary_hook['function'] in whitelist:
359-
return True
357+
if not target.is_TFM_target:
358+
if compiler not in target.supported_toolchains:
359+
return False
360+
if not hasattr(target, "post_binary_hook"):
361+
return True
362+
if target.post_binary_hook['function'] in whitelist:
363+
return True
364+
else:
365+
return False
360366
else:
361367
return False

tools/export/iar/__init__.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@
1818

1919

2020
def _supported(mcu, iar_targets):
21-
if "IAR" not in mcu.supported_toolchains:
21+
if not mcu.is_TFM_target:
22+
if "IAR" not in mcu.supported_toolchains:
23+
return False
24+
if hasattr(mcu, 'device_name') and mcu.device_name in iar_targets:
25+
return True
26+
if mcu.name in iar_targets:
27+
return True
28+
return False
29+
else:
2230
return False
23-
if hasattr(mcu, 'device_name') and mcu.device_name in iar_targets:
24-
return True
25-
if mcu.name in iar_targets:
26-
return True
27-
return False
2831

2932

3033
_iar_defs = os.path.join(

tools/export/makefile/__init__.py

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -289,18 +289,21 @@ class Armc5(Arm):
289289
@classmethod
290290
def is_target_supported(cls, target_name):
291291
target = TARGET_MAP[target_name]
292-
if int(target.build_tools_metadata["version"]) > 0:
293-
#Although toolchain name is set to ARM above we should check for ARMC5 for 5.12/onwards
294-
if "ARMC5" not in target.supported_toolchains:
295-
return False
296-
297-
arm_res = apply_supported_whitelist(
298-
"ARM", cls.POST_BINARY_WHITELIST, target
299-
)
300-
armc5_res = apply_supported_whitelist(
301-
"ARMC5", cls.POST_BINARY_WHITELIST, target
302-
)
303-
return arm_res or armc5_res
292+
if not target.is_TFM_target:
293+
if int(target.build_tools_metadata["version"]) > 0:
294+
# Although toolchain name is set to ARM above we should check for ARMC5 for 5.12/onwards
295+
if "ARMC5" not in target.supported_toolchains:
296+
return False
297+
298+
arm_res = apply_supported_whitelist(
299+
"ARM", cls.POST_BINARY_WHITELIST, target
300+
)
301+
armc5_res = apply_supported_whitelist(
302+
"ARMC5", cls.POST_BINARY_WHITELIST, target
303+
)
304+
return arm_res or armc5_res
305+
else:
306+
return False
304307

305308
class Armc6(Arm):
306309
"""ARM Compiler 6 (armclang) specific generic makefile target"""
@@ -310,23 +313,25 @@ class Armc6(Arm):
310313
@classmethod
311314
def is_target_supported(cls, target_name):
312315
target = TARGET_MAP[target_name]
313-
314-
if int(target.build_tools_metadata["version"]) > 0:
315-
if not (len(set(target.supported_toolchains).intersection(
316-
set(["ARM", "ARMC6"]))) > 0):
317-
return False
318-
319-
if not apply_supported_whitelist(
320-
cls.TOOLCHAIN, cls.POST_BINARY_WHITELIST, target):
321-
#ARMC6 is not in the list, but also check for ARM as ARM represents ARMC6 for 5.12/onwards
322-
#and still keep cls.TOOLCHAIN as ARMC6 as thats the toolchain we want to use
323-
return apply_supported_whitelist(
324-
"ARM", cls.POST_BINARY_WHITELIST, target)
316+
if not target.is_TFM_target:
317+
if int(target.build_tools_metadata["version"]) > 0:
318+
if not (len(set(target.supported_toolchains).intersection(
319+
set(["ARM", "ARMC6"]))) > 0):
320+
return False
321+
322+
if not apply_supported_whitelist(
323+
cls.TOOLCHAIN, cls.POST_BINARY_WHITELIST, target):
324+
# ARMC6 is not in the list, but also check for ARM as ARM represents ARMC6 for 5.12/onwards
325+
# and still keep cls.TOOLCHAIN as ARMC6 as thats the toolchain we want to use
326+
return apply_supported_whitelist(
327+
"ARM", cls.POST_BINARY_WHITELIST, target)
328+
else:
329+
return True
325330
else:
326-
return True
331+
return apply_supported_whitelist(
332+
cls.TOOLCHAIN, cls.POST_BINARY_WHITELIST, target)
327333
else:
328-
return apply_supported_whitelist(
329-
cls.TOOLCHAIN, cls.POST_BINARY_WHITELIST, target)
334+
return
330335

331336

332337
class IAR(Makefile):

tools/export/sw4stm32/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,12 @@ class Sw4STM32(GNUARMEclipse):
308308
@classmethod
309309
def is_target_supported(cls, target_name):
310310
target = TARGET_MAP[target_name]
311-
target_supported = bool(set(target.resolution_order_names)
312-
.intersection(set(cls.BOARDS.keys())))
313-
toolchain_supported = cls.TOOLCHAIN in target.supported_toolchains
314-
return target_supported and toolchain_supported
311+
if not target.is_TFM_target:
312+
target_supported = bool(set(target.resolution_order_names)
313+
.intersection(set(cls.BOARDS.keys())))
314+
toolchain_supported = cls.TOOLCHAIN in target.supported_toolchains
315+
return target_supported and toolchain_supported
316+
return False
315317

316318
def __gen_dir(self, dir_name):
317319
"""

tools/export/uvision/__init__.py

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -391,23 +391,26 @@ class UvisionArmc5(Uvision):
391391
@classmethod
392392
def is_target_supported(cls, target_name):
393393
target = TARGET_MAP[target_name]
394-
if int(target.build_tools_metadata["version"]) > 0:
395-
#Just check for ARMC5 as ARMC5 must be there irrespective of whether uARM is there or not if the target is staying with ARMC5
396-
if "ARMC5" not in target.supported_toolchains:
394+
if not target.is_TFM_target:
395+
if int(target.build_tools_metadata["version"]) > 0:
396+
# Just check for ARMC5 as ARMC5 must be there irrespective of whether uARM is there or not if the target is staying with ARMC5
397+
if "ARMC5" not in target.supported_toolchains:
398+
return False
399+
else:
400+
if not (set(target.supported_toolchains).intersection(
401+
set(["ARM", "uARM"]))):
402+
return False
403+
404+
if not DeviceCMSIS.check_supported(target_name):
397405
return False
398-
else:
399-
if not (set(target.supported_toolchains).intersection(
400-
set(["ARM", "uARM"]))):
406+
if "Cortex-A" in target.core:
407+
return False
408+
if not hasattr(target, "post_binary_hook"):
409+
return True
410+
if target.post_binary_hook['function'] in cls.POST_BINARY_WHITELIST:
411+
return True
412+
else:
401413
return False
402-
403-
if not DeviceCMSIS.check_supported(target_name):
404-
return False
405-
if "Cortex-A" in target.core:
406-
return False
407-
if not hasattr(target, "post_binary_hook"):
408-
return True
409-
if target.post_binary_hook['function'] in cls.POST_BINARY_WHITELIST:
410-
return True
411414
else:
412415
return False
413416

@@ -420,21 +423,24 @@ class UvisionArmc6(Uvision):
420423
@classmethod
421424
def is_target_supported(cls, target_name):
422425
target = TARGET_MAP[target_name]
423-
if int(target.build_tools_metadata["version"]) > 0:
424-
if not len(set(target.supported_toolchains).intersection(
425-
set(["ARM", "ARMC6"]))) > 0:
426+
if not target.is_TFM_target:
427+
if int(target.build_tools_metadata["version"]) > 0:
428+
if not len(set(target.supported_toolchains).intersection(
429+
set(["ARM", "ARMC6"]))) > 0:
430+
return False
431+
else:
432+
if "ARMC6" not in target.supported_toolchains:
433+
return False
434+
435+
if not DeviceCMSIS.check_supported(target_name):
426436
return False
427-
else:
428-
if "ARMC6" not in target.supported_toolchains:
437+
if "Cortex-A" in target.core:
438+
return False
439+
if not hasattr(target, "post_binary_hook"):
440+
return True
441+
if target.post_binary_hook['function'] in cls.POST_BINARY_WHITELIST:
442+
return True
443+
else:
429444
return False
430-
431-
if not DeviceCMSIS.check_supported(target_name):
432-
return False
433-
if "Cortex-A" in target.core:
434-
return False
435-
if not hasattr(target, "post_binary_hook"):
436-
return True
437-
if target.post_binary_hook['function'] in cls.POST_BINARY_WHITELIST:
438-
return True
439445
else:
440446
return False

0 commit comments

Comments
 (0)