Clone of official tools

Revision:
35:da9c89f8be7d
Parent:
31:8ea194f6145b
Child:
36:96847d42f010
diff -r 42f20e28adf5 -r da9c89f8be7d export/iar/__init__.py
--- a/export/iar/__init__.py	Mon Feb 13 09:29:13 2017 -0600
+++ b/export/iar/__init__.py	Wed Feb 15 13:53:18 2017 -0600
@@ -25,11 +25,19 @@
     with open(def_loc, 'r') as f:
         IAR_DEFS = json.load(f)
 
-    #supported targets have a device name and corresponding definition in
-    #iar_definitions.json
-    TARGETS = [target for target, obj in TARGET_MAP.iteritems()
-               if hasattr(obj, 'device_name') and
-               obj.device_name in IAR_DEFS.keys() and "IAR" in obj.supported_toolchains]
+    def _iar_support(tgt, iar_targets):
+        if "IAR" not in tgt.supported_toolchains:
+            return False
+        if hasattr(tgt, 'device_name') and tgt.device_name in iar_targets:
+            return True
+        if tgt.name in iar_targets:
+            return True
+        return False
+
+    #supported targets have a name or device_name which maps to a definition
+    #in iar_definitions.json
+    TARGETS = [target for target, obj in TARGET_MAP.iteritems() if
+               _iar_support(obj, IAR_DEFS.keys())]
 
     def iar_groups(self, grouped_src):
         """Return a namedtuple of group info
@@ -56,7 +64,9 @@
 
     def iar_device(self):
         """Retrieve info from iar_definitions.json"""
-        device_name =  TARGET_MAP[self.target].device_name
+        tgt = TARGET_MAP[self.target]
+        device_name = (tgt.device_name if hasattr(tgt, "device_name") else
+                       tgt.name)
         device_info = self.IAR_DEFS[device_name]
         iar_defaults ={
             "OGChipSelectEditMenu": "",
@@ -64,8 +74,10 @@
             "GFPUCoreSlave": '',
             "GFPUCoreSlave2": 40,
             "GBECoreSlave": 35,
+            "GBECoreSlave2": '',
             "FPU2": 0,
             "NrRegs": 0,
+            "NEON": '',
         }
 
         iar_defaults.update(device_info)
@@ -89,16 +101,15 @@
                self.resources.c_sources + self.resources.cpp_sources + \
                self.resources.objects + self.resources.libraries
         flags = self.flags
-        flags['c_flags'] = list(set(flags['common_flags']
+        c_flags = list(set(flags['common_flags']
                                     + flags['c_flags']
                                     + flags['cxx_flags']))
-        if '--vla' in flags['c_flags']:
-            flags['c_flags'].remove('--vla')
-        if '--no_static_destruction' in flags['c_flags']:
-            flags['c_flags'].remove('--no_static_destruction')
-        #Optimizations
-        if '-Oh' in flags['c_flags']:
-            flags['c_flags'].remove('-Oh')
+        # Flags set in template to be set by user in IDE
+        template = ["--vla", "--no_static_destruction"]
+        # Flag invalid if set in template
+        # Optimizations are also set in template
+        invalid_flag = lambda x: x in template or re.match("-O(\d|time|n)", x)
+        flags['c_flags'] = [flag for flag in c_flags if not invalid_flag(flag)]
 
         try:
             debugger = DeviceCMSIS(self.target).debug.replace('-','').upper()