Clone of official tools
export/makefile/__init__.py@43:2a7da56ebd24, 2018-09-25 (annotated)
- Committer:
- theotherjimmy
- Date:
- Tue Sep 25 13:43:09 2018 -0500
- Revision:
- 43:2a7da56ebd24
- Parent:
- 40:7d3fa6b99b2b
- Child:
- 47:21ae3e5a7128
Release 5.10.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
The Other Jimmy |
31:8ea194f6145b | 1 | """ |
The Other Jimmy |
31:8ea194f6145b | 2 | mbed SDK |
The Other Jimmy |
31:8ea194f6145b | 3 | Copyright (c) 2011-2016 ARM Limited |
The Other Jimmy |
31:8ea194f6145b | 4 | |
The Other Jimmy |
31:8ea194f6145b | 5 | Licensed under the Apache License, Version 2.0 (the "License"); |
The Other Jimmy |
31:8ea194f6145b | 6 | you may not use this file except in compliance with the License. |
The Other Jimmy |
31:8ea194f6145b | 7 | You may obtain a copy of the License at |
The Other Jimmy |
31:8ea194f6145b | 8 | |
The Other Jimmy |
31:8ea194f6145b | 9 | http://www.apache.org/licenses/LICENSE-2.0 |
The Other Jimmy |
31:8ea194f6145b | 10 | |
The Other Jimmy |
31:8ea194f6145b | 11 | Unless required by applicable law or agreed to in writing, software |
The Other Jimmy |
31:8ea194f6145b | 12 | distributed under the License is distributed on an "AS IS" BASIS, |
The Other Jimmy |
31:8ea194f6145b | 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
The Other Jimmy |
31:8ea194f6145b | 14 | See the License for the specific language governing permissions and |
The Other Jimmy |
31:8ea194f6145b | 15 | limitations under the License. |
The Other Jimmy |
31:8ea194f6145b | 16 | """ |
theotherjimmy |
43:2a7da56ebd24 | 17 | from __future__ import print_function, absolute_import |
theotherjimmy |
43:2a7da56ebd24 | 18 | from builtins import str |
theotherjimmy |
43:2a7da56ebd24 | 19 | |
The Other Jimmy |
31:8ea194f6145b | 20 | from os.path import splitext, basename, relpath, join, abspath, dirname,\ |
The Other Jimmy |
31:8ea194f6145b | 21 | exists |
The Other Jimmy |
31:8ea194f6145b | 22 | from os import remove |
The Other Jimmy |
31:8ea194f6145b | 23 | import sys |
The Other Jimmy |
31:8ea194f6145b | 24 | from subprocess import check_output, CalledProcessError, Popen, PIPE |
The Other Jimmy |
31:8ea194f6145b | 25 | import shutil |
The Other Jimmy |
31:8ea194f6145b | 26 | from jinja2.exceptions import TemplateNotFound |
theotherjimmy |
43:2a7da56ebd24 | 27 | from tools.resources import FileType |
theotherjimmy |
40:7d3fa6b99b2b | 28 | from tools.export.exporters import Exporter, apply_supported_whitelist |
The Other Jimmy |
31:8ea194f6145b | 29 | from tools.utils import NotSupportedException |
The Other Jimmy |
31:8ea194f6145b | 30 | from tools.targets import TARGET_MAP |
The Other Jimmy |
31:8ea194f6145b | 31 | |
theotherjimmy |
43:2a7da56ebd24 | 32 | SHELL_ESCAPE_TABLE = { |
theotherjimmy |
43:2a7da56ebd24 | 33 | "(": "\(", |
theotherjimmy |
43:2a7da56ebd24 | 34 | ")": "\)", |
theotherjimmy |
43:2a7da56ebd24 | 35 | } |
theotherjimmy |
43:2a7da56ebd24 | 36 | |
theotherjimmy |
43:2a7da56ebd24 | 37 | |
theotherjimmy |
43:2a7da56ebd24 | 38 | def shell_escape(string): |
theotherjimmy |
43:2a7da56ebd24 | 39 | return "".join(SHELL_ESCAPE_TABLE.get(char, char) for char in string) |
theotherjimmy |
43:2a7da56ebd24 | 40 | |
The Other Jimmy |
31:8ea194f6145b | 41 | |
The Other Jimmy |
31:8ea194f6145b | 42 | class Makefile(Exporter): |
The Other Jimmy |
31:8ea194f6145b | 43 | """Generic Makefile template that mimics the behavior of the python build |
The Other Jimmy |
31:8ea194f6145b | 44 | system |
The Other Jimmy |
31:8ea194f6145b | 45 | """ |
The Other Jimmy |
31:8ea194f6145b | 46 | |
The Other Jimmy |
31:8ea194f6145b | 47 | DOT_IN_RELATIVE_PATH = True |
The Other Jimmy |
31:8ea194f6145b | 48 | |
The Other Jimmy |
31:8ea194f6145b | 49 | MBED_CONFIG_HEADER_SUPPORTED = True |
The Other Jimmy |
31:8ea194f6145b | 50 | |
theotherjimmy |
40:7d3fa6b99b2b | 51 | PREPROCESS_ASM = False |
theotherjimmy |
40:7d3fa6b99b2b | 52 | |
The Other Jimmy |
36:96847d42f010 | 53 | POST_BINARY_WHITELIST = set([ |
The Other Jimmy |
36:96847d42f010 | 54 | "MCU_NRF51Code.binary_hook", |
The Other Jimmy |
36:96847d42f010 | 55 | "TEENSY3_1Code.binary_hook", |
The Other Jimmy |
36:96847d42f010 | 56 | "LPCTargetCode.lpc_patch", |
The Other Jimmy |
36:96847d42f010 | 57 | "LPC4088Code.binary_hook" |
The Other Jimmy |
36:96847d42f010 | 58 | ]) |
The Other Jimmy |
36:96847d42f010 | 59 | |
theotherjimmy |
40:7d3fa6b99b2b | 60 | @classmethod |
theotherjimmy |
40:7d3fa6b99b2b | 61 | def is_target_supported(cls, target_name): |
theotherjimmy |
40:7d3fa6b99b2b | 62 | target = TARGET_MAP[target_name] |
theotherjimmy |
40:7d3fa6b99b2b | 63 | return apply_supported_whitelist( |
theotherjimmy |
40:7d3fa6b99b2b | 64 | cls.TOOLCHAIN, cls.POST_BINARY_WHITELIST, target) |
theotherjimmy |
40:7d3fa6b99b2b | 65 | |
The Other Jimmy |
31:8ea194f6145b | 66 | def generate(self): |
The Other Jimmy |
31:8ea194f6145b | 67 | """Generate the makefile |
The Other Jimmy |
31:8ea194f6145b | 68 | |
The Other Jimmy |
31:8ea194f6145b | 69 | Note: subclasses should not need to override this method |
The Other Jimmy |
31:8ea194f6145b | 70 | """ |
The Other Jimmy |
35:da9c89f8be7d | 71 | if not self.resources.linker_script: |
The Other Jimmy |
35:da9c89f8be7d | 72 | raise NotSupportedException("No linker script found.") |
The Other Jimmy |
35:da9c89f8be7d | 73 | |
The Other Jimmy |
31:8ea194f6145b | 74 | self.resources.win_to_unix() |
The Other Jimmy |
31:8ea194f6145b | 75 | |
The Other Jimmy |
31:8ea194f6145b | 76 | to_be_compiled = [splitext(src)[0] + ".o" for src in |
The Other Jimmy |
31:8ea194f6145b | 77 | self.resources.s_sources + |
The Other Jimmy |
31:8ea194f6145b | 78 | self.resources.c_sources + |
The Other Jimmy |
31:8ea194f6145b | 79 | self.resources.cpp_sources] |
The Other Jimmy |
31:8ea194f6145b | 80 | |
The Other Jimmy |
31:8ea194f6145b | 81 | libraries = [self.prepare_lib(basename(lib)) for lib |
theotherjimmy |
43:2a7da56ebd24 | 82 | in self.libraries] |
The Other Jimmy |
35:da9c89f8be7d | 83 | sys_libs = [self.prepare_sys_lib(lib) for lib |
The Other Jimmy |
35:da9c89f8be7d | 84 | in self.toolchain.sys_libs] |
The Other Jimmy |
31:8ea194f6145b | 85 | |
The Other Jimmy |
31:8ea194f6145b | 86 | ctx = { |
The Other Jimmy |
31:8ea194f6145b | 87 | 'name': self.project_name, |
The Other Jimmy |
31:8ea194f6145b | 88 | 'to_be_compiled': to_be_compiled, |
The Other Jimmy |
31:8ea194f6145b | 89 | 'object_files': self.resources.objects, |
The Other Jimmy |
31:8ea194f6145b | 90 | 'include_paths': list(set(self.resources.inc_dirs)), |
The Other Jimmy |
31:8ea194f6145b | 91 | 'library_paths': self.resources.lib_dirs, |
The Other Jimmy |
31:8ea194f6145b | 92 | 'linker_script': self.resources.linker_script, |
The Other Jimmy |
31:8ea194f6145b | 93 | 'libraries': libraries, |
The Other Jimmy |
35:da9c89f8be7d | 94 | 'ld_sys_libs': sys_libs, |
The Other Jimmy |
31:8ea194f6145b | 95 | 'hex_files': self.resources.hex_files, |
The Other Jimmy |
31:8ea194f6145b | 96 | 'vpath': (["../../.."] |
The Other Jimmy |
31:8ea194f6145b | 97 | if (basename(dirname(dirname(self.export_dir))) |
The Other Jimmy |
31:8ea194f6145b | 98 | == "projectfiles") |
The Other Jimmy |
31:8ea194f6145b | 99 | else [".."]), |
theotherjimmy |
43:2a7da56ebd24 | 100 | 'cc_cmd': basename(self.toolchain.cc[0]), |
theotherjimmy |
43:2a7da56ebd24 | 101 | 'cppc_cmd': basename(self.toolchain.cppc[0]), |
theotherjimmy |
43:2a7da56ebd24 | 102 | 'asm_cmd': basename(self.toolchain.asm[0]), |
theotherjimmy |
43:2a7da56ebd24 | 103 | 'ld_cmd': basename(self.toolchain.ld[0]), |
theotherjimmy |
43:2a7da56ebd24 | 104 | 'elf2bin_cmd': basename(self.toolchain.elf2bin), |
The Other Jimmy |
31:8ea194f6145b | 105 | 'link_script_ext': self.toolchain.LINKER_EXT, |
The Other Jimmy |
31:8ea194f6145b | 106 | 'link_script_option': self.LINK_SCRIPT_OPTION, |
The Other Jimmy |
31:8ea194f6145b | 107 | 'user_library_flag': self.USER_LIBRARY_FLAG, |
theotherjimmy |
40:7d3fa6b99b2b | 108 | 'needs_asm_preproc': self.PREPROCESS_ASM, |
theotherjimmy |
43:2a7da56ebd24 | 109 | 'shell_escape': shell_escape, |
The Other Jimmy |
31:8ea194f6145b | 110 | } |
The Other Jimmy |
31:8ea194f6145b | 111 | |
The Other Jimmy |
36:96847d42f010 | 112 | if hasattr(self.toolchain, "preproc"): |
theotherjimmy |
43:2a7da56ebd24 | 113 | ctx['pp_cmd'] = " ".join( |
theotherjimmy |
43:2a7da56ebd24 | 114 | [basename(self.toolchain.preproc[0])] + |
theotherjimmy |
43:2a7da56ebd24 | 115 | self.toolchain.preproc[1:] + |
theotherjimmy |
43:2a7da56ebd24 | 116 | self.toolchain.ld[1:] |
theotherjimmy |
43:2a7da56ebd24 | 117 | ) |
The Other Jimmy |
36:96847d42f010 | 118 | else: |
The Other Jimmy |
36:96847d42f010 | 119 | ctx['pp_cmd'] = None |
The Other Jimmy |
36:96847d42f010 | 120 | |
The Other Jimmy |
31:8ea194f6145b | 121 | for key in ['include_paths', 'library_paths', 'linker_script', |
The Other Jimmy |
31:8ea194f6145b | 122 | 'hex_files']: |
The Other Jimmy |
31:8ea194f6145b | 123 | if isinstance(ctx[key], list): |
The Other Jimmy |
31:8ea194f6145b | 124 | ctx[key] = [ctx['vpath'][0] + "/" + t for t in ctx[key]] |
The Other Jimmy |
31:8ea194f6145b | 125 | else: |
The Other Jimmy |
31:8ea194f6145b | 126 | ctx[key] = ctx['vpath'][0] + "/" + ctx[key] |
The Other Jimmy |
31:8ea194f6145b | 127 | if "../." not in ctx["include_paths"]: |
The Other Jimmy |
31:8ea194f6145b | 128 | ctx["include_paths"] += ['../.'] |
The Other Jimmy |
31:8ea194f6145b | 129 | for key in ['include_paths', 'library_paths', 'hex_files', |
The Other Jimmy |
31:8ea194f6145b | 130 | 'to_be_compiled']: |
The Other Jimmy |
31:8ea194f6145b | 131 | ctx[key] = sorted(ctx[key]) |
The Other Jimmy |
36:96847d42f010 | 132 | ctx.update(self.format_flags()) |
theotherjimmy |
43:2a7da56ebd24 | 133 | ctx['asm_flags'].extend(self.toolchain.asm[1:]) |
theotherjimmy |
43:2a7da56ebd24 | 134 | ctx['c_flags'].extend(self.toolchain.cc[1:]) |
theotherjimmy |
43:2a7da56ebd24 | 135 | ctx['cxx_flags'].extend(self.toolchain.cppc[1:]) |
theotherjimmy |
43:2a7da56ebd24 | 136 | |
theotherjimmy |
43:2a7da56ebd24 | 137 | # Add the virtual path the the include option in the ASM flags |
theotherjimmy |
43:2a7da56ebd24 | 138 | new_asm_flags = [] |
theotherjimmy |
43:2a7da56ebd24 | 139 | for flag in ctx['asm_flags']: |
theotherjimmy |
43:2a7da56ebd24 | 140 | if flag.startswith('-I'): |
theotherjimmy |
43:2a7da56ebd24 | 141 | new_asm_flags.append("-I{}/{}".format(ctx['vpath'][0], flag[2:])) |
theotherjimmy |
43:2a7da56ebd24 | 142 | elif flag.startswith('--preinclude='): |
theotherjimmy |
43:2a7da56ebd24 | 143 | new_asm_flags.append("--preinclude={}/{}".format(ctx['vpath'][0], flag[13:])) |
theotherjimmy |
43:2a7da56ebd24 | 144 | else: |
theotherjimmy |
43:2a7da56ebd24 | 145 | new_asm_flags.append(flag) |
theotherjimmy |
43:2a7da56ebd24 | 146 | ctx['asm_flags'] = new_asm_flags |
The Other Jimmy |
31:8ea194f6145b | 147 | |
The Other Jimmy |
31:8ea194f6145b | 148 | for templatefile in \ |
The Other Jimmy |
31:8ea194f6145b | 149 | ['makefile/%s_%s.tmpl' % (self.TEMPLATE, |
The Other Jimmy |
31:8ea194f6145b | 150 | self.target.lower())] + \ |
The Other Jimmy |
31:8ea194f6145b | 151 | ['makefile/%s_%s.tmpl' % (self.TEMPLATE, |
The Other Jimmy |
31:8ea194f6145b | 152 | label.lower()) for label |
The Other Jimmy |
31:8ea194f6145b | 153 | in self.toolchain.target.extra_labels] +\ |
The Other Jimmy |
31:8ea194f6145b | 154 | ['makefile/%s.tmpl' % self.TEMPLATE]: |
The Other Jimmy |
31:8ea194f6145b | 155 | try: |
The Other Jimmy |
31:8ea194f6145b | 156 | self.gen_file(templatefile, ctx, 'Makefile') |
The Other Jimmy |
31:8ea194f6145b | 157 | break |
The Other Jimmy |
31:8ea194f6145b | 158 | except TemplateNotFound: |
The Other Jimmy |
31:8ea194f6145b | 159 | pass |
The Other Jimmy |
31:8ea194f6145b | 160 | else: |
The Other Jimmy |
31:8ea194f6145b | 161 | raise NotSupportedException("This make tool is in development") |
The Other Jimmy |
31:8ea194f6145b | 162 | |
The Other Jimmy |
36:96847d42f010 | 163 | def format_flags(self): |
The Other Jimmy |
36:96847d42f010 | 164 | """Format toolchain flags for Makefile""" |
The Other Jimmy |
36:96847d42f010 | 165 | flags = {} |
theotherjimmy |
43:2a7da56ebd24 | 166 | for k, v in self.flags.items(): |
theotherjimmy |
43:2a7da56ebd24 | 167 | if k in ['c_flags', 'cxx_flags']: |
The Other Jimmy |
36:96847d42f010 | 168 | flags[k] = map(lambda x: x.replace('"', '\\"'), v) |
The Other Jimmy |
36:96847d42f010 | 169 | else: |
The Other Jimmy |
36:96847d42f010 | 170 | flags[k] = v |
The Other Jimmy |
36:96847d42f010 | 171 | |
The Other Jimmy |
36:96847d42f010 | 172 | return flags |
The Other Jimmy |
36:96847d42f010 | 173 | |
The Other Jimmy |
31:8ea194f6145b | 174 | @staticmethod |
theotherjimmy |
43:2a7da56ebd24 | 175 | def clean(_): |
theotherjimmy |
43:2a7da56ebd24 | 176 | remove("Makefile") |
theotherjimmy |
43:2a7da56ebd24 | 177 | # legacy .build directory cleaned if exists |
theotherjimmy |
43:2a7da56ebd24 | 178 | if exists('.build'): |
theotherjimmy |
43:2a7da56ebd24 | 179 | shutil.rmtree('.build') |
theotherjimmy |
43:2a7da56ebd24 | 180 | if exists('BUILD'): |
theotherjimmy |
43:2a7da56ebd24 | 181 | shutil.rmtree('BUILD') |
theotherjimmy |
43:2a7da56ebd24 | 182 | |
theotherjimmy |
43:2a7da56ebd24 | 183 | @staticmethod |
The Other Jimmy |
31:8ea194f6145b | 184 | def build(project_name, log_name="build_log.txt", cleanup=True): |
The Other Jimmy |
31:8ea194f6145b | 185 | """ Build Make project """ |
The Other Jimmy |
31:8ea194f6145b | 186 | # > Make -j |
The Other Jimmy |
31:8ea194f6145b | 187 | cmd = ["make", "-j"] |
The Other Jimmy |
31:8ea194f6145b | 188 | |
The Other Jimmy |
31:8ea194f6145b | 189 | # Build the project |
The Other Jimmy |
31:8ea194f6145b | 190 | p = Popen(cmd, stdout=PIPE, stderr=PIPE) |
The Other Jimmy |
31:8ea194f6145b | 191 | out, err = p.communicate() |
The Other Jimmy |
31:8ea194f6145b | 192 | ret_code = p.returncode |
The Other Jimmy |
31:8ea194f6145b | 193 | |
The Other Jimmy |
31:8ea194f6145b | 194 | out_string = "=" * 10 + "STDOUT" + "=" * 10 + "\n" |
The Other Jimmy |
31:8ea194f6145b | 195 | out_string += out |
The Other Jimmy |
31:8ea194f6145b | 196 | out_string += "=" * 10 + "STDERR" + "=" * 10 + "\n" |
The Other Jimmy |
31:8ea194f6145b | 197 | out_string += err |
The Other Jimmy |
31:8ea194f6145b | 198 | |
The Other Jimmy |
31:8ea194f6145b | 199 | if ret_code == 0: |
The Other Jimmy |
31:8ea194f6145b | 200 | out_string += "SUCCESS" |
The Other Jimmy |
31:8ea194f6145b | 201 | else: |
The Other Jimmy |
31:8ea194f6145b | 202 | out_string += "FAILURE" |
The Other Jimmy |
31:8ea194f6145b | 203 | |
theotherjimmy |
43:2a7da56ebd24 | 204 | print(out_string) |
The Other Jimmy |
31:8ea194f6145b | 205 | |
The Other Jimmy |
31:8ea194f6145b | 206 | if log_name: |
The Other Jimmy |
31:8ea194f6145b | 207 | # Write the output to the log file |
The Other Jimmy |
31:8ea194f6145b | 208 | with open(log_name, 'w+') as f: |
The Other Jimmy |
31:8ea194f6145b | 209 | f.write(out_string) |
The Other Jimmy |
31:8ea194f6145b | 210 | |
The Other Jimmy |
31:8ea194f6145b | 211 | # Cleanup the exported and built files |
The Other Jimmy |
31:8ea194f6145b | 212 | if cleanup: |
The Other Jimmy |
31:8ea194f6145b | 213 | remove(log_name) |
theotherjimmy |
43:2a7da56ebd24 | 214 | Makefile.clean(project_name) |
The Other Jimmy |
31:8ea194f6145b | 215 | |
The Other Jimmy |
31:8ea194f6145b | 216 | if ret_code != 0: |
The Other Jimmy |
31:8ea194f6145b | 217 | # Seems like something went wrong. |
The Other Jimmy |
31:8ea194f6145b | 218 | return -1 |
The Other Jimmy |
31:8ea194f6145b | 219 | else: |
The Other Jimmy |
31:8ea194f6145b | 220 | return 0 |
The Other Jimmy |
31:8ea194f6145b | 221 | |
The Other Jimmy |
31:8ea194f6145b | 222 | |
The Other Jimmy |
31:8ea194f6145b | 223 | class GccArm(Makefile): |
The Other Jimmy |
31:8ea194f6145b | 224 | """GCC ARM specific makefile target""" |
The Other Jimmy |
31:8ea194f6145b | 225 | NAME = 'Make-GCC-ARM' |
The Other Jimmy |
31:8ea194f6145b | 226 | TEMPLATE = 'make-gcc-arm' |
The Other Jimmy |
31:8ea194f6145b | 227 | TOOLCHAIN = "GCC_ARM" |
The Other Jimmy |
31:8ea194f6145b | 228 | LINK_SCRIPT_OPTION = "-T" |
The Other Jimmy |
31:8ea194f6145b | 229 | USER_LIBRARY_FLAG = "-L" |
The Other Jimmy |
31:8ea194f6145b | 230 | |
The Other Jimmy |
31:8ea194f6145b | 231 | @staticmethod |
The Other Jimmy |
31:8ea194f6145b | 232 | def prepare_lib(libname): |
theotherjimmy |
40:7d3fa6b99b2b | 233 | if "lib" == libname[:3]: |
theotherjimmy |
40:7d3fa6b99b2b | 234 | libname = libname[3:-2] |
theotherjimmy |
40:7d3fa6b99b2b | 235 | return "-l" + libname |
The Other Jimmy |
31:8ea194f6145b | 236 | |
The Other Jimmy |
35:da9c89f8be7d | 237 | @staticmethod |
The Other Jimmy |
35:da9c89f8be7d | 238 | def prepare_sys_lib(libname): |
The Other Jimmy |
35:da9c89f8be7d | 239 | return "-l" + libname |
The Other Jimmy |
35:da9c89f8be7d | 240 | |
The Other Jimmy |
31:8ea194f6145b | 241 | |
theotherjimmy |
40:7d3fa6b99b2b | 242 | class Arm(Makefile): |
theotherjimmy |
40:7d3fa6b99b2b | 243 | """ARM Compiler generic makefile target""" |
The Other Jimmy |
31:8ea194f6145b | 244 | LINK_SCRIPT_OPTION = "--scatter" |
The Other Jimmy |
31:8ea194f6145b | 245 | USER_LIBRARY_FLAG = "--userlibpath " |
theotherjimmy |
40:7d3fa6b99b2b | 246 | TEMPLATE = 'make-arm' |
The Other Jimmy |
31:8ea194f6145b | 247 | |
The Other Jimmy |
31:8ea194f6145b | 248 | @staticmethod |
The Other Jimmy |
31:8ea194f6145b | 249 | def prepare_lib(libname): |
The Other Jimmy |
31:8ea194f6145b | 250 | return libname |
The Other Jimmy |
31:8ea194f6145b | 251 | |
The Other Jimmy |
35:da9c89f8be7d | 252 | @staticmethod |
The Other Jimmy |
35:da9c89f8be7d | 253 | def prepare_sys_lib(libname): |
The Other Jimmy |
35:da9c89f8be7d | 254 | return libname |
The Other Jimmy |
35:da9c89f8be7d | 255 | |
theotherjimmy |
40:7d3fa6b99b2b | 256 | def generate(self): |
theotherjimmy |
40:7d3fa6b99b2b | 257 | if self.resources.linker_script: |
theotherjimmy |
43:2a7da56ebd24 | 258 | sct_file = self.resources.get_file_refs(FileType.LD_SCRIPT)[-1] |
theotherjimmy |
40:7d3fa6b99b2b | 259 | new_script = self.toolchain.correct_scatter_shebang( |
theotherjimmy |
43:2a7da56ebd24 | 260 | sct_file.path, join("..", dirname(sct_file.name))) |
theotherjimmy |
43:2a7da56ebd24 | 261 | if new_script is not sct_file: |
theotherjimmy |
43:2a7da56ebd24 | 262 | self.resources.add_files_to_type( |
theotherjimmy |
43:2a7da56ebd24 | 263 | FileType.LD_SCRIPT, [new_script]) |
theotherjimmy |
40:7d3fa6b99b2b | 264 | self.generated_files.append(new_script) |
theotherjimmy |
40:7d3fa6b99b2b | 265 | return super(Arm, self).generate() |
theotherjimmy |
40:7d3fa6b99b2b | 266 | |
theotherjimmy |
40:7d3fa6b99b2b | 267 | class Armc5(Arm): |
theotherjimmy |
40:7d3fa6b99b2b | 268 | """ARM Compiler 5 (armcc) specific makefile target""" |
theotherjimmy |
40:7d3fa6b99b2b | 269 | NAME = 'Make-ARMc5' |
theotherjimmy |
40:7d3fa6b99b2b | 270 | TOOLCHAIN = "ARM" |
theotherjimmy |
40:7d3fa6b99b2b | 271 | PREPROCESS_ASM = True |
theotherjimmy |
40:7d3fa6b99b2b | 272 | |
theotherjimmy |
40:7d3fa6b99b2b | 273 | class Armc6(Arm): |
theotherjimmy |
40:7d3fa6b99b2b | 274 | """ARM Compiler 6 (armclang) specific generic makefile target""" |
theotherjimmy |
40:7d3fa6b99b2b | 275 | NAME = 'Make-ARMc6' |
theotherjimmy |
40:7d3fa6b99b2b | 276 | TOOLCHAIN = "ARMC6" |
theotherjimmy |
40:7d3fa6b99b2b | 277 | |
The Other Jimmy |
31:8ea194f6145b | 278 | |
The Other Jimmy |
31:8ea194f6145b | 279 | class IAR(Makefile): |
The Other Jimmy |
31:8ea194f6145b | 280 | """IAR specific makefile target""" |
The Other Jimmy |
31:8ea194f6145b | 281 | NAME = 'Make-IAR' |
The Other Jimmy |
31:8ea194f6145b | 282 | TEMPLATE = 'make-iar' |
The Other Jimmy |
31:8ea194f6145b | 283 | TOOLCHAIN = "IAR" |
The Other Jimmy |
31:8ea194f6145b | 284 | LINK_SCRIPT_OPTION = "--config" |
The Other Jimmy |
31:8ea194f6145b | 285 | USER_LIBRARY_FLAG = "-L" |
The Other Jimmy |
31:8ea194f6145b | 286 | |
The Other Jimmy |
31:8ea194f6145b | 287 | @staticmethod |
The Other Jimmy |
31:8ea194f6145b | 288 | def prepare_lib(libname): |
The Other Jimmy |
31:8ea194f6145b | 289 | if "lib" == libname[:3]: |
The Other Jimmy |
31:8ea194f6145b | 290 | libname = libname[3:] |
The Other Jimmy |
31:8ea194f6145b | 291 | return "-l" + splitext(libname)[0] |
The Other Jimmy |
35:da9c89f8be7d | 292 | |
The Other Jimmy |
35:da9c89f8be7d | 293 | @staticmethod |
The Other Jimmy |
35:da9c89f8be7d | 294 | def prepare_sys_lib(libname): |
The Other Jimmy |
35:da9c89f8be7d | 295 | if "lib" == libname[:3]: |
The Other Jimmy |
35:da9c89f8be7d | 296 | libname = libname[3:] |
The Other Jimmy |
35:da9c89f8be7d | 297 | return "-l" + splitext(libname)[0] |