User | Revision | Line number | New contents of line |
nexpaq |
0:6c56fb4bc5f0
|
1
|
"""
|
nexpaq |
0:6c56fb4bc5f0
|
2
|
mbed SDK
|
nexpaq |
0:6c56fb4bc5f0
|
3
|
Copyright (c) 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 os.path import basename, join, dirname
|
nexpaq |
0:6c56fb4bc5f0
|
18
|
from project_generator_definitions.definitions import ProGenDef
|
nexpaq |
0:6c56fb4bc5f0
|
19
|
|
nexpaq |
0:6c56fb4bc5f0
|
20
|
from tools.export.exporters import Exporter, ExporterTargetsProperty
|
nexpaq |
0:6c56fb4bc5f0
|
21
|
from tools.targets import TARGET_MAP, TARGET_NAMES
|
nexpaq |
0:6c56fb4bc5f0
|
22
|
|
nexpaq |
0:6c56fb4bc5f0
|
23
|
# If you wish to add a new target, add it to project_generator_definitions, and then
|
nexpaq |
0:6c56fb4bc5f0
|
24
|
# define progen_target name in the target class (`` self.progen_target = 'my_target_name' ``)
|
nexpaq |
0:6c56fb4bc5f0
|
25
|
# There are 2 default mbed templates (predefined settings) uvision.uvproj and uvproj_microlib.uvproj.tmpl
|
nexpaq |
0:6c56fb4bc5f0
|
26
|
class Uvision5(Exporter):
|
nexpaq |
0:6c56fb4bc5f0
|
27
|
"""
|
nexpaq |
0:6c56fb4bc5f0
|
28
|
Exporter class for uvision5. This class uses project generator.
|
nexpaq |
0:6c56fb4bc5f0
|
29
|
"""
|
nexpaq |
0:6c56fb4bc5f0
|
30
|
# These 2 are currently for exporters backward compatiblity
|
nexpaq |
0:6c56fb4bc5f0
|
31
|
NAME = 'uvision5'
|
nexpaq |
0:6c56fb4bc5f0
|
32
|
TOOLCHAIN = 'ARM'
|
nexpaq |
0:6c56fb4bc5f0
|
33
|
# PROGEN_ACTIVE contains information for exporter scripts that this is using progen
|
nexpaq |
0:6c56fb4bc5f0
|
34
|
PROGEN_ACTIVE = True
|
nexpaq |
0:6c56fb4bc5f0
|
35
|
|
nexpaq |
0:6c56fb4bc5f0
|
36
|
MBED_CONFIG_HEADER_SUPPORTED = True
|
nexpaq |
0:6c56fb4bc5f0
|
37
|
|
nexpaq |
0:6c56fb4bc5f0
|
38
|
@ExporterTargetsProperty
|
nexpaq |
0:6c56fb4bc5f0
|
39
|
def TARGETS(cls):
|
nexpaq |
0:6c56fb4bc5f0
|
40
|
if not hasattr(cls, "_targets_supported"):
|
nexpaq |
0:6c56fb4bc5f0
|
41
|
cls._targets_supported = []
|
nexpaq |
0:6c56fb4bc5f0
|
42
|
progendef = ProGenDef('uvision5')
|
nexpaq |
0:6c56fb4bc5f0
|
43
|
for target in TARGET_NAMES:
|
nexpaq |
0:6c56fb4bc5f0
|
44
|
try:
|
nexpaq |
0:6c56fb4bc5f0
|
45
|
if (progendef.is_supported(str(TARGET_MAP[target])) or
|
nexpaq |
0:6c56fb4bc5f0
|
46
|
progendef.is_supported(TARGET_MAP[target].progen['target'])):
|
nexpaq |
0:6c56fb4bc5f0
|
47
|
cls._targets_supported.append(target)
|
nexpaq |
0:6c56fb4bc5f0
|
48
|
except AttributeError:
|
nexpaq |
0:6c56fb4bc5f0
|
49
|
# target is not supported yet
|
nexpaq |
0:6c56fb4bc5f0
|
50
|
continue
|
nexpaq |
0:6c56fb4bc5f0
|
51
|
return cls._targets_supported
|
nexpaq |
0:6c56fb4bc5f0
|
52
|
|
nexpaq |
0:6c56fb4bc5f0
|
53
|
def get_toolchain(self):
|
nexpaq |
0:6c56fb4bc5f0
|
54
|
return TARGET_MAP[self.target].default_toolchain
|
nexpaq |
0:6c56fb4bc5f0
|
55
|
|
nexpaq |
0:6c56fb4bc5f0
|
56
|
def generate(self):
|
nexpaq |
0:6c56fb4bc5f0
|
57
|
""" Generates the project files """
|
nexpaq |
0:6c56fb4bc5f0
|
58
|
project_data = self.progen_get_project_data()
|
nexpaq |
0:6c56fb4bc5f0
|
59
|
tool_specific = {}
|
nexpaq |
0:6c56fb4bc5f0
|
60
|
# Expand tool specific settings by uvision specific settings which are required
|
nexpaq |
0:6c56fb4bc5f0
|
61
|
try:
|
nexpaq |
0:6c56fb4bc5f0
|
62
|
if TARGET_MAP[self.target].progen['uvision5']['template']:
|
nexpaq |
0:6c56fb4bc5f0
|
63
|
tool_specific['uvision5'] = TARGET_MAP[self.target].progen['uvision5']
|
nexpaq |
0:6c56fb4bc5f0
|
64
|
except KeyError:
|
nexpaq |
0:6c56fb4bc5f0
|
65
|
# use default template
|
nexpaq |
0:6c56fb4bc5f0
|
66
|
# by the mbed projects
|
nexpaq |
0:6c56fb4bc5f0
|
67
|
tool_specific['uvision5'] = {
|
nexpaq |
0:6c56fb4bc5f0
|
68
|
'template': [join(dirname(__file__), 'uvision.uvproj.tmpl')],
|
nexpaq |
0:6c56fb4bc5f0
|
69
|
}
|
nexpaq |
0:6c56fb4bc5f0
|
70
|
|
nexpaq |
0:6c56fb4bc5f0
|
71
|
#project_data['template'] = [tool_specific['uvision5']['template']]
|
nexpaq |
0:6c56fb4bc5f0
|
72
|
project_data['tool_specific'] = {}
|
nexpaq |
0:6c56fb4bc5f0
|
73
|
project_data['tool_specific'].update(tool_specific)
|
nexpaq |
0:6c56fb4bc5f0
|
74
|
|
nexpaq |
0:6c56fb4bc5f0
|
75
|
# get flags from toolchain and apply
|
nexpaq |
0:6c56fb4bc5f0
|
76
|
project_data['misc'] = {}
|
nexpaq |
0:6c56fb4bc5f0
|
77
|
asm_flag_string = '--cpreproc --cpreproc_opts=-D__ASSERT_MSG,' + ",".join(list(set(self.flags['asm_flags'])))
|
nexpaq |
0:6c56fb4bc5f0
|
78
|
# asm flags only, common are not valid within uvision project, they are armcc specific
|
nexpaq |
0:6c56fb4bc5f0
|
79
|
project_data['misc']['asm_flags'] = [asm_flag_string]
|
nexpaq |
0:6c56fb4bc5f0
|
80
|
# cxx flags included, as uvision have them all in one tab
|
nexpaq |
0:6c56fb4bc5f0
|
81
|
project_data['misc']['c_flags'] = list(set(['-D__ASSERT_MSG']
|
nexpaq |
0:6c56fb4bc5f0
|
82
|
+ self.flags['common_flags']
|
nexpaq |
0:6c56fb4bc5f0
|
83
|
+ self.flags['c_flags']
|
nexpaq |
0:6c56fb4bc5f0
|
84
|
+ self.flags['cxx_flags']))
|
nexpaq |
0:6c56fb4bc5f0
|
85
|
# not compatible with c99 flag set in the template
|
nexpaq |
0:6c56fb4bc5f0
|
86
|
project_data['misc']['c_flags'].remove("--c99")
|
nexpaq |
0:6c56fb4bc5f0
|
87
|
# cpp is not required as it's implicit for cpp files
|
nexpaq |
0:6c56fb4bc5f0
|
88
|
project_data['misc']['c_flags'].remove("--cpp")
|
nexpaq |
0:6c56fb4bc5f0
|
89
|
# we want no-vla for only cxx, but it's also applied for C in IDE, thus we remove it
|
nexpaq |
0:6c56fb4bc5f0
|
90
|
project_data['misc']['c_flags'].remove("--no_vla")
|
nexpaq |
0:6c56fb4bc5f0
|
91
|
project_data['misc']['ld_flags'] = self.flags['ld_flags']
|
nexpaq |
0:6c56fb4bc5f0
|
92
|
|
nexpaq |
0:6c56fb4bc5f0
|
93
|
i = 0
|
nexpaq |
0:6c56fb4bc5f0
|
94
|
project_data['build_dir'] = project_data['build_dir'] + '\\' + 'uvision5'
|
nexpaq |
0:6c56fb4bc5f0
|
95
|
self.progen_gen_file(project_data)
|