Clone of official tools

Revision:
29:1210849dba19
Parent:
24:25bff2709c20
Child:
30:f12ce67666d0
--- a/toolchains/gcc.py	Mon Aug 29 10:55:42 2016 +0100
+++ b/toolchains/gcc.py	Mon Aug 29 11:18:36 2016 +0100
@@ -16,6 +16,7 @@
 """
 import re
 from os.path import join, basename, splitext, dirname, exists
+from distutils.spawn import find_executable
 
 from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS
 from tools.hooks import hook_tool
@@ -39,7 +40,7 @@
         'c': ["-std=gnu99"],
         'cxx': ["-std=gnu++98", "-fno-rtti", "-Wvla"],
         'ld': ["-Wl,--gc-sections", "-Wl,--wrap,main",
-            "-Wl,--wrap,_malloc_r", "-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r"],
+            "-Wl,--wrap,_malloc_r", "-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r", "-Wl,--wrap,_calloc_r"],
     }
 
     def __init__(self, target, options=None, notify=None, macros=None, silent=False, tool_path="", extra_verbose=False):
@@ -110,6 +111,11 @@
         self.ar = join(tool_path, "arm-none-eabi-ar")
         self.elf2bin = join(tool_path, "arm-none-eabi-objcopy")
 
+        if tool_path:
+            self.toolchain_path = main_cc
+        else:
+            self.toolchain_path = find_executable("arm-none-eabi-gcc") or ''
+
     def parse_dependencies(self, dep_path):
         dependencies = []
         buff = open(dep_path).readlines()
@@ -138,7 +144,7 @@
         # The warning/error notification is multiline
         msg = None
         for line in output.splitlines():
-            match = GCC.DIAGNOSTIC_PATTERN.match(line)
+            match = GCC.DIAGNOSTIC_PATTERN.search(line)
             if match is not None:
                 if msg is not None:
                     self.cc_info(msg)
@@ -170,22 +176,23 @@
     def get_config_option(self, config_header):
         return ['-include', config_header]
 
-    def get_compile_options(self, defines, includes):
+    def get_compile_options(self, defines, includes, for_asm=False):
         opts = ['-D%s' % d for d in defines]
         if self.RESPONSE_FILES:
             opts += ['@%s' % self.get_inc_file(includes)]
         else:
             opts += ["-I%s" % i for i in includes]
 
-        config_header = self.get_config_header()
-        if config_header is not None:
-            opts = opts + self.get_config_option(config_header)
+        if not for_asm:
+            config_header = self.get_config_header()
+            if config_header is not None:
+                opts = opts + self.get_config_option(config_header)
         return opts
 
     @hook_tool
     def assemble(self, source, object, includes):
         # Build assemble command
-        cmd = self.asm + self.get_compile_options(self.get_symbols(), includes) + ["-o", object, source]
+        cmd = self.asm + self.get_compile_options(self.get_symbols(True), includes) + ["-o", object, source]
 
         # Call cmdline hook
         cmd = self.hook.get_cmdline_assembler(cmd)
@@ -272,13 +279,13 @@
         GCC.__init__(self, target, options, notify, macros, silent, TOOLCHAIN_PATHS['GCC_ARM'], extra_verbose=extra_verbose)
 
         # Use latest gcc nanolib
-        if "big-build" in self.options:
+        if "std-lib" in self.options:
             use_nano = False
-        elif "small-build" in self.options:
+        elif "small-lib" in self.options:
             use_nano = True
-        elif target.default_build == "standard":
+        elif target.default_lib == "std":
             use_nano = False
-        elif target.default_build == "small":
+        elif target.default_lib == "small":
             use_nano = True
         else:
             use_nano = False