dhgdh
Dependencies: MAX44000 PWM_Tone_Library nexpaq_mdk
Fork of LED_Demo by
mbd_os/tools/export/gccarm.py@1:55a6170b404f, 2016-09-17 (annotated)
- Committer:
- nexpaq
- Date:
- Sat Sep 17 16:32:05 2016 +0000
- Revision:
- 1:55a6170b404f
checking in for sharing
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-2016 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 | from os.path import splitext, basename, relpath, join, abspath, dirname |
nexpaq | 1:55a6170b404f | 18 | from os import curdir, getcwd |
nexpaq | 1:55a6170b404f | 19 | from tools.export.exporters import Exporter |
nexpaq | 1:55a6170b404f | 20 | |
nexpaq | 1:55a6170b404f | 21 | |
nexpaq | 1:55a6170b404f | 22 | class GccArm(Exporter): |
nexpaq | 1:55a6170b404f | 23 | NAME = 'GccArm' |
nexpaq | 1:55a6170b404f | 24 | TOOLCHAIN = 'GCC_ARM' |
nexpaq | 1:55a6170b404f | 25 | |
nexpaq | 1:55a6170b404f | 26 | TARGETS = [ |
nexpaq | 1:55a6170b404f | 27 | 'LPC1768', |
nexpaq | 1:55a6170b404f | 28 | 'LPC1549', |
nexpaq | 1:55a6170b404f | 29 | 'KL05Z', |
nexpaq | 1:55a6170b404f | 30 | 'KL25Z', |
nexpaq | 1:55a6170b404f | 31 | 'KL43Z', |
nexpaq | 1:55a6170b404f | 32 | 'KL46Z', |
nexpaq | 1:55a6170b404f | 33 | 'K64F', |
nexpaq | 1:55a6170b404f | 34 | 'K22F', |
nexpaq | 1:55a6170b404f | 35 | 'K20D50M', |
nexpaq | 1:55a6170b404f | 36 | 'LPC4088', |
nexpaq | 1:55a6170b404f | 37 | 'LPC4088_DM', |
nexpaq | 1:55a6170b404f | 38 | 'LPC4330_M4', |
nexpaq | 1:55a6170b404f | 39 | 'LPC11U24', |
nexpaq | 1:55a6170b404f | 40 | 'LPC1114', |
nexpaq | 1:55a6170b404f | 41 | 'LPC11U35_401', |
nexpaq | 1:55a6170b404f | 42 | 'LPC11U35_501', |
nexpaq | 1:55a6170b404f | 43 | 'LPC11U37H_401', |
nexpaq | 1:55a6170b404f | 44 | 'LPC810', |
nexpaq | 1:55a6170b404f | 45 | 'LPC812', |
nexpaq | 1:55a6170b404f | 46 | 'LPC824', |
nexpaq | 1:55a6170b404f | 47 | 'SSCI824', |
nexpaq | 1:55a6170b404f | 48 | 'STM32F407', |
nexpaq | 1:55a6170b404f | 49 | 'DISCO_F100RB', |
nexpaq | 1:55a6170b404f | 50 | 'DISCO_F051R8', |
nexpaq | 1:55a6170b404f | 51 | 'DISCO_F407VG', |
nexpaq | 1:55a6170b404f | 52 | 'DISCO_F429ZI', |
nexpaq | 1:55a6170b404f | 53 | 'DISCO_F469NI', |
nexpaq | 1:55a6170b404f | 54 | 'DISCO_F303VC', |
nexpaq | 1:55a6170b404f | 55 | 'DISCO_F746NG', |
nexpaq | 1:55a6170b404f | 56 | 'DISCO_F769NI', |
nexpaq | 1:55a6170b404f | 57 | 'DISCO_L476VG', |
nexpaq | 1:55a6170b404f | 58 | 'UBLOX_C027', |
nexpaq | 1:55a6170b404f | 59 | 'ARCH_PRO', |
nexpaq | 1:55a6170b404f | 60 | 'NRF51822', |
nexpaq | 1:55a6170b404f | 61 | 'HRM1017', |
nexpaq | 1:55a6170b404f | 62 | 'TY51822R3', |
nexpaq | 1:55a6170b404f | 63 | 'RBLAB_NRF51822', |
nexpaq | 1:55a6170b404f | 64 | 'RBLAB_BLENANO', |
nexpaq | 1:55a6170b404f | 65 | 'LPC2368', |
nexpaq | 1:55a6170b404f | 66 | 'LPC2460', |
nexpaq | 1:55a6170b404f | 67 | 'LPCCAPPUCCINO', |
nexpaq | 1:55a6170b404f | 68 | 'ARCH_BLE', |
nexpaq | 1:55a6170b404f | 69 | 'MTS_GAMBIT', |
nexpaq | 1:55a6170b404f | 70 | 'ARCH_MAX', |
nexpaq | 1:55a6170b404f | 71 | 'NUCLEO_F401RE', |
nexpaq | 1:55a6170b404f | 72 | 'NUCLEO_F410RB', |
nexpaq | 1:55a6170b404f | 73 | 'NUCLEO_F411RE', |
nexpaq | 1:55a6170b404f | 74 | 'NUCLEO_F429ZI', |
nexpaq | 1:55a6170b404f | 75 | 'NUCLEO_F446RE', |
nexpaq | 1:55a6170b404f | 76 | 'NUCLEO_F446ZE', |
nexpaq | 1:55a6170b404f | 77 | 'B96B_F446VE', |
nexpaq | 1:55a6170b404f | 78 | 'ARCH_MAX', |
nexpaq | 1:55a6170b404f | 79 | 'NUCLEO_F030R8', |
nexpaq | 1:55a6170b404f | 80 | 'NUCLEO_F031K6', |
nexpaq | 1:55a6170b404f | 81 | 'NUCLEO_F042K6', |
nexpaq | 1:55a6170b404f | 82 | 'NUCLEO_F070RB', |
nexpaq | 1:55a6170b404f | 83 | 'NUCLEO_F072RB', |
nexpaq | 1:55a6170b404f | 84 | 'NUCLEO_F091RC', |
nexpaq | 1:55a6170b404f | 85 | 'NUCLEO_F103RB', |
nexpaq | 1:55a6170b404f | 86 | 'NUCLEO_F207ZG', |
nexpaq | 1:55a6170b404f | 87 | 'NUCLEO_F302R8', |
nexpaq | 1:55a6170b404f | 88 | 'NUCLEO_F303K8', |
nexpaq | 1:55a6170b404f | 89 | 'NUCLEO_F303RE', |
nexpaq | 1:55a6170b404f | 90 | 'NUCLEO_F334R8', |
nexpaq | 1:55a6170b404f | 91 | 'NUCLEO_F303ZE', |
nexpaq | 1:55a6170b404f | 92 | 'NUCLEO_F746ZG', |
nexpaq | 1:55a6170b404f | 93 | 'NUCLEO_F767ZI', |
nexpaq | 1:55a6170b404f | 94 | 'DISCO_L053C8', |
nexpaq | 1:55a6170b404f | 95 | 'NUCLEO_L011K4', |
nexpaq | 1:55a6170b404f | 96 | 'NUCLEO_L031K6', |
nexpaq | 1:55a6170b404f | 97 | 'NUCLEO_L053R8', |
nexpaq | 1:55a6170b404f | 98 | 'NUCLEO_L073RZ', |
nexpaq | 1:55a6170b404f | 99 | 'NUCLEO_L432KC', |
nexpaq | 1:55a6170b404f | 100 | 'NUCLEO_L476RG', |
nexpaq | 1:55a6170b404f | 101 | 'DISCO_F334C8', |
nexpaq | 1:55a6170b404f | 102 | 'MAX32600MBED', |
nexpaq | 1:55a6170b404f | 103 | 'MAXWSNENV', |
nexpaq | 1:55a6170b404f | 104 | 'MAX32620HSP', |
nexpaq | 1:55a6170b404f | 105 | 'MTS_MDOT_F405RG', |
nexpaq | 1:55a6170b404f | 106 | 'MTS_MDOT_F411RE', |
nexpaq | 1:55a6170b404f | 107 | 'NUCLEO_L152RE', |
nexpaq | 1:55a6170b404f | 108 | 'NRF51_DK', |
nexpaq | 1:55a6170b404f | 109 | 'NRF51_DONGLE', |
nexpaq | 1:55a6170b404f | 110 | 'NRF51_MICROBIT', |
nexpaq | 1:55a6170b404f | 111 | 'MTM_MTCONNECT04S', |
nexpaq | 1:55a6170b404f | 112 | 'SEEED_TINY_BLE', |
nexpaq | 1:55a6170b404f | 113 | 'DISCO_F401VC', |
nexpaq | 1:55a6170b404f | 114 | 'DELTA_DFCM_NNN40', |
nexpaq | 1:55a6170b404f | 115 | 'RZ_A1H', |
nexpaq | 1:55a6170b404f | 116 | 'MOTE_L152RC', |
nexpaq | 1:55a6170b404f | 117 | 'EFM32WG_STK3800', |
nexpaq | 1:55a6170b404f | 118 | 'EFM32LG_STK3600', |
nexpaq | 1:55a6170b404f | 119 | 'EFM32GG_STK3700', |
nexpaq | 1:55a6170b404f | 120 | 'EFM32ZG_STK3200', |
nexpaq | 1:55a6170b404f | 121 | 'EFM32HG_STK3400', |
nexpaq | 1:55a6170b404f | 122 | 'EFM32PG_STK3401', |
nexpaq | 1:55a6170b404f | 123 | 'NZ32_SC151', |
nexpaq | 1:55a6170b404f | 124 | 'SAMR21G18A', |
nexpaq | 1:55a6170b404f | 125 | 'TEENSY3_1', |
nexpaq | 1:55a6170b404f | 126 | 'SAMD21J18A', |
nexpaq | 1:55a6170b404f | 127 | 'SAMD21G18A', |
nexpaq | 1:55a6170b404f | 128 | 'SAML21J18A', |
nexpaq | 1:55a6170b404f | 129 | 'SAMG55J19', |
nexpaq | 1:55a6170b404f | 130 | 'ARM_BEETLE_SOC', |
nexpaq | 1:55a6170b404f | 131 | 'ELMO_F411RE', |
nexpaq | 1:55a6170b404f | 132 | 'BLUEPILL_F103C8', |
nexpaq | 1:55a6170b404f | 133 | ] |
nexpaq | 1:55a6170b404f | 134 | |
nexpaq | 1:55a6170b404f | 135 | DOT_IN_RELATIVE_PATH = True |
nexpaq | 1:55a6170b404f | 136 | |
nexpaq | 1:55a6170b404f | 137 | MBED_CONFIG_HEADER_SUPPORTED = True |
nexpaq | 1:55a6170b404f | 138 | |
nexpaq | 1:55a6170b404f | 139 | def generate(self): |
nexpaq | 1:55a6170b404f | 140 | # "make" wants Unix paths |
nexpaq | 1:55a6170b404f | 141 | self.resources.win_to_unix() |
nexpaq | 1:55a6170b404f | 142 | |
nexpaq | 1:55a6170b404f | 143 | to_be_compiled = [] |
nexpaq | 1:55a6170b404f | 144 | for r_type in ['s_sources', 'c_sources', 'cpp_sources']: |
nexpaq | 1:55a6170b404f | 145 | r = getattr(self.resources, r_type) |
nexpaq | 1:55a6170b404f | 146 | if r: |
nexpaq | 1:55a6170b404f | 147 | for source in r: |
nexpaq | 1:55a6170b404f | 148 | base, ext = splitext(source) |
nexpaq | 1:55a6170b404f | 149 | to_be_compiled.append(base + '.o') |
nexpaq | 1:55a6170b404f | 150 | |
nexpaq | 1:55a6170b404f | 151 | libraries = [] |
nexpaq | 1:55a6170b404f | 152 | for lib in self.resources.libraries: |
nexpaq | 1:55a6170b404f | 153 | l, _ = splitext(basename(lib)) |
nexpaq | 1:55a6170b404f | 154 | libraries.append(l[3:]) |
nexpaq | 1:55a6170b404f | 155 | |
nexpaq | 1:55a6170b404f | 156 | ctx = { |
nexpaq | 1:55a6170b404f | 157 | 'name': self.project_name, |
nexpaq | 1:55a6170b404f | 158 | 'to_be_compiled': to_be_compiled, |
nexpaq | 1:55a6170b404f | 159 | 'object_files': self.resources.objects, |
nexpaq | 1:55a6170b404f | 160 | 'include_paths': self.resources.inc_dirs, |
nexpaq | 1:55a6170b404f | 161 | 'library_paths': self.resources.lib_dirs, |
nexpaq | 1:55a6170b404f | 162 | 'linker_script': self.resources.linker_script, |
nexpaq | 1:55a6170b404f | 163 | 'libraries': libraries, |
nexpaq | 1:55a6170b404f | 164 | 'symbols': self.toolchain.get_symbols(), |
nexpaq | 1:55a6170b404f | 165 | 'cpu_flags': self.toolchain.cpu, |
nexpaq | 1:55a6170b404f | 166 | 'hex_files': self.resources.hex_files, |
nexpaq | 1:55a6170b404f | 167 | 'vpath': (["../../.."] |
nexpaq | 1:55a6170b404f | 168 | if basename(dirname(dirname(self.export_dir))) == "projectfiles" |
nexpaq | 1:55a6170b404f | 169 | else [".."]) |
nexpaq | 1:55a6170b404f | 170 | } |
nexpaq | 1:55a6170b404f | 171 | |
nexpaq | 1:55a6170b404f | 172 | for key in ['include_paths', 'library_paths', 'linker_script', 'hex_files']: |
nexpaq | 1:55a6170b404f | 173 | if isinstance(ctx[key], list): |
nexpaq | 1:55a6170b404f | 174 | ctx[key] = [ctx['vpath'][0] + "/" + t for t in ctx[key]] |
nexpaq | 1:55a6170b404f | 175 | else: |
nexpaq | 1:55a6170b404f | 176 | ctx[key] = ctx['vpath'][0] + "/" + ctx[key] |
nexpaq | 1:55a6170b404f | 177 | if "../." not in ctx["include_paths"]: |
nexpaq | 1:55a6170b404f | 178 | ctx["include_paths"] += ['../.'] |
nexpaq | 1:55a6170b404f | 179 | ctx.update(self.flags) |
nexpaq | 1:55a6170b404f | 180 | self.gen_file('gcc_arm_%s.tmpl' % self.target.lower(), ctx, 'Makefile') |