Brian Daniels / mbed-tools

Fork of mbed-tools by Morpheus

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 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_L053R8',
00033         'NUCLEO_L152RE',
00034         'NUCLEO_F030R8',
00035         'NUCLEO_F042K6',
00036         'NUCLEO_F070RB',
00037         'NUCLEO_F072RB',
00038         'NUCLEO_F091RC',
00039         'NUCLEO_F103RB',
00040         'NUCLEO_F302R8',
00041         'NUCLEO_F303K8',
00042         'NUCLEO_F303RE',
00043         'NUCLEO_F334R8',
00044         'NUCLEO_F401RE',
00045         'NUCLEO_F410RB',
00046         'NUCLEO_F411RE',
00047         'NUCLEO_F446RE',
00048         'DISCO_L053C8',
00049         'DISCO_F051R8',
00050         'DISCO_F100RB',
00051         'DISCO_F303VC',
00052         'DISCO_F334C8',
00053         'DISCO_F401VC',
00054         'DISCO_F407VG',
00055         'DISCO_F429ZI',
00056         'DISCO_F469NI',
00057         'MTS_MDOT_F405RG',
00058         'MTS_MDOT_F411RE',
00059         'MOTE_L152RC',
00060         'NZ32_SC151',
00061     ]
00062 
00063     # seems like CoIDE currently supports only one type
00064     FILE_TYPES = {
00065         'c_sources':'1',
00066         'cpp_sources':'1',
00067         's_sources':'1'
00068     }
00069     FILE_TYPES2 = {
00070         'headers':'1'
00071     }
00072 
00073     def generate(self):
00074         self.resources.win_to_unix()
00075         source_files = []
00076         for r_type, n in CoIDE.FILE_TYPES.iteritems():
00077             for file in getattr(self.resources, r_type):
00078                 source_files.append({
00079                     'name': basename(file), 'type': n, 'path': file
00080                 })
00081         header_files = []
00082         for r_type, n in CoIDE.FILE_TYPES2.iteritems():
00083             for file in getattr(self.resources, r_type):
00084                 header_files.append({
00085                     'name': basename(file), 'type': n, 'path': file
00086                 })
00087 
00088         libraries = []
00089         for lib in self.resources.libraries:
00090             l, _ = splitext(basename(lib))
00091             libraries.append(l[3:])
00092 
00093         if self.resources.linker_script is None:
00094             self.resources.linker_script = ''
00095             
00096         ctx = {
00097             'name': self.program_name,
00098             'source_files': source_files,
00099             'header_files': header_files,
00100             'include_paths': self.resources.inc_dirs,
00101             'scatter_file': self.resources.linker_script,
00102             'library_paths': self.resources.lib_dirs,
00103             'object_files': self.resources.objects,
00104             'libraries': libraries,
00105             'symbols': self.get_symbols()
00106         }
00107         target = self.target.lower()
00108 
00109         # Project file
00110         self.gen_file('coide_%s.coproj.tmpl' % target, ctx, '%s.coproj' % self.program_name)