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