aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Brunet <charles.brunet@optelgroup.com>2023-01-27 13:55:46 -0500
committerXavier Claessens <xclaesse@gmail.com>2023-02-01 11:33:17 -0500
commit3729b6bcd4087217ad364bf2b84131880a01af40 (patch)
tree8f3fe56743fe41c1ba9f4701e3aed78a91a0153a
parent9e9fa8f8204fd56bd6e56c22062b8297cd65b407 (diff)
downloadmeson-3729b6bcd4087217ad364bf2b84131880a01af40.zip
meson-3729b6bcd4087217ad364bf2b84131880a01af40.tar.gz
meson-3729b6bcd4087217ad364bf2b84131880a01af40.tar.bz2
remove /utf-8 option when /validate-charset- is present
-rw-r--r--mesonbuild/compilers/mixins/visualstudio.py4
-rw-r--r--unittests/internaltests.py22
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,', [])