diff --git a/tools/export/iar.py b/tools/export/iar.py index 16a626a9ba..4393867ed7 100644 --- a/tools/export/iar.py +++ b/tools/export/iar.py @@ -35,16 +35,19 @@ class IAREmbeddedWorkbench(Exporter): MBED_CONFIG_HEADER_SUPPORTED = True - # backward compatibility with our scripts - TARGETS = [] - for target in TARGET_NAMES: - try: - if (ProGenDef('iar').is_supported(str(TARGET_MAP[target])) or - ProGenDef('iar').is_supported(TARGET_MAP[target].progen['target'])): - TARGETS.append(target) - except AttributeError: - # target is not supported yet - continue + @property + def TARGETS(self): + if not hasattr(self, "_targets_supported"): + self._targets_supported = [] + for target in TARGET_NAMES: + try: + if (ProGenDef('iar').is_supported(str(TARGET_MAP[target])) or + ProGenDef('iar').is_supported(TARGET_MAP[target].progen['target'])): + self._targets_supported.append(target) + except AttributeError: + # target is not supported yet + continue + return self._targets_supported def generate(self): """ Generates the project files """ diff --git a/tools/export/uvision4.py b/tools/export/uvision4.py index 17c62f2903..a4f684e832 100644 --- a/tools/export/uvision4.py +++ b/tools/export/uvision4.py @@ -36,16 +36,19 @@ class Uvision4(Exporter): MBED_CONFIG_HEADER_SUPPORTED = True - # backward compatibility with our scripts - TARGETS = [] - for target in TARGET_NAMES: - try: - if (ProGenDef('uvision').is_supported(str(TARGET_MAP[target])) or - ProGenDef('uvision').is_supported(TARGET_MAP[target].progen['target'])): - TARGETS.append(target) - except AttributeError: - # target is not supported yet - continue + @property + def TARGETS(self): + if not hasattr(self, "_targets_supported"): + self._targets_supported = [] + for target in TARGET_NAMES: + try: + if (ProGenDef('uvision').is_supported(str(TARGET_MAP[target])) or + ProGenDef('uvision').is_supported(TARGET_MAP[target].progen['target'])): + self._targets_supported.append(target) + except AttributeError: + # target is not supported yet + continue + return self._targets_supported def get_toolchain(self): return TARGET_MAP[self.target].default_toolchain diff --git a/tools/export/uvision5.py b/tools/export/uvision5.py index 50ebf91906..3be797f0e3 100644 --- a/tools/export/uvision5.py +++ b/tools/export/uvision5.py @@ -37,15 +37,22 @@ class Uvision5(Exporter): MBED_CONFIG_HEADER_SUPPORTED = True # backward compatibility with our scripts - TARGETS = [] - for target in TARGET_NAMES: - try: - if (ProGenDef('uvision5').is_supported(str(TARGET_MAP[target])) or - ProGenDef('uvision5').is_supported(TARGET_MAP[target].progen['target'])): - TARGETS.append(target) - except AttributeError: - # target is not supported yet - continue + def __init__(self): + self._targets = [] + + @property + def TARGETS(self): + if not hasattr(self, "_targets_supported"): + self._targets_supported = [] + for target in TARGET_NAMES: + try: + if (ProGenDef('uvision5').is_supported(str(TARGET_MAP[target])) or + ProGenDef('uvision5').is_supported(TARGET_MAP[target].progen['target'])): + self._targets_supported.append(target) + except AttributeError: + # target is not supported yet + continue + return self._targets_supported def get_toolchain(self): return TARGET_MAP[self.target].default_toolchain