Clone of official tools
Diff: toolchains/arm.py
- Revision:
- 21:4fdf0dd04f6f
- Parent:
- 20:835f6355470d
- Child:
- 22:9e85236d8716
--- a/toolchains/arm.py Fri Jul 15 15:28:09 2016 +0100 +++ b/toolchains/arm.py Fri Jul 15 22:58:15 2016 +0100 @@ -18,7 +18,6 @@ from os.path import join, dirname, splitext, basename, exists from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS -from tools.settings import GOANNA_PATH from tools.hooks import hook_tool from tools.utils import mkdir import copy @@ -29,6 +28,7 @@ STD_LIB_NAME = "%s.ar" DIAGNOSTIC_PATTERN = re.compile('"(?P<file>[^"]+)", line (?P<line>\d+)( \(column (?P<column>\d+)\)|): (?P<severity>Warning|Error): (?P<message>.+)') + INDEX_PATTERN = re.compile('(?P<col>\s*)\^') DEP_PATTERN = re.compile('\S+:\s(?P<file>.+)\n') @@ -72,12 +72,8 @@ self.flags['c'].append("-O3") self.asm = [main_cc] + self.flags['common'] + self.flags['asm'] + ["-I \""+ARM_INC+"\""] - if not "analyze" in self.options: - self.cc = [main_cc] + self.flags['common'] + self.flags['c'] + ["-I \""+ARM_INC+"\""] - self.cppc = [main_cc] + self.flags['common'] + self.flags['c'] + self.flags['cxx'] + ["-I \""+ARM_INC+"\""] - else: - self.cc = [join(GOANNA_PATH, "goannacc"), "--with-cc=" + main_cc.replace('\\', '/'), "--dialect=armcc", '--output-format="%s"' % self.GOANNA_FORMAT] + self.flags['common'] + self.flags['c'] + ["-I \""+ARM_INC+"\""] - self.cppc= [join(GOANNA_PATH, "goannac++"), "--with-cxx=" + main_cc.replace('\\', '/'), "--dialect=armcc", '--output-format="%s"' % self.GOANNA_FORMAT] + self.flags['common'] + self.flags['c'] + self.flags['cxx'] + ["-I \""+ARM_INC+"\""] + self.cc = [main_cc] + self.flags['common'] + self.flags['c'] + ["-I \""+ARM_INC+"\""] + self.cppc = [main_cc] + self.flags['common'] + self.flags['c'] + self.flags['cxx'] + ["-I \""+ARM_INC+"\""] self.ld = [join(ARM_BIN, "armlink")] self.sys_libs = [] @@ -90,29 +86,38 @@ for line in open(dep_path).readlines(): match = ARM.DEP_PATTERN.match(line) if match is not None: - dependencies.append(match.group('file')) + #we need to append chroot, because when the .d files are generated the compiler is chrooted + dependencies.append((self.CHROOT if self.CHROOT else '') + match.group('file')) return dependencies - + def parse_output(self, output): + msg = None for line in output.splitlines(): match = ARM.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 - ) - 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') - ) + if msg is not None: + self.cc_info(msg) + msg = { + 'severity': match.group('severity').lower(), + 'file': match.group('file'), + 'line': match.group('line'), + 'col': match.group('column') if match.group('column') else 0, + 'message': match.group('message'), + 'text': '', + 'target_name': self.target.name, + 'toolchain_name': self.name + } + elif msg is not None: + match = ARM.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" + + if msg is not None: + self.cc_info(msg) def get_dep_option(self, object): base, _ = splitext(object) @@ -123,7 +128,12 @@ return ['--preinclude=' + config_header] def get_compile_options(self, defines, includes): - opts = ['-D%s' % d for d in defines] + ['--via', self.get_inc_file(includes)] + opts = ['-D%s' % d for d in defines] + if self.RESPONSE_FILES: + opts += ['--via', 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) @@ -186,25 +196,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, '--via', link_files] # Exec command - self.default_cmd([cmd_linker, '--via', 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 = ['--via', self.get_arch_files(objects)] + else: + param = objects # Exec command - self.default_cmd([self.ar, '-r', lib_path, '--via', archive_files]) + self.default_cmd([self.ar, '-r', lib_path] + param) @hook_tool def binary(self, resources, elf, bin): @@ -215,6 +225,7 @@ cmd = self.hook.get_cmdline_binary(cmd) # Exec command + self.cc_verbose("FromELF: %s" % ' '.join(cmd)) self.default_cmd(cmd) @@ -223,7 +234,7 @@ ARM.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose) # Run-time values - self.ld.extend(["--libpath \"%s\"" % join(TOOLCHAIN_PATHS['ARM'], "lib")]) + self.ld.extend(["--libpath", join(TOOLCHAIN_PATHS['ARM'], "lib")]) class ARM_MICRO(ARM): @@ -265,4 +276,4 @@ self.sys_libs.extend([join(TOOLCHAIN_PATHS['ARM'], "lib", "cpplib", lib+".l") for lib in ["cpp_ps", "cpprt_p"]]) else: # Run-time values - self.ld.extend(["--libpath \"%s\"" % join(TOOLCHAIN_PATHS['ARM'], "lib")]) + self.ld.extend(["--libpath", join(TOOLCHAIN_PATHS['ARM'], "lib")])