joey shelton / LED_Demo

Dependencies:   MAX44000 PWM_Tone_Library nexpaq_mdk

Fork of LED_Demo by Maxim nexpaq

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-2016 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 os.path import splitext, basename, relpath, join, abspath, dirname
00018 from os import curdir, getcwd
00019 from tools.export.exporters import Exporter
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_F769NI',
00057         'DISCO_L476VG',
00058         'UBLOX_C027',
00059         'ARCH_PRO',
00060         'NRF51822',
00061         'HRM1017',
00062         'TY51822R3',
00063         'RBLAB_NRF51822',
00064         'RBLAB_BLENANO',
00065         'LPC2368',
00066         'LPC2460',
00067         'LPCCAPPUCCINO',
00068         'ARCH_BLE',
00069         'MTS_GAMBIT',
00070         'ARCH_MAX',
00071         'NUCLEO_F401RE',
00072         'NUCLEO_F410RB',
00073         'NUCLEO_F411RE',
00074         'NUCLEO_F429ZI',
00075         'NUCLEO_F446RE',
00076         'NUCLEO_F446ZE',
00077         'B96B_F446VE',
00078         'ARCH_MAX',
00079         'NUCLEO_F030R8',
00080         'NUCLEO_F031K6',
00081         'NUCLEO_F042K6',
00082         'NUCLEO_F070RB',
00083         'NUCLEO_F072RB',
00084         'NUCLEO_F091RC',
00085         'NUCLEO_F103RB',
00086         'NUCLEO_F207ZG',
00087         'NUCLEO_F302R8',
00088         'NUCLEO_F303K8',
00089         'NUCLEO_F303RE',
00090         'NUCLEO_F334R8',
00091         'NUCLEO_F303ZE',
00092         'NUCLEO_F746ZG',
00093         'NUCLEO_F767ZI',
00094         'DISCO_L053C8',
00095         'NUCLEO_L011K4',
00096         'NUCLEO_L031K6',
00097         'NUCLEO_L053R8',
00098         'NUCLEO_L073RZ',
00099         'NUCLEO_L432KC',
00100         'NUCLEO_L476RG',
00101         'DISCO_F334C8',
00102         'MAX32600MBED',
00103         'MAXWSNENV',
00104         'MAX32620HSP',
00105         'MTS_MDOT_F405RG',
00106         'MTS_MDOT_F411RE',
00107         'NUCLEO_L152RE',
00108         'NRF51_DK',
00109         'NRF51_DONGLE',
00110         'NRF51_MICROBIT',
00111         'MTM_MTCONNECT04S',
00112         'SEEED_TINY_BLE',
00113         'DISCO_F401VC',
00114         'DELTA_DFCM_NNN40',
00115         'RZ_A1H',
00116         'MOTE_L152RC',
00117         'EFM32WG_STK3800',
00118         'EFM32LG_STK3600',
00119         'EFM32GG_STK3700',
00120         'EFM32ZG_STK3200',
00121         'EFM32HG_STK3400',
00122         'EFM32PG_STK3401',
00123         'NZ32_SC151',
00124         'SAMR21G18A',
00125         'TEENSY3_1',
00126         'SAMD21J18A',
00127         'SAMD21G18A',
00128         'SAML21J18A',
00129         'SAMG55J19',
00130         'ARM_BEETLE_SOC',
00131         'ELMO_F411RE',
00132         'BLUEPILL_F103C8',
00133     ]
00134 
00135     DOT_IN_RELATIVE_PATH = True
00136 
00137     MBED_CONFIG_HEADER_SUPPORTED = True
00138 
00139     def generate(self):
00140         # "make" wants Unix paths
00141         self.resources.win_to_unix()
00142 
00143         to_be_compiled = []
00144         for r_type in ['s_sources', 'c_sources', 'cpp_sources']:
00145             r = getattr(self.resources, r_type)
00146             if r:
00147                 for source in r:
00148                     base, ext = splitext(source)
00149                     to_be_compiled.append(base + '.o')
00150 
00151         libraries = []
00152         for lib in self.resources.libraries:
00153             l, _ = splitext(basename(lib))
00154             libraries.append(l[3:])
00155 
00156         ctx = {
00157             'name': self.project_name,
00158             'to_be_compiled': to_be_compiled,
00159             'object_files': self.resources.objects,
00160             'include_paths': self.resources.inc_dirs,
00161             'library_paths': self.resources.lib_dirs,
00162             'linker_script': self.resources.linker_script,
00163             'libraries': libraries,
00164             'symbols': self.toolchain.get_symbols(),
00165             'cpu_flags': self.toolchain.cpu,
00166             'hex_files': self.resources.hex_files,
00167             'vpath': (["../../.."]
00168                       if basename(dirname(dirname(self.export_dir))) == "projectfiles"
00169                       else [".."])
00170         }
00171 
00172         for key in ['include_paths', 'library_paths', 'linker_script', 'hex_files']:
00173             if isinstance(ctx[key], list):
00174                 ctx[key] = [ctx['vpath'][0] + "/" + t for t in ctx[key]]
00175             else:
00176                 ctx[key] = ctx['vpath'][0] + "/" + ctx[key]
00177         if "../." not in ctx["include_paths"]:
00178             ctx["include_paths"] += ['../.']
00179         ctx.update(self.flags)
00180         self.gen_file('gcc_arm_%s.tmpl' % self.target.lower(), ctx, 'Makefile')