diff --git a/tools/export/uvision/__init__.py b/tools/export/uvision/__init__.py index e5bf40c0d3ea..787f81284ee3 100644 --- a/tools/export/uvision/__init__.py +++ b/tools/export/uvision/__init__.py @@ -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" diff --git a/tools/export/uvision/uvision.tmpl b/tools/export/uvision/uvision.tmpl index c2261a64951e..2ca08621a5b7 100644 --- a/tools/export/uvision/uvision.tmpl +++ b/tools/export/uvision/uvision.tmpl @@ -369,8 +369,8 @@ 0 1 0 - 4 - 2 + {{v6_lang}} + {{v6_lang_p}} 1 1 0