joey shelton / LED_Demo

Dependencies:   MAX44000 PWM_Tone_Library nexpaq_mdk

Fork of LED_Demo by Maxim nexpaq

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-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 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     MBED_CONFIG_HEADER_SUPPORTED = True
00035 
00036     FILE_TYPES = {
00037         'headers': 'h',
00038         'c_sources': 'c',
00039         's_sources': 'a',
00040         'cpp_sources': 'cpp'
00041     }
00042 
00043 
00044     def generate(self):
00045         self.resources.win_to_unix()
00046         source_files = []
00047         for r_type, n in IntermediateFile.FILE_TYPES.iteritems():
00048             for file in getattr(self.resources, r_type):
00049                 source_files.append({
00050                     'name': file, 'type': n
00051                 })
00052 
00053         libraries = []
00054         for lib in self.resources.libraries:
00055             l, _ = splitext(basename(lib))
00056             libraries.append(l[3:])
00057 
00058 
00059         if self.resources.linker_script is None:
00060             self.resources.linker_script = ''
00061 
00062         ctx = {
00063             'name': self.project_name,
00064             'target': self.target,
00065             'toolchain': self.toolchain.name,
00066             'source_files': source_files,
00067             'include_paths': self.resources.inc_dirs,
00068             'script_file': self.resources.linker_script,
00069             'library_paths': self.resources.lib_dirs,
00070             'libraries': libraries,
00071             'symbols': self.toolchain.get_symbols(),
00072             'object_files': self.resources.objects,
00073             'sys_libs': self.toolchain.sys_libs,
00074             'cc_org': self.flags['common_flags'] + self.flags['c_flags'],
00075             'ld_org': self.flags['common_flags'] + self.flags['ld_flags'],
00076             'cppc_org': self.flags['common_flags'] + self.flags['cxx_flags']
00077         }
00078 
00079         # EmBlocks intermediate file template
00080         self.gen_file('emblocks.eix.tmpl', ctx, '%s.eix' % self.project_name)