dhgdh
Dependencies: MAX44000 PWM_Tone_Library nexpaq_mdk
Fork of LED_Demo by
mbd_os/tools/toolchains/gcc.py@9:6bb35cef007d, 2016-10-22 (annotated)
- Committer:
- cyberjoey
- Date:
- Sat Oct 22 01:31:58 2016 +0000
- Revision:
- 9:6bb35cef007d
- Parent:
- 1:55a6170b404f
WORKING
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nexpaq | 1:55a6170b404f | 1 | """ |
nexpaq | 1:55a6170b404f | 2 | mbed SDK |
nexpaq | 1:55a6170b404f | 3 | Copyright (c) 2011-2013 ARM Limited |
nexpaq | 1:55a6170b404f | 4 | |
nexpaq | 1:55a6170b404f | 5 | Licensed under the Apache License, Version 2.0 (the "License"); |
nexpaq | 1:55a6170b404f | 6 | you may not use this file except in compliance with the License. |
nexpaq | 1:55a6170b404f | 7 | You may obtain a copy of the License at |
nexpaq | 1:55a6170b404f | 8 | |
nexpaq | 1:55a6170b404f | 9 | http://www.apache.org/licenses/LICENSE-2.0 |
nexpaq | 1:55a6170b404f | 10 | |
nexpaq | 1:55a6170b404f | 11 | Unless required by applicable law or agreed to in writing, software |
nexpaq | 1:55a6170b404f | 12 | distributed under the License is distributed on an "AS IS" BASIS, |
nexpaq | 1:55a6170b404f | 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
nexpaq | 1:55a6170b404f | 14 | See the License for the specific language governing permissions and |
nexpaq | 1:55a6170b404f | 15 | limitations under the License. |
nexpaq | 1:55a6170b404f | 16 | """ |
nexpaq | 1:55a6170b404f | 17 | import re |
nexpaq | 1:55a6170b404f | 18 | from os.path import join, basename, splitext, dirname, exists |
nexpaq | 1:55a6170b404f | 19 | from distutils.spawn import find_executable |
nexpaq | 1:55a6170b404f | 20 | |
nexpaq | 1:55a6170b404f | 21 | from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS |
nexpaq | 1:55a6170b404f | 22 | from tools.hooks import hook_tool |
nexpaq | 1:55a6170b404f | 23 | |
nexpaq | 1:55a6170b404f | 24 | class GCC(mbedToolchain): |
nexpaq | 1:55a6170b404f | 25 | LINKER_EXT = '.ld' |
nexpaq | 1:55a6170b404f | 26 | LIBRARY_EXT = '.a' |
nexpaq | 1:55a6170b404f | 27 | |
nexpaq | 1:55a6170b404f | 28 | STD_LIB_NAME = "lib%s.a" |
nexpaq | 1:55a6170b404f | 29 | DIAGNOSTIC_PATTERN = re.compile('((?P<file>[^:]+):(?P<line>\d+):)(\d+:)? (?P<severity>warning|error): (?P<message>.+)') |
nexpaq | 1:55a6170b404f | 30 | INDEX_PATTERN = re.compile('(?P<col>\s*)\^') |
nexpaq | 1:55a6170b404f | 31 | |
nexpaq | 1:55a6170b404f | 32 | DEFAULT_FLAGS = { |
nexpaq | 1:55a6170b404f | 33 | 'common': ["-c", "-Wall", "-Wextra", |
nexpaq | 1:55a6170b404f | 34 | "-Wno-unused-parameter", "-Wno-missing-field-initializers", |
nexpaq | 1:55a6170b404f | 35 | "-fmessage-length=0", "-fno-exceptions", "-fno-builtin", |
nexpaq | 1:55a6170b404f | 36 | "-ffunction-sections", "-fdata-sections", "-funsigned-char", |
nexpaq | 1:55a6170b404f | 37 | "-MMD", "-fno-delete-null-pointer-checks", "-fomit-frame-pointer" |
nexpaq | 1:55a6170b404f | 38 | ], |
nexpaq | 1:55a6170b404f | 39 | 'asm': ["-x", "assembler-with-cpp"], |
nexpaq | 1:55a6170b404f | 40 | 'c': ["-std=gnu99"], |
nexpaq | 1:55a6170b404f | 41 | 'cxx': ["-std=gnu++98", "-fno-rtti", "-Wvla"], |
nexpaq | 1:55a6170b404f | 42 | 'ld': ["-Wl,--gc-sections", "-Wl,--wrap,main", |
nexpaq | 1:55a6170b404f | 43 | "-Wl,--wrap,_malloc_r", "-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r", "-Wl,--wrap,_calloc_r"], |
nexpaq | 1:55a6170b404f | 44 | } |
nexpaq | 1:55a6170b404f | 45 | |
nexpaq | 1:55a6170b404f | 46 | def __init__(self, target, options=None, notify=None, macros=None, silent=False, tool_path="", extra_verbose=False): |
nexpaq | 1:55a6170b404f | 47 | mbedToolchain.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose) |
nexpaq | 1:55a6170b404f | 48 | |
nexpaq | 1:55a6170b404f | 49 | if target.core == "Cortex-M0+": |
nexpaq | 1:55a6170b404f | 50 | cpu = "cortex-m0plus" |
nexpaq | 1:55a6170b404f | 51 | elif target.core == "Cortex-M4F": |
nexpaq | 1:55a6170b404f | 52 | cpu = "cortex-m4" |
nexpaq | 1:55a6170b404f | 53 | elif target.core == "Cortex-M7F": |
nexpaq | 1:55a6170b404f | 54 | cpu = "cortex-m7" |
nexpaq | 1:55a6170b404f | 55 | elif target.core == "Cortex-M7FD": |
nexpaq | 1:55a6170b404f | 56 | cpu = "cortex-m7" |
nexpaq | 1:55a6170b404f | 57 | else: |
nexpaq | 1:55a6170b404f | 58 | cpu = target.core.lower() |
nexpaq | 1:55a6170b404f | 59 | |
nexpaq | 1:55a6170b404f | 60 | self.cpu = ["-mcpu=%s" % cpu] |
nexpaq | 1:55a6170b404f | 61 | if target.core.startswith("Cortex"): |
nexpaq | 1:55a6170b404f | 62 | self.cpu.append("-mthumb") |
nexpaq | 1:55a6170b404f | 63 | |
nexpaq | 1:55a6170b404f | 64 | # FPU handling, M7 possibly to have double FPU |
nexpaq | 1:55a6170b404f | 65 | if target.core == "Cortex-M4F": |
nexpaq | 1:55a6170b404f | 66 | self.cpu.append("-mfpu=fpv4-sp-d16") |
nexpaq | 1:55a6170b404f | 67 | self.cpu.append("-mfloat-abi=softfp") |
nexpaq | 1:55a6170b404f | 68 | elif target.core == "Cortex-M7F": |
nexpaq | 1:55a6170b404f | 69 | self.cpu.append("-mfpu=fpv5-sp-d16") |
nexpaq | 1:55a6170b404f | 70 | self.cpu.append("-mfloat-abi=softfp") |
nexpaq | 1:55a6170b404f | 71 | elif target.core == "Cortex-M7FD": |
nexpaq | 1:55a6170b404f | 72 | self.cpu.append("-mfpu=fpv5-d16") |
nexpaq | 1:55a6170b404f | 73 | self.cpu.append("-mfloat-abi=softfp") |
nexpaq | 1:55a6170b404f | 74 | |
nexpaq | 1:55a6170b404f | 75 | |
nexpaq | 1:55a6170b404f | 76 | |
nexpaq | 1:55a6170b404f | 77 | if target.core == "Cortex-A9": |
nexpaq | 1:55a6170b404f | 78 | self.cpu.append("-mthumb-interwork") |
nexpaq | 1:55a6170b404f | 79 | self.cpu.append("-marm") |
nexpaq | 1:55a6170b404f | 80 | self.cpu.append("-march=armv7-a") |
nexpaq | 1:55a6170b404f | 81 | self.cpu.append("-mfpu=vfpv3") |
nexpaq | 1:55a6170b404f | 82 | self.cpu.append("-mfloat-abi=hard") |
nexpaq | 1:55a6170b404f | 83 | self.cpu.append("-mno-unaligned-access") |
nexpaq | 1:55a6170b404f | 84 | |
nexpaq | 1:55a6170b404f | 85 | |
nexpaq | 1:55a6170b404f | 86 | # Note: We are using "-O2" instead of "-Os" to avoid this known GCC bug: |
nexpaq | 1:55a6170b404f | 87 | # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46762 |
nexpaq | 1:55a6170b404f | 88 | self.flags["common"] += self.cpu |
nexpaq | 1:55a6170b404f | 89 | |
nexpaq | 1:55a6170b404f | 90 | if "save-asm" in self.options: |
nexpaq | 1:55a6170b404f | 91 | self.flags["common"].append("-save-temps") |
nexpaq | 1:55a6170b404f | 92 | |
nexpaq | 1:55a6170b404f | 93 | if "debug-info" in self.options: |
nexpaq | 1:55a6170b404f | 94 | self.flags["common"].append("-g") |
nexpaq | 1:55a6170b404f | 95 | self.flags["common"].append("-O0") |
nexpaq | 1:55a6170b404f | 96 | else: |
nexpaq | 1:55a6170b404f | 97 | self.flags["common"].append("-Os") |
nexpaq | 1:55a6170b404f | 98 | |
nexpaq | 1:55a6170b404f | 99 | main_cc = join(tool_path, "arm-none-eabi-gcc") |
nexpaq | 1:55a6170b404f | 100 | main_cppc = join(tool_path, "arm-none-eabi-g++") |
nexpaq | 1:55a6170b404f | 101 | self.asm = [main_cc] + self.flags['asm'] + self.flags["common"] |
nexpaq | 1:55a6170b404f | 102 | self.cc = [main_cc] |
nexpaq | 1:55a6170b404f | 103 | self.cppc =[main_cppc] |
nexpaq | 1:55a6170b404f | 104 | self.cc += self.flags['c'] + self.flags['common'] |
nexpaq | 1:55a6170b404f | 105 | self.cppc += self.flags['cxx'] + self.flags['common'] |
nexpaq | 1:55a6170b404f | 106 | |
nexpaq | 1:55a6170b404f | 107 | self.flags['ld'] += self.cpu |
nexpaq | 1:55a6170b404f | 108 | self.ld = [join(tool_path, "arm-none-eabi-gcc")] + self.flags['ld'] |
nexpaq | 1:55a6170b404f | 109 | self.sys_libs = ["stdc++", "supc++", "m", "c", "gcc"] |
nexpaq | 1:55a6170b404f | 110 | |
nexpaq | 1:55a6170b404f | 111 | self.ar = join(tool_path, "arm-none-eabi-ar") |
nexpaq | 1:55a6170b404f | 112 | self.elf2bin = join(tool_path, "arm-none-eabi-objcopy") |
nexpaq | 1:55a6170b404f | 113 | |
nexpaq | 1:55a6170b404f | 114 | if tool_path: |
nexpaq | 1:55a6170b404f | 115 | self.toolchain_path = main_cc |
nexpaq | 1:55a6170b404f | 116 | else: |
nexpaq | 1:55a6170b404f | 117 | self.toolchain_path = find_executable("arm-none-eabi-gcc") or '' |
nexpaq | 1:55a6170b404f | 118 | |
nexpaq | 1:55a6170b404f | 119 | def parse_dependencies(self, dep_path): |
nexpaq | 1:55a6170b404f | 120 | dependencies = [] |
nexpaq | 1:55a6170b404f | 121 | buff = open(dep_path).readlines() |
nexpaq | 1:55a6170b404f | 122 | buff[0] = re.sub('^(.*?)\: ', '', buff[0]) |
nexpaq | 1:55a6170b404f | 123 | for line in buff: |
nexpaq | 1:55a6170b404f | 124 | file = line.replace('\\\n', '').strip() |
nexpaq | 1:55a6170b404f | 125 | if file: |
nexpaq | 1:55a6170b404f | 126 | # GCC might list more than one dependency on a single line, in this case |
nexpaq | 1:55a6170b404f | 127 | # the dependencies are separated by a space. However, a space might also |
nexpaq | 1:55a6170b404f | 128 | # indicate an actual space character in a dependency path, but in this case |
nexpaq | 1:55a6170b404f | 129 | # the space character is prefixed by a backslash. |
nexpaq | 1:55a6170b404f | 130 | # Temporary replace all '\ ' with a special char that is not used (\a in this |
nexpaq | 1:55a6170b404f | 131 | # case) to keep them from being interpreted by 'split' (they will be converted |
nexpaq | 1:55a6170b404f | 132 | # back later to a space char) |
nexpaq | 1:55a6170b404f | 133 | file = file.replace('\\ ', '\a') |
nexpaq | 1:55a6170b404f | 134 | if file.find(" ") == -1: |
nexpaq | 1:55a6170b404f | 135 | dependencies.append((self.CHROOT if self.CHROOT else '') + file.replace('\a', ' ')) |
nexpaq | 1:55a6170b404f | 136 | else: |
nexpaq | 1:55a6170b404f | 137 | dependencies = dependencies + [(self.CHROOT if self.CHROOT else '') + f.replace('\a', ' ') for f in file.split(" ")] |
nexpaq | 1:55a6170b404f | 138 | return dependencies |
nexpaq | 1:55a6170b404f | 139 | |
nexpaq | 1:55a6170b404f | 140 | def is_not_supported_error(self, output): |
nexpaq | 1:55a6170b404f | 141 | return "error: #error [NOT_SUPPORTED]" in output |
nexpaq | 1:55a6170b404f | 142 | |
nexpaq | 1:55a6170b404f | 143 | def parse_output(self, output): |
nexpaq | 1:55a6170b404f | 144 | # The warning/error notification is multiline |
nexpaq | 1:55a6170b404f | 145 | msg = None |
nexpaq | 1:55a6170b404f | 146 | for line in output.splitlines(): |
nexpaq | 1:55a6170b404f | 147 | match = GCC.DIAGNOSTIC_PATTERN.search(line) |
nexpaq | 1:55a6170b404f | 148 | if match is not None: |
nexpaq | 1:55a6170b404f | 149 | if msg is not None: |
nexpaq | 1:55a6170b404f | 150 | self.cc_info(msg) |
nexpaq | 1:55a6170b404f | 151 | msg = { |
nexpaq | 1:55a6170b404f | 152 | 'severity': match.group('severity').lower(), |
nexpaq | 1:55a6170b404f | 153 | 'file': match.group('file'), |
nexpaq | 1:55a6170b404f | 154 | 'line': match.group('line'), |
nexpaq | 1:55a6170b404f | 155 | 'col': 0, |
nexpaq | 1:55a6170b404f | 156 | 'message': match.group('message'), |
nexpaq | 1:55a6170b404f | 157 | 'text': '', |
nexpaq | 1:55a6170b404f | 158 | 'target_name': self.target.name, |
nexpaq | 1:55a6170b404f | 159 | 'toolchain_name': self.name |
nexpaq | 1:55a6170b404f | 160 | } |
nexpaq | 1:55a6170b404f | 161 | elif msg is not None: |
nexpaq | 1:55a6170b404f | 162 | # Determine the warning/error column by calculating the ^ position |
nexpaq | 1:55a6170b404f | 163 | match = GCC.INDEX_PATTERN.match(line) |
nexpaq | 1:55a6170b404f | 164 | if match is not None: |
nexpaq | 1:55a6170b404f | 165 | msg['col'] = len(match.group('col')) |
nexpaq | 1:55a6170b404f | 166 | self.cc_info(msg) |
nexpaq | 1:55a6170b404f | 167 | msg = None |
nexpaq | 1:55a6170b404f | 168 | else: |
nexpaq | 1:55a6170b404f | 169 | msg['text'] += line+"\n" |
nexpaq | 1:55a6170b404f | 170 | |
nexpaq | 1:55a6170b404f | 171 | def get_dep_option(self, object): |
nexpaq | 1:55a6170b404f | 172 | base, _ = splitext(object) |
nexpaq | 1:55a6170b404f | 173 | dep_path = base + '.d' |
nexpaq | 1:55a6170b404f | 174 | return ["-MD", "-MF", dep_path] |
nexpaq | 1:55a6170b404f | 175 | |
nexpaq | 1:55a6170b404f | 176 | def get_config_option(self, config_header): |
nexpaq | 1:55a6170b404f | 177 | return ['-include', config_header] |
nexpaq | 1:55a6170b404f | 178 | |
nexpaq | 1:55a6170b404f | 179 | def get_compile_options(self, defines, includes, for_asm=False): |
nexpaq | 1:55a6170b404f | 180 | opts = ['-D%s' % d for d in defines] |
nexpaq | 1:55a6170b404f | 181 | if self.RESPONSE_FILES: |
nexpaq | 1:55a6170b404f | 182 | opts += ['@%s' % self.get_inc_file(includes)] |
nexpaq | 1:55a6170b404f | 183 | else: |
nexpaq | 1:55a6170b404f | 184 | opts += ["-I%s" % i for i in includes] |
nexpaq | 1:55a6170b404f | 185 | |
nexpaq | 1:55a6170b404f | 186 | if not for_asm: |
nexpaq | 1:55a6170b404f | 187 | config_header = self.get_config_header() |
nexpaq | 1:55a6170b404f | 188 | if config_header is not None: |
nexpaq | 1:55a6170b404f | 189 | opts = opts + self.get_config_option(config_header) |
nexpaq | 1:55a6170b404f | 190 | return opts |
nexpaq | 1:55a6170b404f | 191 | |
nexpaq | 1:55a6170b404f | 192 | @hook_tool |
nexpaq | 1:55a6170b404f | 193 | def assemble(self, source, object, includes): |
nexpaq | 1:55a6170b404f | 194 | # Build assemble command |
nexpaq | 1:55a6170b404f | 195 | cmd = self.asm + self.get_compile_options(self.get_symbols(True), includes) + ["-o", object, source] |
nexpaq | 1:55a6170b404f | 196 | |
nexpaq | 1:55a6170b404f | 197 | # Call cmdline hook |
nexpaq | 1:55a6170b404f | 198 | cmd = self.hook.get_cmdline_assembler(cmd) |
nexpaq | 1:55a6170b404f | 199 | |
nexpaq | 1:55a6170b404f | 200 | # Return command array, don't execute |
nexpaq | 1:55a6170b404f | 201 | return [cmd] |
nexpaq | 1:55a6170b404f | 202 | |
nexpaq | 1:55a6170b404f | 203 | @hook_tool |
nexpaq | 1:55a6170b404f | 204 | def compile(self, cc, source, object, includes): |
nexpaq | 1:55a6170b404f | 205 | # Build compile command |
nexpaq | 1:55a6170b404f | 206 | cmd = cc + self.get_compile_options(self.get_symbols(), includes) |
nexpaq | 1:55a6170b404f | 207 | |
nexpaq | 1:55a6170b404f | 208 | cmd.extend(self.get_dep_option(object)) |
nexpaq | 1:55a6170b404f | 209 | |
nexpaq | 1:55a6170b404f | 210 | cmd.extend(["-o", object, source]) |
nexpaq | 1:55a6170b404f | 211 | |
nexpaq | 1:55a6170b404f | 212 | # Call cmdline hook |
nexpaq | 1:55a6170b404f | 213 | cmd = self.hook.get_cmdline_compiler(cmd) |
nexpaq | 1:55a6170b404f | 214 | |
nexpaq | 1:55a6170b404f | 215 | return [cmd] |
nexpaq | 1:55a6170b404f | 216 | |
nexpaq | 1:55a6170b404f | 217 | def compile_c(self, source, object, includes): |
nexpaq | 1:55a6170b404f | 218 | return self.compile(self.cc, source, object, includes) |
nexpaq | 1:55a6170b404f | 219 | |
nexpaq | 1:55a6170b404f | 220 | def compile_cpp(self, source, object, includes): |
nexpaq | 1:55a6170b404f | 221 | return self.compile(self.cppc, source, object, includes) |
nexpaq | 1:55a6170b404f | 222 | |
nexpaq | 1:55a6170b404f | 223 | @hook_tool |
nexpaq | 1:55a6170b404f | 224 | def link(self, output, objects, libraries, lib_dirs, mem_map): |
nexpaq | 1:55a6170b404f | 225 | libs = [] |
nexpaq | 1:55a6170b404f | 226 | for l in libraries: |
nexpaq | 1:55a6170b404f | 227 | name, _ = splitext(basename(l)) |
nexpaq | 1:55a6170b404f | 228 | libs.append("-l%s" % name[3:]) |
nexpaq | 1:55a6170b404f | 229 | libs.extend(["-l%s" % l for l in self.sys_libs]) |
nexpaq | 1:55a6170b404f | 230 | |
nexpaq | 1:55a6170b404f | 231 | # Build linker command |
nexpaq | 1:55a6170b404f | 232 | map_file = splitext(output)[0] + ".map" |
nexpaq | 1:55a6170b404f | 233 | cmd = self.ld + ["-o", output, "-Wl,-Map=%s" % map_file] + objects + ["-Wl,--start-group"] + libs + ["-Wl,--end-group"] |
nexpaq | 1:55a6170b404f | 234 | if mem_map: |
nexpaq | 1:55a6170b404f | 235 | cmd.extend(['-T', mem_map]) |
nexpaq | 1:55a6170b404f | 236 | |
nexpaq | 1:55a6170b404f | 237 | for L in lib_dirs: |
nexpaq | 1:55a6170b404f | 238 | cmd.extend(['-L', L]) |
nexpaq | 1:55a6170b404f | 239 | cmd.extend(libs) |
nexpaq | 1:55a6170b404f | 240 | |
nexpaq | 1:55a6170b404f | 241 | # Call cmdline hook |
nexpaq | 1:55a6170b404f | 242 | cmd = self.hook.get_cmdline_linker(cmd) |
nexpaq | 1:55a6170b404f | 243 | |
nexpaq | 1:55a6170b404f | 244 | if self.RESPONSE_FILES: |
nexpaq | 1:55a6170b404f | 245 | # Split link command to linker executable + response file |
nexpaq | 1:55a6170b404f | 246 | cmd_linker = cmd[0] |
nexpaq | 1:55a6170b404f | 247 | link_files = self.get_link_file(cmd[1:]) |
nexpaq | 1:55a6170b404f | 248 | cmd = [cmd_linker, "@%s" % link_files] |
nexpaq | 1:55a6170b404f | 249 | |
nexpaq | 1:55a6170b404f | 250 | # Exec command |
nexpaq | 1:55a6170b404f | 251 | self.cc_verbose("Link: %s" % ' '.join(cmd)) |
nexpaq | 1:55a6170b404f | 252 | self.default_cmd(cmd) |
nexpaq | 1:55a6170b404f | 253 | |
nexpaq | 1:55a6170b404f | 254 | @hook_tool |
nexpaq | 1:55a6170b404f | 255 | def archive(self, objects, lib_path): |
nexpaq | 1:55a6170b404f | 256 | if self.RESPONSE_FILES: |
nexpaq | 1:55a6170b404f | 257 | param = ["@%s" % self.get_arch_file(objects)] |
nexpaq | 1:55a6170b404f | 258 | else: |
nexpaq | 1:55a6170b404f | 259 | param = objects |
nexpaq | 1:55a6170b404f | 260 | |
nexpaq | 1:55a6170b404f | 261 | # Exec command |
nexpaq | 1:55a6170b404f | 262 | self.default_cmd([self.ar, 'rcs', lib_path] + param) |
nexpaq | 1:55a6170b404f | 263 | |
nexpaq | 1:55a6170b404f | 264 | @hook_tool |
nexpaq | 1:55a6170b404f | 265 | def binary(self, resources, elf, bin): |
nexpaq | 1:55a6170b404f | 266 | # Build binary command |
nexpaq | 1:55a6170b404f | 267 | cmd = [self.elf2bin, "-O", "binary", elf, bin] |
nexpaq | 1:55a6170b404f | 268 | |
nexpaq | 1:55a6170b404f | 269 | # Call cmdline hook |
nexpaq | 1:55a6170b404f | 270 | cmd = self.hook.get_cmdline_binary(cmd) |
nexpaq | 1:55a6170b404f | 271 | |
nexpaq | 1:55a6170b404f | 272 | # Exec command |
nexpaq | 1:55a6170b404f | 273 | self.cc_verbose("FromELF: %s" % ' '.join(cmd)) |
nexpaq | 1:55a6170b404f | 274 | self.default_cmd(cmd) |
nexpaq | 1:55a6170b404f | 275 | |
nexpaq | 1:55a6170b404f | 276 | |
nexpaq | 1:55a6170b404f | 277 | class GCC_ARM(GCC): |
nexpaq | 1:55a6170b404f | 278 | def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False): |
nexpaq | 1:55a6170b404f | 279 | GCC.__init__(self, target, options, notify, macros, silent, TOOLCHAIN_PATHS['GCC_ARM'], extra_verbose=extra_verbose) |
nexpaq | 1:55a6170b404f | 280 | |
nexpaq | 1:55a6170b404f | 281 | # Use latest gcc nanolib |
nexpaq | 1:55a6170b404f | 282 | if "std-lib" in self.options: |
nexpaq | 1:55a6170b404f | 283 | use_nano = False |
nexpaq | 1:55a6170b404f | 284 | elif "small-lib" in self.options: |
nexpaq | 1:55a6170b404f | 285 | use_nano = True |
nexpaq | 1:55a6170b404f | 286 | elif target.default_lib == "std": |
nexpaq | 1:55a6170b404f | 287 | use_nano = False |
nexpaq | 1:55a6170b404f | 288 | elif target.default_lib == "small": |
nexpaq | 1:55a6170b404f | 289 | use_nano = True |
nexpaq | 1:55a6170b404f | 290 | else: |
nexpaq | 1:55a6170b404f | 291 | use_nano = False |
nexpaq | 1:55a6170b404f | 292 | |
nexpaq | 1:55a6170b404f | 293 | if use_nano: |
nexpaq | 1:55a6170b404f | 294 | self.ld.append("--specs=nano.specs") |
nexpaq | 1:55a6170b404f | 295 | self.flags['ld'].append("--specs=nano.specs") |
nexpaq | 1:55a6170b404f | 296 | self.cc += ["-DMBED_RTOS_SINGLE_THREAD"] |
nexpaq | 1:55a6170b404f | 297 | self.cppc += ["-DMBED_RTOS_SINGLE_THREAD"] |
nexpaq | 1:55a6170b404f | 298 | self.macros.extend(["MBED_RTOS_SINGLE_THREAD"]) |
nexpaq | 1:55a6170b404f | 299 | self.sys_libs.append("nosys") |
nexpaq | 1:55a6170b404f | 300 | |
nexpaq | 1:55a6170b404f | 301 | |
nexpaq | 1:55a6170b404f | 302 | class GCC_CR(GCC): |
nexpaq | 1:55a6170b404f | 303 | def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False): |
nexpaq | 1:55a6170b404f | 304 | GCC.__init__(self, target, options, notify, macros, silent, TOOLCHAIN_PATHS['GCC_CR'], extra_verbose=extra_verbose) |
nexpaq | 1:55a6170b404f | 305 | |
nexpaq | 1:55a6170b404f | 306 | additional_compiler_flags = [ |
nexpaq | 1:55a6170b404f | 307 | "-D__NEWLIB__", "-D__CODE_RED", "-D__USE_CMSIS", "-DCPP_USE_HEAP", |
nexpaq | 1:55a6170b404f | 308 | ] |
nexpaq | 1:55a6170b404f | 309 | self.cc += additional_compiler_flags |
nexpaq | 1:55a6170b404f | 310 | self.cppc += additional_compiler_flags |
nexpaq | 1:55a6170b404f | 311 | |
nexpaq | 1:55a6170b404f | 312 | # Use latest gcc nanolib |
nexpaq | 1:55a6170b404f | 313 | self.ld.append("--specs=nano.specs") |
nexpaq | 1:55a6170b404f | 314 | if target.name in ["LPC1768", "LPC4088", "LPC4088_DM", "LPC4330", "UBLOX_C027", "LPC2368"]: |
nexpaq | 1:55a6170b404f | 315 | self.ld.extend(["-u _printf_float", "-u _scanf_float"]) |
nexpaq | 1:55a6170b404f | 316 | self.ld += ["-nostdlib"] |