Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-sdk-tools by
Diff: toolchains/gcc.py
- Revision:
- 21:4fdf0dd04f6f
- Parent:
- 20:835f6355470d
- Child:
- 22:9e85236d8716
diff -r 835f6355470d -r 4fdf0dd04f6f toolchains/gcc.py --- a/toolchains/gcc.py Fri Jul 15 15:28:09 2016 +0100 +++ b/toolchains/gcc.py Fri Jul 15 22:58:15 2016 +0100 @@ -18,7 +18,6 @@ from os.path import join, basename, splitext, dirname, exists from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS -from tools.settings import GOANNA_PATH from tools.hooks import hook_tool class GCC(mbedToolchain): @@ -27,6 +26,7 @@ STD_LIB_NAME = "lib%s.a" DIAGNOSTIC_PATTERN = re.compile('((?P<file>[^:]+):(?P<line>\d+):)(\d+:)? (?P<severity>warning|error): (?P<message>.+)') + INDEX_PATTERN = re.compile('(?P<col>\s*)\^') DEFAULT_FLAGS = { 'common': ["-c", "-Wall", "-Wextra", @@ -98,12 +98,8 @@ main_cc = join(tool_path, "arm-none-eabi-gcc") main_cppc = join(tool_path, "arm-none-eabi-g++") self.asm = [main_cc] + self.flags['asm'] + self.flags["common"] - if not "analyze" in self.options: - self.cc = [main_cc] - self.cppc =[main_cppc] - else: - self.cc = [join(GOANNA_PATH, "goannacc"), "--with-cc=" + main_cc.replace('\\', '/'), "--dialect=gnu", '--output-format="%s"' % self.GOANNA_FORMAT] - self.cppc= [join(GOANNA_PATH, "goannac++"), "--with-cxx=" + main_cppc.replace('\\', '/'), "--dialect=gnu", '--output-format="%s"' % self.GOANNA_FORMAT] + self.cc = [main_cc] + self.cppc =[main_cppc] self.cc += self.flags['c'] + self.flags['common'] self.cppc += self.flags['cxx'] + self.flags['common'] @@ -130,9 +126,9 @@ # back later to a space char) file = file.replace('\\ ', '\a') if file.find(" ") == -1: - dependencies.append(file.replace('\a', ' ')) + dependencies.append((self.CHROOT if self.CHROOT else '') + file.replace('\a', ' ')) else: - dependencies = dependencies + [f.replace('\a', ' ') for f in file.split(" ")] + dependencies = dependencies + [(self.CHROOT if self.CHROOT else '') + f.replace('\a', ' ') for f in file.split(" ")] return dependencies def is_not_supported_error(self, output): @@ -140,32 +136,30 @@ def parse_output(self, output): # The warning/error notification is multiline - WHERE, WHAT = 0, 1 - state, file, message = WHERE, None, None + msg = None for line in output.splitlines(): - match = self.goanna_parse_line(line) - if match is not None: - self.cc_info( - match.group('severity').lower(), - match.group('file'), - match.group('line'), - match.group('message'), - target_name=self.target.name, - toolchain_name=self.name - ) - continue - - match = GCC.DIAGNOSTIC_PATTERN.match(line) if match is not None: - self.cc_info( - match.group('severity').lower(), - match.group('file'), - match.group('line'), - match.group('message'), - target_name=self.target.name, - toolchain_name=self.name - ) + if msg is not None: + self.cc_info(msg) + msg = { + 'severity': match.group('severity').lower(), + 'file': match.group('file'), + 'line': match.group('line'), + 'col': 0, + 'message': match.group('message'), + 'text': '', + 'target_name': self.target.name, + 'toolchain_name': self.name + } + elif msg is not None: + match = GCC.INDEX_PATTERN.match(line) + if match is not None: + msg['col'] = len(match.group('col')) + self.cc_info(msg) + msg = None + else: + msg['text'] += line+"\n" def get_dep_option(self, object): base, _ = splitext(object) @@ -176,7 +170,12 @@ return ['-include', config_header] def get_compile_options(self, defines, includes): - opts = ['-D%s' % d for d in defines] + ['@%s' % self.get_inc_file(includes)] + 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) @@ -234,25 +233,25 @@ # Call cmdline hook cmd = self.hook.get_cmdline_linker(cmd) - # Split link command to linker executable + response file - cmd_linker = cmd[0] - link_files = self.get_link_file(cmd[1:]) + if self.RESPONSE_FILES: + # Split link command to linker executable + response file + cmd_linker = cmd[0] + link_files = self.get_link_file(cmd[1:]) + cmd = [cmd_linker, "@%s" % link_files] # Exec command - self.default_cmd([cmd_linker, "@%s" % link_files]) + self.cc_verbose("Link: %s" % ' '.join(cmd)) + self.default_cmd(cmd) @hook_tool def archive(self, objects, lib_path): - archive_files = join(dirname(lib_path), ".archive_files.txt") - with open(archive_files, "wb") as f: - o_list = [] - for o in objects: - o_list.append('"%s"' % o) - string = " ".join(o_list).replace("\\", "/") - f.write(string) + if self.RESPONSE_FILES: + param = ["@%s" % self.get_arch_files(objects)] + else: + param = objects # Exec command - self.default_cmd([self.ar, 'rcs', lib_path, "@%s" % archive_files]) + self.default_cmd([self.ar, 'rcs', lib_path] + param) @hook_tool def binary(self, resources, elf, bin): @@ -263,6 +262,7 @@ cmd = self.hook.get_cmdline_binary(cmd) # Exec command + self.cc_verbose("FromELF: %s" % ' '.join(cmd)) self.default_cmd(cmd)