Clone of official tools

Revision:
2:07730b0f452c
Parent:
0:66f3b5499f7f
Child:
7:5af61d55adbe
--- a/toolchains/gcc.py	Fri May 20 20:16:44 2016 +0100
+++ b/toolchains/gcc.py	Fri May 20 22:27:03 2016 +0100
@@ -23,6 +23,7 @@
 from tools.hooks import hook_tool
 
 class GCC(mbedToolchain):
+    PROFILE = {}
     LINKER_EXT = '.ld'
     LIBRARY_EXT = '.a'
 
@@ -30,8 +31,8 @@
     CIRCULAR_DEPENDENCIES = True
     DIAGNOSTIC_PATTERN = re.compile('((?P<line>\d+):)(\d+:)? (?P<severity>warning|error): (?P<message>.+)')
 
-    def __init__(self, target, options=None, notify=None, macros=None, silent=False, tool_path="", extra_verbose=False):
-        mbedToolchain.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose)
+    def __init__(self, target, options=None, notify=None, macros=None, silent=False, tool_path="", extra_verbose=False, profile=None):
+        mbedToolchain.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose, profile=profile)
 
         if target.core == "Cortex-M0+":
             cpu = "cortex-m0plus"
@@ -61,37 +62,31 @@
             self.cpu.append("-mfloat-abi=hard")
             self.cpu.append("-mno-unaligned-access")
 
-
         # Note: We are using "-O2" instead of "-Os" to avoid this known GCC bug:
         # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46762
-        common_flags = ["-c", "-Wall", "-Wextra",
-            "-Wno-unused-parameter", "-Wno-missing-field-initializers",
+        common_flags = self.PROFILE.get('COMMON_FLAGS', ["-c", "-O2",
+            "-Wall", "-Wextra", "-Wno-unused-parameter", "-Wno-missing-field-initializers",
             "-fmessage-length=0", "-fno-exceptions", "-fno-builtin",
             "-ffunction-sections", "-fdata-sections",
             "-fno-delete-null-pointer-checks", "-fomit-frame-pointer"
-            ] + self.cpu
+            ]) + self.cpu
 
         if "save-asm" in self.options:
             common_flags.append("-save-temps")
-
         if "debug-info" in self.options:
+            common_flags.remove("-O3")
+            common_flags.remove("-O2")
+            common_flags.remove("-O1")
             common_flags.append("-O0")
-        else:
-            common_flags.append("-O2")
+
         # add debug symbols for all builds
         common_flags.append("-g")
 
-        main_cc = join(tool_path, "arm-none-eabi-gcc")
-        main_cppc = join(tool_path, "arm-none-eabi-g++")
-        self.asm = [main_cc, "-x", "assembler-with-cpp"] + common_flags
-        if not "analyze" in self.options:
-            self.cc  = [main_cc, "-std=gnu99"] + common_flags
-            self.cppc =[main_cppc, "-std=gnu++98", "-fno-rtti"] + common_flags
-        else:
-            self.cc  = [join(GOANNA_PATH, "goannacc"), "--with-cc=" + main_cc.replace('\\', '/'), "-std=gnu99", "--dialect=gnu", '--output-format="%s"' % self.GOANNA_FORMAT] + common_flags
-            self.cppc= [join(GOANNA_PATH, "goannac++"), "--with-cxx=" + main_cppc.replace('\\', '/'), "-std=gnu++98", "-fno-rtti", "--dialect=gnu", '--output-format="%s"' % self.GOANNA_FORMAT] + common_flags
+        self.asm = [join(tool_path, "arm-none-eabi-gcc")] + self.PROFILE.get('COMMON_ASM_FLAGS', ["-x", "assembler-with-cpp"]) + common_flags
+        self.cc  = [join(tool_path, "arm-none-eabi-gcc")] + self.PROFILE.get('COMMON_CC_FLAGS',  ["-std=gnu99"]) + common_flags
+        self.cppc =[join(tool_path, "arm-none-eabi-g++")] + self.PROFILE.get('COMMON_CPP_FLAGS', ["-std=gnu++98", "-fno-rtti"]) + common_flags
+        self.ld =  [join(tool_path, "arm-none-eabi-gcc")] + self.PROFILE.get('COMMON_LD_FLAGS',  ["-Wl,--gc-sections", "-Wl,--wrap,main"]) + self.cpu
 
-        self.ld = [join(tool_path, "arm-none-eabi-gcc"), "-Wl,--gc-sections", "-Wl,--wrap,main"] + self.cpu
         self.sys_libs = ["stdc++", "supc++", "m", "c", "gcc"]
 
         self.ar = join(tool_path, "arm-none-eabi-ar")
@@ -268,8 +263,8 @@
 
 
 class GCC_ARM(GCC):
-    def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
-        GCC.__init__(self, target, options, notify, macros, silent, GCC_ARM_PATH, extra_verbose=extra_verbose)
+    def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False, profile=None):
+        GCC.__init__(self, target, options, notify, macros, silent, GCC_ARM_PATH, extra_verbose=extra_verbose, profile=profile)
 
         # Use latest gcc nanolib
         self.ld.append("--specs=nano.specs")
@@ -282,8 +277,8 @@
 
 
 class GCC_CR(GCC):
-    def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
-        GCC.__init__(self, target, options, notify, macros, silent, GCC_CR_PATH, extra_verbose=extra_verbose)
+    def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False, profile=None):
+        GCC.__init__(self, target, options, notify, macros, silent, GCC_CR_PATH, extra_verbose=extra_verbose, profile=profile)
 
         additional_compiler_flags = [
             "-D__NEWLIB__", "-D__CODE_RED", "-D__USE_CMSIS", "-DCPP_USE_HEAP",