Lee Kai Xuan / mbed-os

Fork of mbed-os by erkin yucel

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers coide.py Source File

coide.py

00001 """
00002 mbed SDK
00003 Copyright (c) 2014-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 exporters import Exporter
00018 from os.path import splitext, basename
00019 
00020 
00021 class CoIDE(Exporter):
00022     NAME = 'CoIDE'
00023     TOOLCHAIN = 'GCC_ARM'
00024 
00025     TARGETS = [
00026         'KL25Z',
00027         'KL05Z',
00028         'LPC1768',
00029         'ARCH_PRO',
00030         'ARCH_MAX',
00031         'UBLOX_C027',
00032         'NUCLEO_L011K4',
00033         'NUCLEO_L053R8',
00034         'NUCLEO_L152RE',
00035         'NUCLEO_F030R8',
00036         'NUCLEO_F042K6',
00037         'NUCLEO_F070RB',
00038         'NUCLEO_F072RB',
00039         'NUCLEO_F091RC',
00040         'NUCLEO_F103RB',
00041         'NUCLEO_F207ZG',
00042         'NUCLEO_F302R8',
00043         'NUCLEO_F303K8',
00044         'NUCLEO_F303RE',
00045         'NUCLEO_F334R8',
00046         'NUCLEO_F303ZE',
00047         'NUCLEO_F401RE',
00048         'NUCLEO_F410RB',
00049         'NUCLEO_F411RE',
00050         'NUCLEO_F429ZI',
00051         'NUCLEO_F446RE',
00052         'NUCLEO_F446ZE',
00053         'DISCO_L053C8',
00054         'DISCO_F051R8',
00055         'DISCO_F100RB',
00056         'DISCO_F303VC',
00057         'DISCO_F334C8',
00058         'DISCO_F401VC',
00059         'DISCO_F407VG',
00060         'DISCO_F429ZI',
00061         'DISCO_F469NI',
00062         'MTS_MDOT_F405RG',
00063         'MTS_MDOT_F411RE',
00064         'MOTE_L152RC',
00065         'NZ32_SC151',
00066     ]
00067 
00068     # seems like CoIDE currently supports only one type
00069     FILE_TYPES = {
00070         'c_sources':'1',
00071         'cpp_sources':'1',
00072         's_sources':'1'
00073     }
00074     FILE_TYPES2 = {
00075         'headers':'1'
00076     }
00077 
00078     def generate(self):
00079         self.resources.win_to_unix()
00080         source_files = []
00081         for r_type, n in CoIDE.FILE_TYPES.iteritems():
00082             for file in getattr(self.resources, r_type):
00083                 source_files.append({
00084                     'name': basename(file), 'type': n, 'path': file
00085                 })
00086         header_files = []
00087         for r_type, n in CoIDE.FILE_TYPES2.iteritems():
00088             for file in getattr(self.resources, r_type):
00089                 header_files.append({
00090                     'name': basename(file), 'type': n, 'path': file
00091                 })
00092 
00093         libraries = []
00094         for lib in self.resources.libraries:
00095             l, _ = splitext(basename(lib))
00096             libraries.append(l[3:])
00097 
00098         if self.resources.linker_script is None:
00099             self.resources.linker_script = ''
00100             
00101         ctx = {
00102             'name': self.project_name,
00103             'source_files': source_files,
00104             'header_files': header_files,
00105             'include_paths': self.resources.inc_dirs,
00106             'scatter_file': self.resources.linker_script,
00107             'library_paths': self.resources.lib_dirs,
00108             'object_files': self.resources.objects,
00109             'libraries': libraries,
00110             'symbols': self.toolchain.get_symbols()
00111         }
00112         target = self.target.lower()
00113 
00114         # Project file
00115         self.gen_file('coide_%s.coproj.tmpl' % target, ctx, '%s.coproj' % self.project_name)