Skip to content

Commit 8c91b41

Browse files
committed
exporters: allow target name to be used for IAR
Allow the IAR exporter to fall back to a target's name if the device_name entry is missing.
1 parent 65956d1 commit 8c91b41

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

tools/export/iar/__init__.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,19 @@ class IAR(Exporter):
2525
with open(def_loc, 'r') as f:
2626
IAR_DEFS = json.load(f)
2727

28-
#supported targets have a device name and corresponding definition in
29-
#iar_definitions.json
30-
TARGETS = [target for target, obj in TARGET_MAP.iteritems()
31-
if hasattr(obj, 'device_name') and
32-
obj.device_name in IAR_DEFS.keys() and "IAR" in obj.supported_toolchains]
28+
def _iar_support(tgt, iar_targets):
29+
if "IAR" not in tgt.supported_toolchains:
30+
return False
31+
if hasattr(tgt, 'device_name') and tgt.device_name in iar_targets:
32+
return True
33+
if tgt.name in iar_targets:
34+
return True
35+
return False
36+
37+
#supported targets have a name or device_name which maps to a definition
38+
#in iar_definitions.json
39+
TARGETS = [target for target, obj in TARGET_MAP.iteritems() if
40+
_iar_support(obj, IAR_DEFS.keys())]
3341

3442
def iar_groups(self, grouped_src):
3543
"""Return a namedtuple of group info
@@ -56,7 +64,9 @@ def iar_groups(self, grouped_src):
5664

5765
def iar_device(self):
5866
"""Retrieve info from iar_definitions.json"""
59-
device_name = TARGET_MAP[self.target].device_name
67+
tgt = TARGET_MAP[self.target]
68+
device_name = (tgt.device_name if hasattr(tgt, "device_name") else
69+
tgt.name)
6070
device_info = self.IAR_DEFS[device_name]
6171
iar_defaults ={
6272
"OGChipSelectEditMenu": "",

0 commit comments

Comments
 (0)