Skip to content

Commit f08ddae

Browse files
committed
µVision export: Add ARMC6 -std handling
This is limited to ARMC6 because as of µVision V5.27 you can't set C++11 for ARMC5. Also, selection of gnu++14, which we want to use, can't be done explicitly, as it's not in µVision's list. But it is the default for ARM Compiler 6.11 and 6.12, so we can get it implicitly.
1 parent b0dc3fe commit f08ddae

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

tools/export/uvision/__init__.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,34 @@ def generate(self):
288288
ctx['fputype'] = self.format_fpu(ctx['device'].core)
289289
ctx['armc6'] = int(self.TOOLCHAIN is 'ARMC6')
290290
ctx['toolchain_name'] = self.TOOLCHAIN_NAME
291+
292+
std = [flag for flag in self.flags['c_flags'] if flag.startswith("-std=")]
293+
if len(std) >= 1:
294+
std = std[-1][len('-std='):]
295+
else:
296+
std = None
297+
c_std = {
298+
'c89': 1, 'gnu89': 2,
299+
'c90': 1, 'gnu90': 2,
300+
'c99': 3, 'gnu99': 4,
301+
'c11': 5, 'gnu11': 6,
302+
}
303+
ctx['v6_lang'] = c_std.get(std, 0)
304+
305+
std = [flag for flag in self.flags['cxx_flags'] if flag.startswith("-std=")]
306+
if len(std) >= 1:
307+
std = std[-1][len('-std='):]
308+
else:
309+
std = None
310+
cpp_std = {
311+
'c++98': 1, 'gnu++98': 2,
312+
'c++03': 5, 'gnu++03': 2, # UVision 5.27.1.0 does not support gnu++03 - fall back to gnu++98
313+
'c++11': 3, 'gnu++11': 4,
314+
'c++14': 6, 'gnu++14': 0, # UVision 5.27.1.0 can't manually select gnu++14, but it is the default!
315+
'c++17': 6, 'gnu++17': 0, # UVision 5.27.1.0 does not support c++17/gnu++17 - fall back to c++14/gnu++14
316+
}
317+
ctx['v6_lang_p'] = cpp_std.get(std, 0)
318+
291319
ctx.update(self.format_flags())
292320
self.gen_file(
293321
'uvision/uvision.tmpl', ctx, self.project_name + ".uvprojx"

tools/export/uvision/uvision.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,8 @@
369369
<uSurpInc>0</uSurpInc>
370370
<uC99>1</uC99>
371371
<useXO>0</useXO>
372-
<v6Lang>4</v6Lang>
373-
<v6LangP>2</v6LangP>
372+
<v6Lang>{{v6_lang}}</v6Lang>
373+
<v6LangP>{{v6_lang_p}}</v6LangP>
374374
<vShortEn>1</vShortEn>
375375
<vShortWch>1</vShortWch>
376376
<v6Lto>0</v6Lto>

0 commit comments

Comments
 (0)