remove /utf-8 option when /validate-charset- is present

pull/10811/head
Charles Brunet 2 years ago committed by Xavier Claessens
parent 9e9fa8f820
commit 3729b6bcd4
  1. 4
      mesonbuild/compilers/mixins/visualstudio.py
  2. 22
      unittests/internaltests.py

@ -260,7 +260,9 @@ class VisualStudioLikeCompiler(Compiler, metaclass=abc.ABCMeta):
continue continue
# cl.exe does not allow specifying both, so remove /utf-8 that we # cl.exe does not allow specifying both, so remove /utf-8 that we
# added automatically in the case the user overrides it manually. # 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: try:
result.remove('/utf-8') result.remove('/utf-8')
except ValueError: except ValueError:

@ -36,6 +36,7 @@ import mesonbuild.environment
import mesonbuild.modules.gnome import mesonbuild.modules.gnome
from mesonbuild import coredata from mesonbuild import coredata
from mesonbuild.compilers.c import ClangCCompiler, GnuCCompiler from mesonbuild.compilers.c import ClangCCompiler, GnuCCompiler
from mesonbuild.compilers.cpp import VisualStudioCPPCompiler
from mesonbuild.compilers.d import DmdDCompiler from mesonbuild.compilers.d import DmdDCompiler
from mesonbuild.interpreterbase import typed_pos_args, InvalidArguments, ObjectHolder from mesonbuild.interpreterbase import typed_pos_args, InvalidArguments, ObjectHolder
from mesonbuild.interpreterbase import typed_pos_args, InvalidArguments, typed_kwargs, ContainerTypeInfo, KwargInfo 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') l.append_direct('/libbaz.a')
self.assertEqual(l, ['-Lfoodir', '-lfoo', '-Lbardir', '-lbar', '-lbar', '/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): def test_compiler_args_class_gnuld(self):
## Test --start/end-group ## Test --start/end-group
linker = mesonbuild.linkers.GnuBFDDynamicLinker([], MachineChoice.HOST, '-Wl,', []) linker = mesonbuild.linkers.GnuBFDDynamicLinker([], MachineChoice.HOST, '-Wl,', [])

Loading…
Cancel
Save