Skip to content

Commit 7b8165d

Browse files
committed
Exporters - uvision5 addition
uvision5 uses software packs for devices, plus different extension. We should use uvision as uvision4. This is based on progen, same as uvision4.
1 parent 8969811 commit 7b8165d

File tree

2 files changed

+79
-1
lines changed

2 files changed

+79
-1
lines changed

workspace_tools/export/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@
2020
import yaml
2121

2222
from workspace_tools.utils import mkdir
23-
from workspace_tools.export import uvision4, codered, gccarm, ds5_5, iar, emblocks, coide, kds, zip, simplicityv3, atmelstudio, sw4stm32, e2studio
23+
from workspace_tools.export import uvision4, uvision5, codered, gccarm, ds5_5, iar, emblocks, coide, kds, zip, simplicityv3, atmelstudio, sw4stm32, e2studio
2424
from workspace_tools.export.exporters import zip_working_directory_and_clean_up, OldLibrariesException
2525
from workspace_tools.targets import TARGET_NAMES, EXPORT_MAP, TARGET_MAP
2626

2727
from project_generator_definitions.definitions import ProGenDef
2828

2929
EXPORTERS = {
3030
'uvision': uvision4.Uvision4,
31+
'uvision5': uvision5.Uvision5,
3132
'lpcxpresso': codered.CodeRed,
3233
'gcc_arm': gccarm.GccArm,
3334
'ds5_5': ds5_5.DS5_5,

workspace_tools/export/uvision5.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
"""
2+
mbed SDK
3+
Copyright (c) 2016 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 os.path import basename, join, dirname
18+
from project_generator_definitions.definitions import ProGenDef
19+
20+
from workspace_tools.export.exporters import Exporter
21+
from workspace_tools.targets import TARGET_MAP, TARGET_NAMES
22+
23+
# If you wish to add a new target, add it to project_generator_definitions, and then
24+
# define progen_target name in the target class (`` self.progen_target = 'my_target_name' ``)
25+
# There are 2 default mbed templates (predefined settings) uvision.uvproj and uvproj_microlib.uvproj.tmpl
26+
class Uvision5(Exporter):
27+
"""
28+
Exporter class for uvision5. This class uses project generator.
29+
"""
30+
# These 2 are currently for exporters backward compatiblity
31+
NAME = 'uVision5'
32+
TOOLCHAIN = 'ARM'
33+
# PROGEN_ACTIVE contains information for exporter scripts that this is using progen
34+
PROGEN_ACTIVE = True
35+
36+
# backward compatibility with our scripts
37+
TARGETS = []
38+
for target in TARGET_NAMES:
39+
try:
40+
if (ProGenDef('uvision5').is_supported(str(TARGET_MAP[target])) or
41+
ProGenDef('uvision5').is_supported(TARGET_MAP[target].progen['target'])):
42+
TARGETS.append(target)
43+
except AttributeError:
44+
# target is not supported yet
45+
continue
46+
47+
48+
def generate(self):
49+
""" Generates the project files """
50+
project_data = self.progen_get_project_data()
51+
tool_specific = {}
52+
# Expand tool specific settings by uvision specific settings which are required
53+
try:
54+
if TARGET_MAP[self.target].progen['uvision5']['template']:
55+
tool_specific['uvision5'] = TARGET_MAP[self.target].progen['uvision5']
56+
except KeyError:
57+
# use default template
58+
# by the mbed projects
59+
tool_specific['uvision5'] = {
60+
'template': [join(dirname(__file__), 'uvision.uvproj.tmpl')],
61+
}
62+
63+
project_data['tool_specific'] = {}
64+
project_data['tool_specific'].update(tool_specific)
65+
i = 0
66+
for macro in project_data['common']['macros']:
67+
# armasm does not like floating numbers in macros, timestamp to int
68+
if macro.startswith('MBED_BUILD_TIMESTAMP'):
69+
timestamp = macro[len('MBED_BUILD_TIMESTAMP='):]
70+
project_data['common']['macros'][i] = 'MBED_BUILD_TIMESTAMP=' + str(int(float(timestamp)))
71+
# armasm does not even accept MACRO=string
72+
if macro.startswith('MBED_USERNAME'):
73+
project_data['common']['macros'].pop(i)
74+
i += 1
75+
project_data['common']['macros'].append('__ASSERT_MSG')
76+
self.progen_gen_file('uvision5', project_data)
77+

0 commit comments

Comments
 (0)