Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-sdk-tools by
gccarm.py
00001 """ 00002 mbed SDK 00003 Copyright (c) 2011-2013 ARM Limited 00004 00005 Licensed under the Apache License, Version 2.0 (the "License"); 00006 you may not use this file except in compliance with the License. 00007 You may obtain a copy of the License at 00008 00009 http://www.apache.org/licenses/LICENSE-2.0 00010 00011 Unless required by applicable law or agreed to in writing, software 00012 distributed under the License is distributed on an "AS IS" BASIS, 00013 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 See the License for the specific language governing permissions and 00015 limitations under the License. 00016 """ 00017 from exporters import Exporter 00018 from os.path import splitext, basename, relpath, join, abspath 00019 from os import curdir, getcwd 00020 00021 00022 class GccArm(Exporter): 00023 NAME = 'GccArm' 00024 TOOLCHAIN = 'GCC_ARM' 00025 00026 TARGETS = [ 00027 'LPC1768', 00028 'LPC1549', 00029 'KL05Z', 00030 'KL25Z', 00031 'KL43Z', 00032 'KL46Z', 00033 'K64F', 00034 'K22F', 00035 'K20D50M', 00036 'LPC4088', 00037 'LPC4088_DM', 00038 'LPC4330_M4', 00039 'LPC11U24', 00040 'LPC1114', 00041 'LPC11U35_401', 00042 'LPC11U35_501', 00043 'LPC11U37H_401', 00044 'LPC810', 00045 'LPC812', 00046 'LPC824', 00047 'SSCI824', 00048 'STM32F407', 00049 'DISCO_F100RB', 00050 'DISCO_F051R8', 00051 'DISCO_F407VG', 00052 'DISCO_F429ZI', 00053 'DISCO_F469NI', 00054 'DISCO_F303VC', 00055 'DISCO_F746NG', 00056 'DISCO_L476VG', 00057 'UBLOX_C027', 00058 'ARCH_PRO', 00059 'NRF51822', 00060 'HRM1017', 00061 'TY51822R3', 00062 'RBLAB_NRF51822', 00063 'RBLAB_BLENANO', 00064 'LPC2368', 00065 'LPC2460', 00066 'LPCCAPPUCCINO', 00067 'ARCH_BLE', 00068 'MTS_GAMBIT', 00069 'ARCH_MAX', 00070 'NUCLEO_F401RE', 00071 'NUCLEO_F410RB', 00072 'NUCLEO_F411RE', 00073 'NUCLEO_F429ZI', 00074 'NUCLEO_F446RE', 00075 'NUCLEO_F446ZE', 00076 'B96B_F446VE', 00077 'ARCH_MAX', 00078 'NUCLEO_F030R8', 00079 'NUCLEO_F031K6', 00080 'NUCLEO_F042K6', 00081 'NUCLEO_F070RB', 00082 'NUCLEO_F072RB', 00083 'NUCLEO_F091RC', 00084 'NUCLEO_F103RB', 00085 'NUCLEO_F207ZG', 00086 'NUCLEO_F302R8', 00087 'NUCLEO_F303K8', 00088 'NUCLEO_F303RE', 00089 'NUCLEO_F334R8', 00090 'NUCLEO_F746ZG', 00091 'NUCLEO_F767ZI', 00092 'DISCO_L053C8', 00093 'NUCLEO_L011K4', 00094 'NUCLEO_L031K6', 00095 'NUCLEO_L053R8', 00096 'NUCLEO_L073RZ', 00097 'NUCLEO_L432KC', 00098 'NUCLEO_L476RG', 00099 'DISCO_F334C8', 00100 'MAX32600MBED', 00101 'MAXWSNENV', 00102 'MTS_MDOT_F405RG', 00103 'MTS_MDOT_F411RE', 00104 'NUCLEO_L152RE', 00105 'NRF51_DK', 00106 'NRF51_DONGLE', 00107 'NRF51_MICROBIT', 00108 'SEEED_TINY_BLE', 00109 'DISCO_F401VC', 00110 'DELTA_DFCM_NNN40', 00111 'RZ_A1H', 00112 'MOTE_L152RC', 00113 'EFM32WG_STK3800', 00114 'EFM32LG_STK3600', 00115 'EFM32GG_STK3700', 00116 'EFM32ZG_STK3200', 00117 'EFM32HG_STK3400', 00118 'EFM32PG_STK3401', 00119 'NZ32_SC151', 00120 'SAMR21G18A', 00121 'TEENSY3_1', 00122 'SAMD21J18A', 00123 'SAMD21G18A', 00124 'SAML21J18A', 00125 'SAMG55J19', 00126 'ARM_BEETLE_SOC', 00127 'ELMO_F411RE', 00128 'BLUEPILL_F103C8', 00129 ] 00130 00131 DOT_IN_RELATIVE_PATH = True 00132 00133 MBED_CONFIG_HEADER_SUPPORTED = True 00134 00135 def generate(self): 00136 # "make" wants Unix paths 00137 if self.sources_relative: 00138 self.resources.relative_to(self.prj_paths[0]) 00139 self.resources.win_to_unix() 00140 00141 to_be_compiled = [] 00142 for r_type in ['s_sources', 'c_sources', 'cpp_sources']: 00143 r = getattr(self.resources, r_type) 00144 if r: 00145 for source in r: 00146 base, ext = splitext(source) 00147 to_be_compiled.append(base + '.o') 00148 00149 libraries = [] 00150 for lib in self.resources.libraries: 00151 l, _ = splitext(basename(lib)) 00152 libraries.append(l[3:]) 00153 00154 build_dir = abspath(join(self.inputDir, ".build")) 00155 ctx = { 00156 'name': self.program_name, 00157 'to_be_compiled': to_be_compiled, 00158 'object_files': self.resources.objects, 00159 'include_paths': self.resources.inc_dirs, 00160 'library_paths': self.resources.lib_dirs, 00161 'linker_script': self.resources.linker_script, 00162 'libraries': libraries, 00163 'symbols': self.get_symbols(), 00164 'cpu_flags': self.toolchain.cpu, 00165 'vpath': [relpath(s, build_dir) for s in self.prj_paths] if self.sources_relative else [".."], 00166 'hex_files': self.resources.hex_files 00167 } 00168 00169 for key in ['include_paths', 'library_paths', 'linker_script', 'hex_files']: 00170 if isinstance(ctx[key], list): 00171 ctx[key] = [ctx['vpath'][0] + "/" + t for t in ctx[key]] 00172 else: 00173 ctx[key] = ctx['vpath'][0] + "/" + ctx[key] 00174 if "../." not in ctx["include_paths"]: 00175 ctx["include_paths"] += ['../.'] 00176 ctx.update(self.progen_flags) 00177 self.gen_file('gcc_arm_%s.tmpl' % self.target.lower(), ctx, 'Makefile') 00178 00179 def scan_and_copy_resources(self, prj_paths, trg_path, relative=False): 00180 self.prj_paths = prj_paths 00181 Exporter.scan_and_copy_resources(self, prj_paths, trg_path, relative)
Generated on Tue Jul 12 2022 21:14:58 by
1.7.2
