|
13 | 13 | from tools.utils import NotSupportedException
|
14 | 14 | from multiprocessing import cpu_count
|
15 | 15 |
|
| 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 | + |
16 | 37 | class IAR(Exporter):
|
17 | 38 | NAME = 'iar'
|
18 | 39 | TOOLCHAIN = 'IAR'
|
19 | 40 |
|
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 |
37 | 42 |
|
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())] |
42 | 43 |
|
43 | 44 | def iar_groups(self, grouped_src):
|
44 | 45 | """Return a namedtuple of group info
|
@@ -68,7 +69,7 @@ def iar_device(self):
|
68 | 69 | tgt = TARGET_MAP[self.target]
|
69 | 70 | device_name = (tgt.device_name if hasattr(tgt, "device_name") else
|
70 | 71 | tgt.name)
|
71 |
| - device_info = self.IAR_DEFS[device_name] |
| 72 | + device_info = _GUI_OPTIONS[device_name] |
72 | 73 | iar_defaults ={
|
73 | 74 | "OGChipSelectEditMenu": "",
|
74 | 75 | "CoreVariant": '',
|
@@ -192,3 +193,5 @@ def build(project_name, log_name="build_log.txt", cleanup=True):
|
192 | 193 | return -1
|
193 | 194 | else:
|
194 | 195 | return 0
|
| 196 | + |
| 197 | + |
0 commit comments