diff --git a/tools/export/cces/__init__.py b/tools/export/cces/__init__.py index cb193aaa8f..e4180d07d4 100644 --- a/tools/export/cces/__init__.py +++ b/tools/export/cces/__init__.py @@ -53,9 +53,12 @@ class CCES(Exporter): target_name - the name of the target. """ target = TARGET_MAP[target_name] - return (cls.TOOLCHAIN in target.supported_toolchains) \ - and hasattr(target, "device_name") \ - and (target.device_name in SUPPORTED_DEVICES) + if not target.is_TFM_target: + return (cls.TOOLCHAIN in target.supported_toolchains) \ + and hasattr(target, "device_name") \ + and (target.device_name in SUPPORTED_DEVICES) + else: + return False @property def flags(self): diff --git a/tools/export/cdt/__init__.py b/tools/export/cdt/__init__.py index d9f83f99e9..e71fa7a409 100644 --- a/tools/export/cdt/__init__.py +++ b/tools/export/cdt/__init__.py @@ -122,10 +122,13 @@ class EclipseArmc5(Eclipse, Armc5): @classmethod def is_target_supported(cls, target_name): target = TARGET_MAP[target_name] - if int(target.build_tools_metadata["version"]) > 0: - return "ARMC5" in target.supported_toolchains + if not target.is_TFM_target: + if int(target.build_tools_metadata["version"]) > 0: + return "ARMC5" in target.supported_toolchains + else: + return True else: - return True + return False class EclipseIAR(Eclipse, IAR): LOAD_EXE = True diff --git a/tools/export/cmsis/__init__.py b/tools/export/cmsis/__init__.py index a4569122b5..874610bf2d 100644 --- a/tools/export/cmsis/__init__.py +++ b/tools/export/cmsis/__init__.py @@ -129,7 +129,10 @@ class CMSIS(Exporter): @classmethod def is_target_supported(cls, target_name): target = TARGET_MAP[target_name] - return cls.TOOLCHAIN in target.supported_toolchains + if not target.is_TFM_target: + return cls.TOOLCHAIN in target.supported_toolchains + else: + return False def make_key(self, src): """turn a source file into its group name""" diff --git a/tools/export/exporters.py b/tools/export/exporters.py index 1ce9f27570..7d092c9839 100644 --- a/tools/export/exporters.py +++ b/tools/export/exporters.py @@ -325,8 +325,11 @@ class Exporter(with_metaclass(ABCMeta, object)): target_name - the name of the target. """ target = TARGET_MAP[target_name] - return bool(set(target.resolution_order_names).intersection(set(cls.TARGETS))) \ - and cls.TOOLCHAIN in target.supported_toolchains + if not target.is_TFM_target: + return bool(set(target.resolution_order_names).intersection(set(cls.TARGETS))) \ + and cls.TOOLCHAIN in target.supported_toolchains + else: + return False @classmethod @@ -351,11 +354,14 @@ class Exporter(with_metaclass(ABCMeta, object)): def apply_supported_whitelist(compiler, whitelist, target): """Generate a list of supported targets for a given compiler and post-binary hook white-list.""" - if compiler not in target.supported_toolchains: - return False - if not hasattr(target, "post_binary_hook"): - return True - if target.post_binary_hook['function'] in whitelist: - return True + if not target.is_TFM_target: + if compiler not in target.supported_toolchains: + return False + if not hasattr(target, "post_binary_hook"): + return True + if target.post_binary_hook['function'] in whitelist: + return True + else: + return False else: return False diff --git a/tools/export/iar/__init__.py b/tools/export/iar/__init__.py index 5090b5eba5..ca0cb153a2 100644 --- a/tools/export/iar/__init__.py +++ b/tools/export/iar/__init__.py @@ -18,13 +18,16 @@ from multiprocessing import cpu_count def _supported(mcu, iar_targets): - if "IAR" not in mcu.supported_toolchains: + if not mcu.is_TFM_target: + if "IAR" not in mcu.supported_toolchains: + return False + if hasattr(mcu, 'device_name') and mcu.device_name in iar_targets: + return True + if mcu.name in iar_targets: + return True + return False + else: return False - if hasattr(mcu, 'device_name') and mcu.device_name in iar_targets: - return True - if mcu.name in iar_targets: - return True - return False _iar_defs = os.path.join( diff --git a/tools/export/makefile/__init__.py b/tools/export/makefile/__init__.py index 19cf24e8db..ca34ebe4aa 100644 --- a/tools/export/makefile/__init__.py +++ b/tools/export/makefile/__init__.py @@ -289,18 +289,21 @@ class Armc5(Arm): @classmethod def is_target_supported(cls, target_name): target = TARGET_MAP[target_name] - if int(target.build_tools_metadata["version"]) > 0: - #Although toolchain name is set to ARM above we should check for ARMC5 for 5.12/onwards - if "ARMC5" not in target.supported_toolchains: - return False + if not target.is_TFM_target: + if int(target.build_tools_metadata["version"]) > 0: + # Although toolchain name is set to ARM above we should check for ARMC5 for 5.12/onwards + if "ARMC5" not in target.supported_toolchains: + return False - arm_res = apply_supported_whitelist( - "ARM", cls.POST_BINARY_WHITELIST, target - ) - armc5_res = apply_supported_whitelist( - "ARMC5", cls.POST_BINARY_WHITELIST, target - ) - return arm_res or armc5_res + arm_res = apply_supported_whitelist( + "ARM", cls.POST_BINARY_WHITELIST, target + ) + armc5_res = apply_supported_whitelist( + "ARMC5", cls.POST_BINARY_WHITELIST, target + ) + return arm_res or armc5_res + else: + return False class Armc6(Arm): """ARM Compiler 6 (armclang) specific generic makefile target""" @@ -310,23 +313,25 @@ class Armc6(Arm): @classmethod def is_target_supported(cls, target_name): target = TARGET_MAP[target_name] + if not target.is_TFM_target: + if int(target.build_tools_metadata["version"]) > 0: + if not (len(set(target.supported_toolchains).intersection( + set(["ARM", "ARMC6"]))) > 0): + return False - if int(target.build_tools_metadata["version"]) > 0: - if not (len(set(target.supported_toolchains).intersection( - set(["ARM", "ARMC6"]))) > 0): - return False - - if not apply_supported_whitelist( - cls.TOOLCHAIN, cls.POST_BINARY_WHITELIST, target): - #ARMC6 is not in the list, but also check for ARM as ARM represents ARMC6 for 5.12/onwards - #and still keep cls.TOOLCHAIN as ARMC6 as thats the toolchain we want to use - return apply_supported_whitelist( - "ARM", cls.POST_BINARY_WHITELIST, target) + if not apply_supported_whitelist( + cls.TOOLCHAIN, cls.POST_BINARY_WHITELIST, target): + # ARMC6 is not in the list, but also check for ARM as ARM represents ARMC6 for 5.12/onwards + # and still keep cls.TOOLCHAIN as ARMC6 as thats the toolchain we want to use + return apply_supported_whitelist( + "ARM", cls.POST_BINARY_WHITELIST, target) + else: + return True else: - return True + return apply_supported_whitelist( + cls.TOOLCHAIN, cls.POST_BINARY_WHITELIST, target) else: - return apply_supported_whitelist( - cls.TOOLCHAIN, cls.POST_BINARY_WHITELIST, target) + return class IAR(Makefile): diff --git a/tools/export/sw4stm32/__init__.py b/tools/export/sw4stm32/__init__.py index da6a7e1e04..74df6a2277 100644 --- a/tools/export/sw4stm32/__init__.py +++ b/tools/export/sw4stm32/__init__.py @@ -298,10 +298,12 @@ class Sw4STM32(GNUARMEclipse): @classmethod def is_target_supported(cls, target_name): target = TARGET_MAP[target_name] - target_supported = bool(set(target.resolution_order_names) - .intersection(set(cls.BOARDS.keys()))) - toolchain_supported = cls.TOOLCHAIN in target.supported_toolchains - return target_supported and toolchain_supported + if not target.is_TFM_target: + target_supported = bool(set(target.resolution_order_names) + .intersection(set(cls.BOARDS.keys()))) + toolchain_supported = cls.TOOLCHAIN in target.supported_toolchains + return target_supported and toolchain_supported + return False def __gen_dir(self, dir_name): """ diff --git a/tools/export/uvision/__init__.py b/tools/export/uvision/__init__.py index 503e28b2d8..f75b40c6b4 100644 --- a/tools/export/uvision/__init__.py +++ b/tools/export/uvision/__init__.py @@ -390,23 +390,26 @@ class UvisionArmc5(Uvision): @classmethod def is_target_supported(cls, target_name): target = TARGET_MAP[target_name] - if int(target.build_tools_metadata["version"]) > 0: - #Just check for ARMC5 as ARMC5 must be there irrespective of whether uARM is there or not if the target is staying with ARMC5 - if "ARMC5" not in target.supported_toolchains: - return False - else: - if not (set(target.supported_toolchains).intersection( - set(["ARM", "uARM"]))): - return False + if not target.is_TFM_target: + if int(target.build_tools_metadata["version"]) > 0: + # Just check for ARMC5 as ARMC5 must be there irrespective of whether uARM is there or not if the target is staying with ARMC5 + if "ARMC5" not in target.supported_toolchains: + return False + else: + if not (set(target.supported_toolchains).intersection( + set(["ARM", "uARM"]))): + return False - if not DeviceCMSIS.check_supported(target_name): - return False - if "Cortex-A" in target.core: - return False - if not hasattr(target, "post_binary_hook"): - return True - if target.post_binary_hook['function'] in cls.POST_BINARY_WHITELIST: - return True + if not DeviceCMSIS.check_supported(target_name): + return False + if "Cortex-A" in target.core: + return False + if not hasattr(target, "post_binary_hook"): + return True + if target.post_binary_hook['function'] in cls.POST_BINARY_WHITELIST: + return True + else: + return False else: return False @@ -419,21 +422,24 @@ class UvisionArmc6(Uvision): @classmethod def is_target_supported(cls, target_name): target = TARGET_MAP[target_name] - if int(target.build_tools_metadata["version"]) > 0: - if not len(set(target.supported_toolchains).intersection( - set(["ARM", "ARMC6"]))) > 0: - return False - else: - if "ARMC6" not in target.supported_toolchains: - return False + if not target.is_TFM_target: + if int(target.build_tools_metadata["version"]) > 0: + if not len(set(target.supported_toolchains).intersection( + set(["ARM", "ARMC6"]))) > 0: + return False + else: + if "ARMC6" not in target.supported_toolchains: + return False - if not DeviceCMSIS.check_supported(target_name): - return False - if "Cortex-A" in target.core: - return False - if not hasattr(target, "post_binary_hook"): - return True - if target.post_binary_hook['function'] in cls.POST_BINARY_WHITELIST: - return True + if not DeviceCMSIS.check_supported(target_name): + return False + if "Cortex-A" in target.core: + return False + if not hasattr(target, "post_binary_hook"): + return True + if target.post_binary_hook['function'] in cls.POST_BINARY_WHITELIST: + return True + else: + return False else: return False diff --git a/tools/targets/__init__.py b/tools/targets/__init__.py index 08541719ae..2ef5d6d40b 100644 --- a/tools/targets/__init__.py +++ b/tools/targets/__init__.py @@ -400,8 +400,8 @@ class Target(namedtuple( return 'NSPE_Target' in self.labels @property - def is_PSA_target(self): - return self.is_PSA_secure_target or self.is_PSA_non_secure_target + def is_TFM_target(self): + return getattr(self, 'tfm_target_name', False) def get_post_build_hook(self, toolchain_labels): """Initialize the post-build hooks for a toolchain. For now, this