the other jimmy / mbed-sdk-tools

Fork of mbed-sdk-tools by mbed official

Revision:
13:ab47a20b66f0
Parent:
0:66f3b5499f7f
Child:
20:835f6355470d
--- a/export/uvision4.py	Tue Jun 14 11:33:06 2016 +0100
+++ b/export/uvision4.py	Thu Jul 14 20:21:19 2016 +0100
@@ -19,6 +19,7 @@
 
 from tools.export.exporters import Exporter
 from tools.targets import TARGET_MAP, TARGET_NAMES
+from tools.settings import ARM_INC
 
 # If you wish to add a new target, add it to project_generator_definitions, and then
 # define progen_target name in the target class (`` self.progen_target = 'my_target_name' ``)
@@ -33,6 +34,8 @@
     # PROGEN_ACTIVE contains information for exporter scripts that this is using progen
     PROGEN_ACTIVE = True
 
+    MBED_CONFIG_HEADER_SUPPORTED = True
+
     # backward compatibility with our scripts
     TARGETS = []
     for target in TARGET_NAMES:
@@ -44,6 +47,8 @@
             # target is not supported yet
             continue
 
+    def get_toolchain(self):
+        return TARGET_MAP[self.target].default_toolchain
 
     def generate(self):
         """ Generates the project files """
@@ -62,6 +67,23 @@
 
         project_data['tool_specific'] = {}
         project_data['tool_specific'].update(tool_specific)
+
+        # get flags from toolchain and apply
+        project_data['tool_specific']['uvision']['misc'] = {}
+        # asm flags only, common are not valid within uvision project, they are armcc specific
+        project_data['tool_specific']['uvision']['misc']['asm_flags'] = list(set(self.progen_flags['asm_flags']))
+        # cxx flags included, as uvision have them all in one tab
+        project_data['tool_specific']['uvision']['misc']['c_flags'] = list(set(self.progen_flags['common_flags'] + self.progen_flags['c_flags'] + self.progen_flags['cxx_flags']))
+        # not compatible with c99 flag set in the template
+        project_data['tool_specific']['uvision']['misc']['c_flags'].remove("--c99")
+        # ARM_INC is by default as system inclusion, not required for exported project
+        project_data['tool_specific']['uvision']['misc']['c_flags'].remove("-I \""+ARM_INC+"\"")
+        # cpp is not required as it's implicit for cpp files
+        project_data['tool_specific']['uvision']['misc']['c_flags'].remove("--cpp")
+        # we want no-vla for only cxx, but it's also applied for C in IDE, thus we remove it
+        project_data['tool_specific']['uvision']['misc']['c_flags'].remove("--no_vla")
+        project_data['tool_specific']['uvision']['misc']['ld_flags'] = self.progen_flags['ld_flags']
+
         i = 0
         for macro in project_data['common']['macros']:
             # armasm does not like floating numbers in macros, timestamp to int
@@ -73,6 +95,5 @@
                 project_data['common']['macros'].pop(i)
             i += 1
         project_data['common']['macros'].append('__ASSERT_MSG')
-        project_data['common']['build_dir'] = join(project_data['common']['build_dir'], 'uvision4')
+        project_data['common']['build_dir'] = project_data['common']['build_dir'] + '\\' + 'uvision4'
         self.progen_gen_file('uvision', project_data)
-