Skip to content

Commit

Permalink
µVision export: Add ARMC6 -std handling
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kjbracey committed Apr 25, 2019
1 parent b0dc3fe commit f08ddae
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
28 changes: 28 additions & 0 deletions tools/export/uvision/__init__.py
Expand Up @@ -288,6 +288,34 @@ def generate(self):
ctx['fputype'] = self.format_fpu(ctx['device'].core)
ctx['armc6'] = int(self.TOOLCHAIN is 'ARMC6')
ctx['toolchain_name'] = self.TOOLCHAIN_NAME

std = [flag for flag in self.flags['c_flags'] if flag.startswith("-std=")]
if len(std) >= 1:
std = std[-1][len('-std='):]
else:
std = None
c_std = {
'c89': 1, 'gnu89': 2,
'c90': 1, 'gnu90': 2,
'c99': 3, 'gnu99': 4,
'c11': 5, 'gnu11': 6,
}
ctx['v6_lang'] = c_std.get(std, 0)

std = [flag for flag in self.flags['cxx_flags'] if flag.startswith("-std=")]
if len(std) >= 1:
std = std[-1][len('-std='):]
else:
std = None
cpp_std = {
'c++98': 1, 'gnu++98': 2,
'c++03': 5, 'gnu++03': 2, # UVision 5.27.1.0 does not support gnu++03 - fall back to gnu++98
'c++11': 3, 'gnu++11': 4,
'c++14': 6, 'gnu++14': 0, # UVision 5.27.1.0 can't manually select gnu++14, but it is the default!
'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
}
ctx['v6_lang_p'] = cpp_std.get(std, 0)

ctx.update(self.format_flags())
self.gen_file(
'uvision/uvision.tmpl', ctx, self.project_name + ".uvprojx"
Expand Down
4 changes: 2 additions & 2 deletions tools/export/uvision/uvision.tmpl
Expand Up @@ -369,8 +369,8 @@
<uSurpInc>0</uSurpInc>
<uC99>1</uC99>
<useXO>0</useXO>
<v6Lang>4</v6Lang>
<v6LangP>2</v6LangP>
<v6Lang>{{v6_lang}}</v6Lang>
<v6LangP>{{v6_lang_p}}</v6LangP>
<vShortEn>1</vShortEn>
<vShortWch>1</vShortWch>
<v6Lto>0</v6Lto>
Expand Down

0 comments on commit f08ddae

Please sign in to comment.