Rtos API example

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers __init__.py Source File

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