takashi kadono
/
Nucleo_446
Color Oled(SSD1331) connect to STMicroelectronics Nucleo-F466
mbed-os/tools/toolchains/iar.py@0:8fdf9a60065b, 2018-10-10 (annotated)
- Committer:
- kadonotakashi
- Date:
- Wed Oct 10 00:33:53 2018 +0000
- Revision:
- 0:8fdf9a60065b
how to make mbed librry
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kadonotakashi | 0:8fdf9a60065b | 1 | """ |
kadonotakashi | 0:8fdf9a60065b | 2 | mbed SDK |
kadonotakashi | 0:8fdf9a60065b | 3 | Copyright (c) 2011-2013 ARM Limited |
kadonotakashi | 0:8fdf9a60065b | 4 | |
kadonotakashi | 0:8fdf9a60065b | 5 | Licensed under the Apache License, Version 2.0 (the "License"); |
kadonotakashi | 0:8fdf9a60065b | 6 | you may not use this file except in compliance with the License. |
kadonotakashi | 0:8fdf9a60065b | 7 | You may obtain a copy of the License at |
kadonotakashi | 0:8fdf9a60065b | 8 | |
kadonotakashi | 0:8fdf9a60065b | 9 | http://www.apache.org/licenses/LICENSE-2.0 |
kadonotakashi | 0:8fdf9a60065b | 10 | |
kadonotakashi | 0:8fdf9a60065b | 11 | Unless required by applicable law or agreed to in writing, software |
kadonotakashi | 0:8fdf9a60065b | 12 | distributed under the License is distributed on an "AS IS" BASIS, |
kadonotakashi | 0:8fdf9a60065b | 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
kadonotakashi | 0:8fdf9a60065b | 14 | See the License for the specific language governing permissions and |
kadonotakashi | 0:8fdf9a60065b | 15 | limitations under the License. |
kadonotakashi | 0:8fdf9a60065b | 16 | """ |
kadonotakashi | 0:8fdf9a60065b | 17 | import re |
kadonotakashi | 0:8fdf9a60065b | 18 | from os import remove |
kadonotakashi | 0:8fdf9a60065b | 19 | from os.path import join, splitext, exists |
kadonotakashi | 0:8fdf9a60065b | 20 | from distutils.version import LooseVersion |
kadonotakashi | 0:8fdf9a60065b | 21 | |
kadonotakashi | 0:8fdf9a60065b | 22 | from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS |
kadonotakashi | 0:8fdf9a60065b | 23 | from tools.hooks import hook_tool |
kadonotakashi | 0:8fdf9a60065b | 24 | from tools.utils import run_cmd, NotSupportedException |
kadonotakashi | 0:8fdf9a60065b | 25 | |
kadonotakashi | 0:8fdf9a60065b | 26 | class IAR(mbedToolchain): |
kadonotakashi | 0:8fdf9a60065b | 27 | LIBRARY_EXT = '.a' |
kadonotakashi | 0:8fdf9a60065b | 28 | LINKER_EXT = '.icf' |
kadonotakashi | 0:8fdf9a60065b | 29 | STD_LIB_NAME = "%s.a" |
kadonotakashi | 0:8fdf9a60065b | 30 | |
kadonotakashi | 0:8fdf9a60065b | 31 | DIAGNOSTIC_PATTERN = re.compile('"(?P<file>[^"]+)",(?P<line>[\d]+)\s+(?P<severity>Warning|Error|Fatal error)(?P<message>.+)') |
kadonotakashi | 0:8fdf9a60065b | 32 | INDEX_PATTERN = re.compile('(?P<col>\s*)\^') |
kadonotakashi | 0:8fdf9a60065b | 33 | IAR_VERSION_RE = re.compile(b"IAR ANSI C/C\+\+ Compiler V(\d+\.\d+)") |
kadonotakashi | 0:8fdf9a60065b | 34 | IAR_VERSION = LooseVersion("7.80") |
kadonotakashi | 0:8fdf9a60065b | 35 | |
kadonotakashi | 0:8fdf9a60065b | 36 | @staticmethod |
kadonotakashi | 0:8fdf9a60065b | 37 | def check_executable(): |
kadonotakashi | 0:8fdf9a60065b | 38 | """Returns True if the executable (arm-none-eabi-gcc) location |
kadonotakashi | 0:8fdf9a60065b | 39 | specified by the user exists OR the executable can be found on the PATH. |
kadonotakashi | 0:8fdf9a60065b | 40 | Returns False otherwise.""" |
kadonotakashi | 0:8fdf9a60065b | 41 | return mbedToolchain.generic_check_executable("IAR", 'iccarm', 2, "bin") |
kadonotakashi | 0:8fdf9a60065b | 42 | |
kadonotakashi | 0:8fdf9a60065b | 43 | def __init__(self, target, notify=None, macros=None, build_profile=None, |
kadonotakashi | 0:8fdf9a60065b | 44 | build_dir=None): |
kadonotakashi | 0:8fdf9a60065b | 45 | mbedToolchain.__init__(self, target, notify, macros, build_dir=build_dir, |
kadonotakashi | 0:8fdf9a60065b | 46 | build_profile=build_profile) |
kadonotakashi | 0:8fdf9a60065b | 47 | if target.core == "Cortex-M7F" or target.core == "Cortex-M7FD": |
kadonotakashi | 0:8fdf9a60065b | 48 | cpuchoice = "Cortex-M7" |
kadonotakashi | 0:8fdf9a60065b | 49 | elif target.core.startswith("Cortex-M23"): |
kadonotakashi | 0:8fdf9a60065b | 50 | cpuchoice = "8-M.baseline" |
kadonotakashi | 0:8fdf9a60065b | 51 | elif target.core.startswith("Cortex-M33"): |
kadonotakashi | 0:8fdf9a60065b | 52 | cpuchoice = "8-M.mainline" |
kadonotakashi | 0:8fdf9a60065b | 53 | else: |
kadonotakashi | 0:8fdf9a60065b | 54 | cpuchoice = target.core |
kadonotakashi | 0:8fdf9a60065b | 55 | |
kadonotakashi | 0:8fdf9a60065b | 56 | # flags_cmd are used only by our scripts, the project files have them already defined, |
kadonotakashi | 0:8fdf9a60065b | 57 | # using this flags results in the errors (duplication) |
kadonotakashi | 0:8fdf9a60065b | 58 | # asm accepts --cpu Core or --fpu FPU, not like c/c++ --cpu=Core |
kadonotakashi | 0:8fdf9a60065b | 59 | asm_flags_cmd = ["--cpu", cpuchoice] |
kadonotakashi | 0:8fdf9a60065b | 60 | # custom c flags |
kadonotakashi | 0:8fdf9a60065b | 61 | c_flags_cmd = ["--cpu", cpuchoice] |
kadonotakashi | 0:8fdf9a60065b | 62 | |
kadonotakashi | 0:8fdf9a60065b | 63 | c_flags_cmd.extend([ |
kadonotakashi | 0:8fdf9a60065b | 64 | "--thumb", "--dlib_config", "DLib_Config_Full.h" |
kadonotakashi | 0:8fdf9a60065b | 65 | ]) |
kadonotakashi | 0:8fdf9a60065b | 66 | # custom c++ cmd flags |
kadonotakashi | 0:8fdf9a60065b | 67 | cxx_flags_cmd = [ |
kadonotakashi | 0:8fdf9a60065b | 68 | "--c++", "--no_rtti", "--no_exceptions" |
kadonotakashi | 0:8fdf9a60065b | 69 | ] |
kadonotakashi | 0:8fdf9a60065b | 70 | if target.core == "Cortex-M7FD": |
kadonotakashi | 0:8fdf9a60065b | 71 | asm_flags_cmd += ["--fpu", "VFPv5"] |
kadonotakashi | 0:8fdf9a60065b | 72 | c_flags_cmd.append("--fpu=VFPv5") |
kadonotakashi | 0:8fdf9a60065b | 73 | elif target.core == "Cortex-M7F": |
kadonotakashi | 0:8fdf9a60065b | 74 | asm_flags_cmd += ["--fpu", "VFPv5_sp"] |
kadonotakashi | 0:8fdf9a60065b | 75 | c_flags_cmd.append("--fpu=VFPv5_sp") |
kadonotakashi | 0:8fdf9a60065b | 76 | elif target.core == "Cortex-M23" or target.core == "Cortex-M33": |
kadonotakashi | 0:8fdf9a60065b | 77 | self.flags["asm"] += ["--cmse"] |
kadonotakashi | 0:8fdf9a60065b | 78 | self.flags["common"] += ["--cmse"] |
kadonotakashi | 0:8fdf9a60065b | 79 | |
kadonotakashi | 0:8fdf9a60065b | 80 | # Create Secure library |
kadonotakashi | 0:8fdf9a60065b | 81 | if target.core == "Cortex-M23" or self.target.core == "Cortex-M33": |
kadonotakashi | 0:8fdf9a60065b | 82 | secure_file = join(build_dir, "cmse_lib.o") |
kadonotakashi | 0:8fdf9a60065b | 83 | self.flags["ld"] += ["--import_cmse_lib_out=%s" % secure_file] |
kadonotakashi | 0:8fdf9a60065b | 84 | |
kadonotakashi | 0:8fdf9a60065b | 85 | IAR_BIN = join(TOOLCHAIN_PATHS['IAR'], "bin") |
kadonotakashi | 0:8fdf9a60065b | 86 | main_cc = join(IAR_BIN, "iccarm") |
kadonotakashi | 0:8fdf9a60065b | 87 | |
kadonotakashi | 0:8fdf9a60065b | 88 | self.asm = [join(IAR_BIN, "iasmarm")] + asm_flags_cmd + self.flags["asm"] |
kadonotakashi | 0:8fdf9a60065b | 89 | self.cc = [main_cc] |
kadonotakashi | 0:8fdf9a60065b | 90 | self.cppc = [main_cc] |
kadonotakashi | 0:8fdf9a60065b | 91 | self.cc += self.flags["common"] + c_flags_cmd + self.flags["c"] |
kadonotakashi | 0:8fdf9a60065b | 92 | self.cppc += self.flags["common"] + c_flags_cmd + cxx_flags_cmd + self.flags["cxx"] |
kadonotakashi | 0:8fdf9a60065b | 93 | |
kadonotakashi | 0:8fdf9a60065b | 94 | self.ld = [join(IAR_BIN, "ilinkarm")] + self.flags['ld'] |
kadonotakashi | 0:8fdf9a60065b | 95 | self.ar = join(IAR_BIN, "iarchive") |
kadonotakashi | 0:8fdf9a60065b | 96 | self.elf2bin = join(IAR_BIN, "ielftool") |
kadonotakashi | 0:8fdf9a60065b | 97 | |
kadonotakashi | 0:8fdf9a60065b | 98 | def version_check(self): |
kadonotakashi | 0:8fdf9a60065b | 99 | stdout, _, retcode = run_cmd([self.cc[0], "--version"], redirect=True) |
kadonotakashi | 0:8fdf9a60065b | 100 | msg = None |
kadonotakashi | 0:8fdf9a60065b | 101 | match = self.IAR_VERSION_RE.search(stdout) |
kadonotakashi | 0:8fdf9a60065b | 102 | found_version = match.group(1).decode("utf-8") if match else None |
kadonotakashi | 0:8fdf9a60065b | 103 | if found_version and LooseVersion(found_version) != self.IAR_VERSION: |
kadonotakashi | 0:8fdf9a60065b | 104 | msg = "Compiler version mismatch: Have {}; expected {}".format( |
kadonotakashi | 0:8fdf9a60065b | 105 | found_version, self.IAR_VERSION) |
kadonotakashi | 0:8fdf9a60065b | 106 | elif not match or len(match.groups()) != 1: |
kadonotakashi | 0:8fdf9a60065b | 107 | msg = ("Compiler version mismatch: Could Not detect compiler " |
kadonotakashi | 0:8fdf9a60065b | 108 | "version; expected {}".format(self.IAR_VERSION)) |
kadonotakashi | 0:8fdf9a60065b | 109 | if msg: |
kadonotakashi | 0:8fdf9a60065b | 110 | self.notify.cc_info({ |
kadonotakashi | 0:8fdf9a60065b | 111 | "message": msg, |
kadonotakashi | 0:8fdf9a60065b | 112 | "file": "", |
kadonotakashi | 0:8fdf9a60065b | 113 | "line": "", |
kadonotakashi | 0:8fdf9a60065b | 114 | "col": "", |
kadonotakashi | 0:8fdf9a60065b | 115 | "severity": "Warning", |
kadonotakashi | 0:8fdf9a60065b | 116 | }) |
kadonotakashi | 0:8fdf9a60065b | 117 | |
kadonotakashi | 0:8fdf9a60065b | 118 | |
kadonotakashi | 0:8fdf9a60065b | 119 | def parse_dependencies(self, dep_path): |
kadonotakashi | 0:8fdf9a60065b | 120 | return [(self.CHROOT if self.CHROOT else '')+path.strip() for path in open(dep_path).readlines() |
kadonotakashi | 0:8fdf9a60065b | 121 | if (path and not path.isspace())] |
kadonotakashi | 0:8fdf9a60065b | 122 | |
kadonotakashi | 0:8fdf9a60065b | 123 | def parse_output(self, output): |
kadonotakashi | 0:8fdf9a60065b | 124 | msg = None |
kadonotakashi | 0:8fdf9a60065b | 125 | for line in output.splitlines(): |
kadonotakashi | 0:8fdf9a60065b | 126 | match = IAR.DIAGNOSTIC_PATTERN.match(line) |
kadonotakashi | 0:8fdf9a60065b | 127 | if match is not None: |
kadonotakashi | 0:8fdf9a60065b | 128 | if msg is not None: |
kadonotakashi | 0:8fdf9a60065b | 129 | self.notify.cc_info(msg) |
kadonotakashi | 0:8fdf9a60065b | 130 | msg = None |
kadonotakashi | 0:8fdf9a60065b | 131 | msg = { |
kadonotakashi | 0:8fdf9a60065b | 132 | 'severity': match.group('severity').lower(), |
kadonotakashi | 0:8fdf9a60065b | 133 | 'file': match.group('file'), |
kadonotakashi | 0:8fdf9a60065b | 134 | 'line': match.group('line'), |
kadonotakashi | 0:8fdf9a60065b | 135 | 'col': 0, |
kadonotakashi | 0:8fdf9a60065b | 136 | 'message': match.group('message'), |
kadonotakashi | 0:8fdf9a60065b | 137 | 'text': '', |
kadonotakashi | 0:8fdf9a60065b | 138 | 'target_name': self.target.name, |
kadonotakashi | 0:8fdf9a60065b | 139 | 'toolchain_name': self.name |
kadonotakashi | 0:8fdf9a60065b | 140 | } |
kadonotakashi | 0:8fdf9a60065b | 141 | elif msg is not None: |
kadonotakashi | 0:8fdf9a60065b | 142 | # Determine the warning/error column by calculating the ^ position |
kadonotakashi | 0:8fdf9a60065b | 143 | match = IAR.INDEX_PATTERN.match(line) |
kadonotakashi | 0:8fdf9a60065b | 144 | if match is not None: |
kadonotakashi | 0:8fdf9a60065b | 145 | msg['col'] = len(match.group('col')) |
kadonotakashi | 0:8fdf9a60065b | 146 | self.notify.cc_info(msg) |
kadonotakashi | 0:8fdf9a60065b | 147 | msg = None |
kadonotakashi | 0:8fdf9a60065b | 148 | else: |
kadonotakashi | 0:8fdf9a60065b | 149 | msg['text'] += line+"\n" |
kadonotakashi | 0:8fdf9a60065b | 150 | |
kadonotakashi | 0:8fdf9a60065b | 151 | if msg is not None: |
kadonotakashi | 0:8fdf9a60065b | 152 | self.notify.cc_info(msg) |
kadonotakashi | 0:8fdf9a60065b | 153 | |
kadonotakashi | 0:8fdf9a60065b | 154 | def get_dep_option(self, object): |
kadonotakashi | 0:8fdf9a60065b | 155 | base, _ = splitext(object) |
kadonotakashi | 0:8fdf9a60065b | 156 | dep_path = base + '.d' |
kadonotakashi | 0:8fdf9a60065b | 157 | return ["--dependencies", dep_path] |
kadonotakashi | 0:8fdf9a60065b | 158 | |
kadonotakashi | 0:8fdf9a60065b | 159 | def cc_extra(self, object): |
kadonotakashi | 0:8fdf9a60065b | 160 | base, _ = splitext(object) |
kadonotakashi | 0:8fdf9a60065b | 161 | return ["-l", base + '.s.txt'] |
kadonotakashi | 0:8fdf9a60065b | 162 | |
kadonotakashi | 0:8fdf9a60065b | 163 | def get_config_option(self, config_header): |
kadonotakashi | 0:8fdf9a60065b | 164 | return ['--preinclude=' + config_header] |
kadonotakashi | 0:8fdf9a60065b | 165 | |
kadonotakashi | 0:8fdf9a60065b | 166 | def get_compile_options(self, defines, includes, for_asm=False): |
kadonotakashi | 0:8fdf9a60065b | 167 | opts = ['-D%s' % d for d in defines] |
kadonotakashi | 0:8fdf9a60065b | 168 | if for_asm: |
kadonotakashi | 0:8fdf9a60065b | 169 | config_macros = self.config.get_config_data_macros() |
kadonotakashi | 0:8fdf9a60065b | 170 | macros_cmd = ['"-D%s"' % d for d in config_macros if not '"' in d] |
kadonotakashi | 0:8fdf9a60065b | 171 | if self.RESPONSE_FILES: |
kadonotakashi | 0:8fdf9a60065b | 172 | via_file = self.make_option_file( |
kadonotakashi | 0:8fdf9a60065b | 173 | macros_cmd, "asm_macros_{}.xcl") |
kadonotakashi | 0:8fdf9a60065b | 174 | opts += ['-f', via_file] |
kadonotakashi | 0:8fdf9a60065b | 175 | else: |
kadonotakashi | 0:8fdf9a60065b | 176 | opts += macros_cmd |
kadonotakashi | 0:8fdf9a60065b | 177 | return opts |
kadonotakashi | 0:8fdf9a60065b | 178 | else: |
kadonotakashi | 0:8fdf9a60065b | 179 | if self.RESPONSE_FILES: |
kadonotakashi | 0:8fdf9a60065b | 180 | opts += ['-f', self.get_inc_file(includes)] |
kadonotakashi | 0:8fdf9a60065b | 181 | else: |
kadonotakashi | 0:8fdf9a60065b | 182 | opts += ["-I%s" % i for i in includes] |
kadonotakashi | 0:8fdf9a60065b | 183 | config_header = self.get_config_header() |
kadonotakashi | 0:8fdf9a60065b | 184 | if config_header is not None: |
kadonotakashi | 0:8fdf9a60065b | 185 | opts = opts + self.get_config_option(config_header) |
kadonotakashi | 0:8fdf9a60065b | 186 | |
kadonotakashi | 0:8fdf9a60065b | 187 | return opts |
kadonotakashi | 0:8fdf9a60065b | 188 | |
kadonotakashi | 0:8fdf9a60065b | 189 | @hook_tool |
kadonotakashi | 0:8fdf9a60065b | 190 | def assemble(self, source, object, includes): |
kadonotakashi | 0:8fdf9a60065b | 191 | # Build assemble command |
kadonotakashi | 0:8fdf9a60065b | 192 | cmd = self.asm + self.get_compile_options(self.get_symbols(True), includes, True) + ["-o", object, source] |
kadonotakashi | 0:8fdf9a60065b | 193 | |
kadonotakashi | 0:8fdf9a60065b | 194 | # Call cmdline hook |
kadonotakashi | 0:8fdf9a60065b | 195 | cmd = self.hook.get_cmdline_assembler(cmd) |
kadonotakashi | 0:8fdf9a60065b | 196 | |
kadonotakashi | 0:8fdf9a60065b | 197 | # Return command array, don't execute |
kadonotakashi | 0:8fdf9a60065b | 198 | return [cmd] |
kadonotakashi | 0:8fdf9a60065b | 199 | |
kadonotakashi | 0:8fdf9a60065b | 200 | @hook_tool |
kadonotakashi | 0:8fdf9a60065b | 201 | def compile(self, cc, source, object, includes): |
kadonotakashi | 0:8fdf9a60065b | 202 | # Build compile command |
kadonotakashi | 0:8fdf9a60065b | 203 | cmd = cc + self.get_compile_options(self.get_symbols(), includes) |
kadonotakashi | 0:8fdf9a60065b | 204 | |
kadonotakashi | 0:8fdf9a60065b | 205 | cmd.extend(self.get_dep_option(object)) |
kadonotakashi | 0:8fdf9a60065b | 206 | |
kadonotakashi | 0:8fdf9a60065b | 207 | cmd.extend(self.cc_extra(object)) |
kadonotakashi | 0:8fdf9a60065b | 208 | |
kadonotakashi | 0:8fdf9a60065b | 209 | cmd.extend(["-o", object, source]) |
kadonotakashi | 0:8fdf9a60065b | 210 | |
kadonotakashi | 0:8fdf9a60065b | 211 | # Call cmdline hook |
kadonotakashi | 0:8fdf9a60065b | 212 | cmd = self.hook.get_cmdline_compiler(cmd) |
kadonotakashi | 0:8fdf9a60065b | 213 | |
kadonotakashi | 0:8fdf9a60065b | 214 | return [cmd] |
kadonotakashi | 0:8fdf9a60065b | 215 | |
kadonotakashi | 0:8fdf9a60065b | 216 | def compile_c(self, source, object, includes): |
kadonotakashi | 0:8fdf9a60065b | 217 | return self.compile(self.cc, source, object, includes) |
kadonotakashi | 0:8fdf9a60065b | 218 | |
kadonotakashi | 0:8fdf9a60065b | 219 | def compile_cpp(self, source, object, includes): |
kadonotakashi | 0:8fdf9a60065b | 220 | return self.compile(self.cppc, source, object, includes) |
kadonotakashi | 0:8fdf9a60065b | 221 | |
kadonotakashi | 0:8fdf9a60065b | 222 | @hook_tool |
kadonotakashi | 0:8fdf9a60065b | 223 | def link(self, output, objects, libraries, lib_dirs, mem_map): |
kadonotakashi | 0:8fdf9a60065b | 224 | # Build linker command |
kadonotakashi | 0:8fdf9a60065b | 225 | map_file = splitext(output)[0] + ".map" |
kadonotakashi | 0:8fdf9a60065b | 226 | cmd = self.ld + [ "-o", output, "--map=%s" % map_file] + objects + libraries |
kadonotakashi | 0:8fdf9a60065b | 227 | |
kadonotakashi | 0:8fdf9a60065b | 228 | if mem_map: |
kadonotakashi | 0:8fdf9a60065b | 229 | cmd.extend(["--config", mem_map]) |
kadonotakashi | 0:8fdf9a60065b | 230 | |
kadonotakashi | 0:8fdf9a60065b | 231 | # Call cmdline hook |
kadonotakashi | 0:8fdf9a60065b | 232 | cmd = self.hook.get_cmdline_linker(cmd) |
kadonotakashi | 0:8fdf9a60065b | 233 | |
kadonotakashi | 0:8fdf9a60065b | 234 | if self.RESPONSE_FILES: |
kadonotakashi | 0:8fdf9a60065b | 235 | # Split link command to linker executable + response file |
kadonotakashi | 0:8fdf9a60065b | 236 | cmd_linker = cmd[0] |
kadonotakashi | 0:8fdf9a60065b | 237 | link_files = self.get_link_file(cmd[1:]) |
kadonotakashi | 0:8fdf9a60065b | 238 | cmd = [cmd_linker, '-f', link_files] |
kadonotakashi | 0:8fdf9a60065b | 239 | |
kadonotakashi | 0:8fdf9a60065b | 240 | # Exec command |
kadonotakashi | 0:8fdf9a60065b | 241 | self.notify.cc_verbose("Link: %s" % ' '.join(cmd)) |
kadonotakashi | 0:8fdf9a60065b | 242 | self.default_cmd(cmd) |
kadonotakashi | 0:8fdf9a60065b | 243 | |
kadonotakashi | 0:8fdf9a60065b | 244 | @hook_tool |
kadonotakashi | 0:8fdf9a60065b | 245 | def archive(self, objects, lib_path): |
kadonotakashi | 0:8fdf9a60065b | 246 | if self.RESPONSE_FILES: |
kadonotakashi | 0:8fdf9a60065b | 247 | param = ['-f', self.get_arch_file(objects)] |
kadonotakashi | 0:8fdf9a60065b | 248 | else: |
kadonotakashi | 0:8fdf9a60065b | 249 | param = objects |
kadonotakashi | 0:8fdf9a60065b | 250 | |
kadonotakashi | 0:8fdf9a60065b | 251 | if exists(lib_path): |
kadonotakashi | 0:8fdf9a60065b | 252 | remove(lib_path) |
kadonotakashi | 0:8fdf9a60065b | 253 | |
kadonotakashi | 0:8fdf9a60065b | 254 | self.default_cmd([self.ar, lib_path] + param) |
kadonotakashi | 0:8fdf9a60065b | 255 | |
kadonotakashi | 0:8fdf9a60065b | 256 | @hook_tool |
kadonotakashi | 0:8fdf9a60065b | 257 | def binary(self, resources, elf, bin): |
kadonotakashi | 0:8fdf9a60065b | 258 | _, fmt = splitext(bin) |
kadonotakashi | 0:8fdf9a60065b | 259 | bin_arg = {".bin": "--bin", ".hex": "--ihex"}[fmt] |
kadonotakashi | 0:8fdf9a60065b | 260 | # Build binary command |
kadonotakashi | 0:8fdf9a60065b | 261 | cmd = [self.elf2bin, bin_arg, elf, bin] |
kadonotakashi | 0:8fdf9a60065b | 262 | |
kadonotakashi | 0:8fdf9a60065b | 263 | # Call cmdline hook |
kadonotakashi | 0:8fdf9a60065b | 264 | cmd = self.hook.get_cmdline_binary(cmd) |
kadonotakashi | 0:8fdf9a60065b | 265 | |
kadonotakashi | 0:8fdf9a60065b | 266 | # Exec command |
kadonotakashi | 0:8fdf9a60065b | 267 | self.notify.cc_verbose("FromELF: %s" % ' '.join(cmd)) |
kadonotakashi | 0:8fdf9a60065b | 268 | self.default_cmd(cmd) |
kadonotakashi | 0:8fdf9a60065b | 269 | |
kadonotakashi | 0:8fdf9a60065b | 270 | @staticmethod |
kadonotakashi | 0:8fdf9a60065b | 271 | def name_mangle(name): |
kadonotakashi | 0:8fdf9a60065b | 272 | return "_Z%i%sv" % (len(name), name) |
kadonotakashi | 0:8fdf9a60065b | 273 | |
kadonotakashi | 0:8fdf9a60065b | 274 | @staticmethod |
kadonotakashi | 0:8fdf9a60065b | 275 | def make_ld_define(name, value): |
kadonotakashi | 0:8fdf9a60065b | 276 | return "--config_def %s=%s" % (name, value) |
kadonotakashi | 0:8fdf9a60065b | 277 | |
kadonotakashi | 0:8fdf9a60065b | 278 | @staticmethod |
kadonotakashi | 0:8fdf9a60065b | 279 | def redirect_symbol(source, sync, build_dir): |
kadonotakashi | 0:8fdf9a60065b | 280 | return "--redirect %s=%s" % (source, sync) |