Brian Daniels / mbed-tools

Fork of mbed-tools by Morpheus

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers gccarm.py Source File

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
00019 
00020 
00021 class GccArm(Exporter):
00022     NAME = 'GccArm'
00023     TOOLCHAIN = 'GCC_ARM'
00024 
00025     TARGETS = [
00026         'LPC1768',
00027         'LPC1549',
00028         'KL05Z',
00029         'KL25Z',
00030         'KL43Z',
00031         'KL46Z',
00032         'K64F',
00033         'K22F',
00034         'K20D50M',
00035         'LPC4088',
00036         'LPC4088_DM',
00037         'LPC4330_M4',
00038         'LPC11U24',
00039         'LPC1114',
00040         'LPC11U35_401',
00041         'LPC11U35_501',
00042         'LPC11U37H_401',
00043         'LPC810',
00044         'LPC812',
00045         'LPC824',
00046         'SSCI824',
00047         'STM32F407',
00048         'DISCO_F100RB',
00049         'DISCO_F051R8',
00050         'DISCO_F407VG',
00051         'DISCO_F429ZI',
00052         'DISCO_F469NI',
00053         'DISCO_F303VC',
00054         'DISCO_F746NG',
00055         'DISCO_L476VG',
00056         'UBLOX_C027',
00057         'ARCH_PRO',
00058         'NRF51822',
00059         'HRM1017',
00060         'RBLAB_NRF51822',
00061         'RBLAB_BLENANO',
00062         'LPC2368',
00063         'LPC2460',
00064         'LPCCAPPUCCINO',
00065         'ARCH_BLE',
00066         'MTS_GAMBIT',
00067         'ARCH_MAX',
00068         'NUCLEO_F401RE',
00069         'NUCLEO_F410RB',
00070         'NUCLEO_F411RE',
00071         'NUCLEO_F446RE',
00072         'B96B_F446VE',
00073         'ARCH_MAX',
00074         'NUCLEO_F030R8',
00075         'NUCLEO_F031K6',
00076         'NUCLEO_F042K6',
00077         'NUCLEO_F070RB',
00078         'NUCLEO_F072RB',
00079         'NUCLEO_F091RC',
00080         'NUCLEO_F103RB',
00081         'NUCLEO_F302R8',
00082         'NUCLEO_F303K8',
00083         'NUCLEO_F303RE',
00084         'NUCLEO_F334R8',
00085         'NUCLEO_F746ZG',
00086         'DISCO_L053C8',
00087         'NUCLEO_L053R8',
00088         'NUCLEO_L073RZ',
00089         'NUCLEO_L476RG',
00090         'DISCO_F334C8',
00091         'MAX32600MBED',
00092         'MAXWSNENV',
00093         'MTS_MDOT_F405RG',
00094         'MTS_MDOT_F411RE',
00095         'NUCLEO_L152RE',
00096         'NRF51_DK',
00097         'NRF51_DONGLE',
00098         'SEEED_TINY_BLE',
00099         'DISCO_F401VC',
00100         'DELTA_DFCM_NNN40',
00101         'RZ_A1H',
00102         'MOTE_L152RC',
00103         'EFM32WG_STK3800',
00104         'EFM32LG_STK3600',
00105         'EFM32GG_STK3700',
00106         'EFM32ZG_STK3200',
00107         'EFM32HG_STK3400',
00108         'EFM32PG_STK3401',
00109         'NZ32_SC151',
00110         'SAMR21G18A',
00111         'TEENSY3_1',
00112         'SAMD21J18A',
00113         'SAMD21G18A',
00114         'SAML21J18A',
00115     ]
00116 
00117     DOT_IN_RELATIVE_PATH = True
00118 
00119     def generate(self):
00120         # "make" wants Unix paths
00121         self.resources.win_to_unix()
00122 
00123         to_be_compiled = []
00124         for r_type in ['s_sources', 'c_sources', 'cpp_sources']:
00125             r = getattr(self.resources, r_type)
00126             if r:
00127                 for source in r:
00128                     base, ext = splitext(source)
00129                     to_be_compiled.append(base + '.o')
00130 
00131         libraries = []
00132         for lib in self.resources.libraries:
00133             l, _ = splitext(basename(lib))
00134             libraries.append(l[3:])
00135 
00136         ctx = {
00137             'name': self.program_name,
00138             'to_be_compiled': to_be_compiled,
00139             'object_files': self.resources.objects,
00140             'include_paths': self.resources.inc_dirs,
00141             'library_paths': self.resources.lib_dirs,
00142             'linker_script': self.resources.linker_script,
00143             'libraries': libraries,
00144             'symbols': self.get_symbols(),
00145             'cpu_flags': self.toolchain.cpu
00146         }
00147         self.gen_file('gcc_arm_%s.tmpl' % self.target.lower(), ctx, 'Makefile')