Skip to content

Commit 7251a8c

Browse files
authored
Merge pull request #2176 from 0xc0170/fix_#2171
Exporters - progen TARGETS lazy evaluated
2 parents 38ae4f9 + f95265f commit 7251a8c

File tree

3 files changed

+42
-29
lines changed

3 files changed

+42
-29
lines changed

tools/export/iar.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,19 @@ class IAREmbeddedWorkbench(Exporter):
3535

3636
MBED_CONFIG_HEADER_SUPPORTED = True
3737

38-
# backward compatibility with our scripts
39-
TARGETS = []
40-
for target in TARGET_NAMES:
41-
try:
42-
if (ProGenDef('iar').is_supported(str(TARGET_MAP[target])) or
43-
ProGenDef('iar').is_supported(TARGET_MAP[target].progen['target'])):
44-
TARGETS.append(target)
45-
except AttributeError:
46-
# target is not supported yet
47-
continue
38+
@property
39+
def TARGETS(self):
40+
if not hasattr(self, "_targets_supported"):
41+
self._targets_supported = []
42+
for target in TARGET_NAMES:
43+
try:
44+
if (ProGenDef('iar').is_supported(str(TARGET_MAP[target])) or
45+
ProGenDef('iar').is_supported(TARGET_MAP[target].progen['target'])):
46+
self._targets_supported.append(target)
47+
except AttributeError:
48+
# target is not supported yet
49+
continue
50+
return self._targets_supported
4851

4952
def generate(self):
5053
""" Generates the project files """

tools/export/uvision4.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,19 @@ class Uvision4(Exporter):
3636

3737
MBED_CONFIG_HEADER_SUPPORTED = True
3838

39-
# backward compatibility with our scripts
40-
TARGETS = []
41-
for target in TARGET_NAMES:
42-
try:
43-
if (ProGenDef('uvision').is_supported(str(TARGET_MAP[target])) or
44-
ProGenDef('uvision').is_supported(TARGET_MAP[target].progen['target'])):
45-
TARGETS.append(target)
46-
except AttributeError:
47-
# target is not supported yet
48-
continue
39+
@property
40+
def TARGETS(self):
41+
if not hasattr(self, "_targets_supported"):
42+
self._targets_supported = []
43+
for target in TARGET_NAMES:
44+
try:
45+
if (ProGenDef('uvision').is_supported(str(TARGET_MAP[target])) or
46+
ProGenDef('uvision').is_supported(TARGET_MAP[target].progen['target'])):
47+
self._targets_supported.append(target)
48+
except AttributeError:
49+
# target is not supported yet
50+
continue
51+
return self._targets_supported
4952

5053
def get_toolchain(self):
5154
return TARGET_MAP[self.target].default_toolchain

tools/export/uvision5.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,22 @@ class Uvision5(Exporter):
3737
MBED_CONFIG_HEADER_SUPPORTED = True
3838

3939
# backward compatibility with our scripts
40-
TARGETS = []
41-
for target in TARGET_NAMES:
42-
try:
43-
if (ProGenDef('uvision5').is_supported(str(TARGET_MAP[target])) or
44-
ProGenDef('uvision5').is_supported(TARGET_MAP[target].progen['target'])):
45-
TARGETS.append(target)
46-
except AttributeError:
47-
# target is not supported yet
48-
continue
40+
def __init__(self):
41+
self._targets = []
42+
43+
@property
44+
def TARGETS(self):
45+
if not hasattr(self, "_targets_supported"):
46+
self._targets_supported = []
47+
for target in TARGET_NAMES:
48+
try:
49+
if (ProGenDef('uvision5').is_supported(str(TARGET_MAP[target])) or
50+
ProGenDef('uvision5').is_supported(TARGET_MAP[target].progen['target'])):
51+
self._targets_supported.append(target)
52+
except AttributeError:
53+
# target is not supported yet
54+
continue
55+
return self._targets_supported
4956

5057
def get_toolchain(self):
5158
return TARGET_MAP[self.target].default_toolchain

0 commit comments

Comments
 (0)