Brian Daniels / mbed-tools

Fork of mbed-tools by Morpheus

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers emblocks.py Source File

emblocks.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 from tools.targets import TARGETS
00020 
00021 # filter all the GCC_ARM targets out of the target list
00022 gccTargets = []
00023 for t in TARGETS:
00024     if 'GCC_ARM' in t.supported_toolchains:
00025         gccTargets.append(t.name)
00026 
00027 class IntermediateFile(Exporter):
00028     NAME = 'EmBlocks'
00029     TOOLCHAIN = 'GCC_ARM'
00030 
00031     # we support all GCC targets (is handled on IDE side)
00032     TARGETS = gccTargets
00033 
00034     FILE_TYPES = {
00035         'headers': 'h',
00036         'c_sources': 'c',
00037         's_sources': 'a',
00038         'cpp_sources': 'cpp'
00039     }
00040 
00041 
00042     def generate(self):
00043         self.resources.win_to_unix()
00044         source_files = []
00045         for r_type, n in IntermediateFile.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.program_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.get_symbols(),
00070             'object_files': self.resources.objects,
00071             'sys_libs': self.toolchain.sys_libs,
00072             'cc_org': self.toolchain.cc[1:],
00073             'ld_org': self.toolchain.ld[1:],
00074             'cppc_org': self.toolchain.cppc[1:]
00075         }
00076 
00077         # EmBlocks intermediate file template
00078         self.gen_file('emblocks.eix.tmpl', ctx, '%s.eix' % self.program_name)