Clone of official tools

Revision:
36:96847d42f010
Parent:
35:da9c89f8be7d
Child:
40:7d3fa6b99b2b
--- a/export/uvision/__init__.py	Wed Feb 15 13:53:18 2017 -0600
+++ b/export/uvision/__init__.py	Thu Jun 22 11:12:28 2017 -0500
@@ -9,7 +9,7 @@
 
 from tools.arm_pack_manager import Cache
 from tools.targets import TARGET_MAP
-from tools.export.exporters import Exporter
+from tools.export.exporters import Exporter, filter_supported
 from tools.export.cmsis import DeviceCMSIS
 
 cache_d = False
@@ -119,13 +119,19 @@
     """
     NAME = 'uvision5'
     TOOLCHAIN = 'ARM'
-    TARGETS = []
-    for target, obj in TARGET_MAP.iteritems():
-        if not ("ARM" in obj.supported_toolchains and hasattr(obj, "device_name")):
-            continue
-        if not DeviceCMSIS.check_supported(target):
-            continue
-        TARGETS.append(target)
+
+    POST_BINARY_WHITELIST = set([
+        "MCU_NRF51Code.binary_hook",
+        "TEENSY3_1Code.binary_hook",
+        "LPCTargetCode.lpc_patch",
+        "LPC4088Code.binary_hook",
+        "MTSCode.combine_bins_mts_dot",
+        "MTSCode.combine_bins_mts_dragonfly",
+        "NCS36510TargetCode.ncs36510_addfib"
+    ])
+    TARGETS = [tgt for tgt in filter_supported("ARM", POST_BINARY_WHITELIST)
+               if DeviceCMSIS.check_supported(tgt)]
+
     #File associations within .uvprojx file
     file_types = {'.cpp': 8, '.c': 1, '.s': 2,
                   '.obj': 3, '.o': 3, '.lib': 4,
@@ -166,7 +172,7 @@
         # Flag is invalid if set in template
         # Optimizations are also set in the template
         invalid_flag = lambda x: x in template or re.match("-O(\d|time)", x) 
-        flags['c_flags'] = [flag for flag in c_flags if not invalid_flag(flag)]
+        flags['c_flags'] = [flag.replace('"','\\"') for flag in c_flags if not invalid_flag(flag)]
         flags['c_flags'] = " ".join(flags['c_flags'])
         return flags
 
@@ -178,6 +184,16 @@
                                     key=lambda (_, __, name): name.lower())
         return grouped
 
+    @staticmethod
+    def format_fpu(core):
+        """Generate a core's FPU string"""
+        if core.endswith("FD"):
+            return "FPU3(DFPU)"
+        elif core.endswith("F"):
+            return "FPU2"
+        else:
+            return ""
+
     def generate(self):
         """Generate the .uvproj file"""
         cache = Cache(True, False)
@@ -197,10 +213,15 @@
             'include_paths': '; '.join(self.resources.inc_dirs).encode('utf-8'),
             'device': DeviceUvision(self.target),
         }
-        ctx['cputype'] = ctx['device'].core.rstrip("FD")
-        # Turn on FPU optimizations if the core has an FPU
-        ctx['fpu_setting'] = 1 if 'f' not in ctx['device'].core.lower() \
-                                  or 'd' in ctx['device'].core.lower() else 2
+        core = ctx['device'].core
+        ctx['cputype'] = core.rstrip("FD")
+        if core.endswith("FD"):
+            ctx['fpu_setting'] = 3
+        elif core.endswith("F"):
+            ctx['fpu_setting'] = 2
+        else:
+            ctx['fpu_setting'] = 1
+        ctx['fputype'] = self.format_fpu(core)
         ctx.update(self.format_flags())
         self.gen_file('uvision/uvision.tmpl', ctx, self.project_name+".uvprojx")
         self.gen_file('uvision/uvision_debug.tmpl', ctx, self.project_name + ".uvoptx")