diff options
author | Charles Brunet <charles.brunet@optelgroup.com> | 2023-01-27 13:55:46 -0500 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2023-02-06 23:37:55 +0530 |
commit | 1794471986a487c7662cadde7455052ca7dcb36c (patch) | |
tree | 818895331de870170bad85470dfa849dc360137d | |
parent | a605aad93c9a9896cd2c9efdbb23d030f1813867 (diff) | |
download | meson-1794471986a487c7662cadde7455052ca7dcb36c.zip meson-1794471986a487c7662cadde7455052ca7dcb36c.tar.gz meson-1794471986a487c7662cadde7455052ca7dcb36c.tar.bz2 |
remove /utf-8 option when /validate-charset- is present
-rw-r--r-- | mesonbuild/compilers/mixins/visualstudio.py | 4 | ||||
-rw-r--r-- | unittests/internaltests.py | 22 |
2 files changed, 25 insertions, 1 deletions
diff --git a/mesonbuild/compilers/mixins/visualstudio.py b/mesonbuild/compilers/mixins/visualstudio.py index 765d63d..0473f2e 100644 --- a/mesonbuild/compilers/mixins/visualstudio.py +++ b/mesonbuild/compilers/mixins/visualstudio.py @@ -260,7 +260,9 @@ class VisualStudioLikeCompiler(Compiler, metaclass=abc.ABCMeta): continue # cl.exe does not allow specifying both, so remove /utf-8 that we # added automatically in the case the user overrides it manually. - elif i.startswith('/source-charset:') or i.startswith('/execution-charset:'): + elif (i.startswith('/source-charset:') + or i.startswith('/execution-charset:') + or i == '/validate-charset-'): try: result.remove('/utf-8') except ValueError: diff --git a/unittests/internaltests.py b/unittests/internaltests.py index 29d4bb3..a669558 100644 --- a/unittests/internaltests.py +++ b/unittests/internaltests.py @@ -36,6 +36,7 @@ import mesonbuild.environment import mesonbuild.modules.gnome from mesonbuild import coredata from mesonbuild.compilers.c import ClangCCompiler, GnuCCompiler +from mesonbuild.compilers.cpp import VisualStudioCPPCompiler from mesonbuild.compilers.d import DmdDCompiler from mesonbuild.interpreterbase import typed_pos_args, InvalidArguments, ObjectHolder from mesonbuild.interpreterbase import typed_pos_args, InvalidArguments, typed_kwargs, ContainerTypeInfo, KwargInfo @@ -220,6 +221,27 @@ class InternalTests(unittest.TestCase): l.append_direct('/libbaz.a') self.assertEqual(l, ['-Lfoodir', '-lfoo', '-Lbardir', '-lbar', '-lbar', '/libbaz.a']) + + def test_compiler_args_class_visualstudio(self): + linker = mesonbuild.linkers.MSVCDynamicLinker(MachineChoice.HOST, []) + cc = VisualStudioCPPCompiler([], [], 'fake', MachineChoice.HOST, False, mock.Mock(), 'x64', linker=linker) + + a = cc.compiler_args(cc.get_always_args()) + self.assertEqual(a.to_native(copy=True), ['/nologo', '/showIncludes', '/utf-8']) + + # Ensure /source-charset: removes /utf-8 + a.append('/source-charset:utf-8') + self.assertEqual(a.to_native(copy=True), ['/nologo', '/showIncludes', '/source-charset:utf-8']) + + # Ensure /execution-charset: removes /utf-8 + a = cc.compiler_args(cc.get_always_args() + ['/execution-charset:utf-8']) + self.assertEqual(a.to_native(copy=True), ['/nologo', '/showIncludes', '/execution-charset:utf-8']) + + # Ensure /validate-charset- removes /utf-8 + a = cc.compiler_args(cc.get_always_args() + ['/validate-charset-']) + self.assertEqual(a.to_native(copy=True), ['/nologo', '/showIncludes', '/validate-charset-']) + + def test_compiler_args_class_gnuld(self): ## Test --start/end-group linker = mesonbuild.linkers.GnuBFDDynamicLinker([], MachineChoice.HOST, '-Wl,', []) |