Skip to content

Commit e57296d

Browse files
Merge pull request #4598 from theotherjimmy/iar-styling
Fix style issues in IAR exporter
2 parents f6d0c29 + 14a0fb7 commit e57296d

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

tools/export/iar/__init__.py

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,33 @@
1313
from tools.utils import NotSupportedException
1414
from multiprocessing import cpu_count
1515

16+
17+
def _supported(mcu, iar_targets):
18+
if "IAR" not in mcu.supported_toolchains:
19+
return False
20+
if hasattr(mcu, 'device_name') and mcu.device_name in iar_targets:
21+
return True
22+
if mcu.name in iar_targets:
23+
return True
24+
return False
25+
26+
27+
_iar_defs = os.path.join(
28+
os.path.dirname(os.path.abspath(__file__)), 'iar_definitions.json')
29+
30+
with open(_iar_defs, 'r') as f:
31+
_GUI_OPTIONS = json.load(f)
32+
33+
_IAR_TARGETS = [target for target, obj in TARGET_MAP.iteritems() if
34+
_supported(obj, _GUI_OPTIONS.keys())]
35+
36+
1637
class IAR(Exporter):
1738
NAME = 'iar'
1839
TOOLCHAIN = 'IAR'
1940

20-
#iar_definitions.json location
21-
def_loc = os.path.join(
22-
os.path.dirname(os.path.abspath(__file__)), '..', '..', '..',
23-
'tools','export', 'iar', 'iar_definitions.json')
24-
25-
#create a dictionary of the definitions
26-
with open(def_loc, 'r') as f:
27-
IAR_DEFS = json.load(f)
28-
29-
def _iar_support(tgt, iar_targets):
30-
if "IAR" not in tgt.supported_toolchains:
31-
return False
32-
if hasattr(tgt, 'device_name') and tgt.device_name in iar_targets:
33-
return True
34-
if tgt.name in iar_targets:
35-
return True
36-
return False
41+
TARGETS = _IAR_TARGETS
3742

38-
#supported targets have a name or device_name which maps to a definition
39-
#in iar_definitions.json
40-
TARGETS = [target for target, obj in TARGET_MAP.iteritems() if
41-
_iar_support(obj, IAR_DEFS.keys())]
4243

4344
def iar_groups(self, grouped_src):
4445
"""Return a namedtuple of group info
@@ -68,7 +69,7 @@ def iar_device(self):
6869
tgt = TARGET_MAP[self.target]
6970
device_name = (tgt.device_name if hasattr(tgt, "device_name") else
7071
tgt.name)
71-
device_info = self.IAR_DEFS[device_name]
72+
device_info = _GUI_OPTIONS[device_name]
7273
iar_defaults ={
7374
"OGChipSelectEditMenu": "",
7475
"CoreVariant": '',
@@ -192,3 +193,5 @@ def build(project_name, log_name="build_log.txt", cleanup=True):
192193
return -1
193194
else:
194195
return 0
196+
197+

0 commit comments

Comments
 (0)