ON Semiconductor / mbed-os

Dependents:   mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510

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 tools.targets import TARGET_MAP
00019 from tools.export.exporters import Exporter
00020 
00021 class EmBitz(Exporter ):
00022     NAME = 'EmBitz'
00023     TOOLCHAIN = 'GCC_ARM'
00024 
00025     TARGETS = [target for target, obj in TARGET_MAP.iteritems()
00026                if "GCC_ARM" in obj.supported_toolchains]
00027 
00028     MBED_CONFIG_HEADER_SUPPORTED = True
00029 
00030     FILE_TYPES = {
00031         'headers': 'h',
00032         'c_sources': 'c',
00033         's_sources': 'a',
00034         'cpp_sources': 'cpp'
00035     }
00036 
00037 
00038     @staticmethod
00039     def _remove_symbols(sym_list):
00040         return [s for s in sym_list if not s.startswith("-D")]
00041 
00042     def generate(self):
00043         self.resources.win_to_unix()
00044         source_files = []
00045         for r_type, n in self.FILE_TYPES.iteritems():
00046             for file in getattr(self.resources, r_type):
00047                 source_files.append({
00048                     'name': file, 'type': n
00049                 })
00050 
00051         libraries = []
00052         for lib in self.resources.libraries:
00053             l, _ = splitext(basename(lib))
00054             libraries.append(l[3:])
00055 
00056 
00057         if self.resources.linker_script is None:
00058             self.resources.linker_script = ''
00059 
00060         ctx = {
00061             'name': self.project_name,
00062             'target': self.target,
00063             'toolchain': self.toolchain.name,
00064             'source_files': source_files,
00065             'include_paths': self.resources.inc_dirs,
00066             'script_file': self.resources.linker_script,
00067             'library_paths': self.resources.lib_dirs,
00068             'libraries': libraries,
00069             'symbols': self.toolchain.get_symbols(),
00070             'object_files': self.resources.objects,
00071             'sys_libs': self.toolchain.sys_libs,
00072             'cc_org': (self.flags['common_flags'] +
00073                        self._remove_symbols(self.flags['c_flags'])),
00074             'ld_org': self.flags['ld_flags'],
00075             'cppc_org': (self.flags['common_flags'] +
00076                          self._remove_symbols(self.flags['cxx_flags']))
00077         }
00078 
00079         self.gen_file('embitz/eix.tmpl', ctx, '%s.eix' % self.project_name)