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