]> git.gir.st - tmk_keyboard.git/blob - tool/mbed/mbed-sdk/workspace_tools/export/emblocks.py
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[tmk_keyboard.git] / tool / mbed / mbed-sdk / workspace_tools / export / emblocks.py
1 """
2 mbed SDK
3 Copyright (c) 2014 ARM Limited
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 """
17 from exporters import Exporter
18 from os.path import splitext, basename
19 from workspace_tools.targets import TARGETS
20
21 # filter all the GCC_ARM targets out of the target list
22 gccTargets = []
23 for t in TARGETS:
24 if 'GCC_ARM' in t.supported_toolchains:
25 gccTargets.append(t.name)
26
27 class IntermediateFile(Exporter):
28 NAME = 'EmBlocks'
29 TOOLCHAIN = 'GCC_ARM'
30
31 # we support all GCC targets (is handled on IDE side)
32 TARGETS = gccTargets
33
34 FILE_TYPES = {
35 'headers': 'h',
36 'c_sources': 'c',
37 's_sources': 'a',
38 'cpp_sources': 'cpp'
39 }
40
41
42 def generate(self):
43 self.resources.win_to_unix()
44 source_files = []
45 for r_type, n in IntermediateFile.FILE_TYPES.iteritems():
46 for file in getattr(self.resources, r_type):
47 source_files.append({
48 'name': file, 'type': n
49 })
50
51 libraries = []
52 for lib in self.resources.libraries:
53 l, _ = splitext(basename(lib))
54 libraries.append(l[3:])
55
56
57 if self.resources.linker_script is None:
58 self.resources.linker_script = ''
59
60 ctx = {
61 'name': self.program_name,
62 'target': self.target,
63 'toolchain': self.toolchain.name,
64 'source_files': source_files,
65 'include_paths': self.resources.inc_dirs,
66 'script_file': self.resources.linker_script,
67 'library_paths': self.resources.lib_dirs,
68 'libraries': libraries,
69 'symbols': self.get_symbols(),
70 'object_files': self.resources.objects,
71 'sys_libs': self.toolchain.sys_libs,
72 'cc_org': self.toolchain.cc[1:],
73 'ld_org': self.toolchain.ld[1:],
74 'cppc_org': self.toolchain.cppc[1:]
75 }
76
77 # EmBlocks intermediate file template
78 self.gen_file('emblocks.eix.tmpl', ctx, '%s.eix' % self.program_name)
Imprint / Impressum