Clone of official tools

Revision:
40:7d3fa6b99b2b
Parent:
36:96847d42f010
Child:
43:2a7da56ebd24
--- a/export/makefile/__init__.py	Wed Jul 19 16:44:30 2017 -0500
+++ b/export/makefile/__init__.py	Tue Oct 10 16:56:30 2017 -0500
@@ -21,7 +21,7 @@
 from subprocess import check_output, CalledProcessError, Popen, PIPE
 import shutil
 from jinja2.exceptions import TemplateNotFound
-from tools.export.exporters import Exporter, filter_supported
+from tools.export.exporters import Exporter, apply_supported_whitelist
 from tools.utils import NotSupportedException
 from tools.targets import TARGET_MAP
 
@@ -35,6 +35,8 @@
 
     MBED_CONFIG_HEADER_SUPPORTED = True
 
+    PREPROCESS_ASM = False
+
     POST_BINARY_WHITELIST = set([
         "MCU_NRF51Code.binary_hook",
         "TEENSY3_1Code.binary_hook",
@@ -42,6 +44,12 @@
         "LPC4088Code.binary_hook"
     ])
 
+    @classmethod
+    def is_target_supported(cls, target_name):
+        target = TARGET_MAP[target_name]
+        return apply_supported_whitelist(
+            cls.TOOLCHAIN, cls.POST_BINARY_WHITELIST, target)
+
     def generate(self):
         """Generate the makefile
 
@@ -90,6 +98,7 @@
             'link_script_ext': self.toolchain.LINKER_EXT,
             'link_script_option': self.LINK_SCRIPT_OPTION,
             'user_library_flag': self.USER_LIBRARY_FLAG,
+            'needs_asm_preproc': self.PREPROCESS_ASM,
         }
 
         if hasattr(self.toolchain, "preproc"):
@@ -186,7 +195,6 @@
 
 class GccArm(Makefile):
     """GCC ARM specific makefile target"""
-    TARGETS = filter_supported("GCC_ARM", Makefile.POST_BINARY_WHITELIST)
     NAME = 'Make-GCC-ARM'
     TEMPLATE = 'make-gcc-arm'
     TOOLCHAIN = "GCC_ARM"
@@ -195,21 +203,20 @@
 
     @staticmethod
     def prepare_lib(libname):
-        return "-l:" + libname
+        if "lib" == libname[:3]:
+            libname = libname[3:-2]
+        return "-l" + libname
 
     @staticmethod
     def prepare_sys_lib(libname):
         return "-l" + libname
 
 
-class Armc5(Makefile):
-    """ARM Compiler 5 specific makefile target"""
-    TARGETS = filter_supported("ARM", Makefile.POST_BINARY_WHITELIST)
-    NAME = 'Make-ARMc5'
-    TEMPLATE = 'make-armc5'
-    TOOLCHAIN = "ARM"
+class Arm(Makefile):
+    """ARM Compiler generic makefile target"""
     LINK_SCRIPT_OPTION = "--scatter"
     USER_LIBRARY_FLAG = "--userlibpath "
+    TEMPLATE = 'make-arm'
 
     @staticmethod
     def prepare_lib(libname):
@@ -219,10 +226,29 @@
     def prepare_sys_lib(libname):
         return libname
 
+    def generate(self):
+        if self.resources.linker_script:
+            new_script = self.toolchain.correct_scatter_shebang(
+                self.resources.linker_script)
+            if new_script is not self.resources.linker_script:
+                self.resources.linker_script = new_script
+                self.generated_files.append(new_script)
+        return super(Arm, self).generate()
+
+class Armc5(Arm):
+    """ARM Compiler 5 (armcc) specific makefile target"""
+    NAME = 'Make-ARMc5'
+    TOOLCHAIN = "ARM"
+    PREPROCESS_ASM = True
+
+class Armc6(Arm):
+    """ARM Compiler 6 (armclang) specific generic makefile target"""
+    NAME = 'Make-ARMc6'
+    TOOLCHAIN = "ARMC6"
+
 
 class IAR(Makefile):
     """IAR specific makefile target"""
-    TARGETS = filter_supported("IAR", Makefile.POST_BINARY_WHITELIST)
     NAME = 'Make-IAR'
     TEMPLATE = 'make-iar'
     TOOLCHAIN = "IAR"