aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2023-02-07 14:04:44 -0800
committerNirbheek Chauhan <nirbheek@centricular.com>2023-02-19 02:55:58 +0530
commit095a6c4da2d5da95cf8c9a9e35f5c55895957859 (patch)
tree873d35abc2f9a934397f9906b8240db166ff3ec9
parent95ae4f72f4a54525543b7a29ecdad1210c8a317a (diff)
downloadmeson-095a6c4da2d5da95cf8c9a9e35f5c55895957859.zip
meson-095a6c4da2d5da95cf8c9a9e35f5c55895957859.tar.gz
meson-095a6c4da2d5da95cf8c9a9e35f5c55895957859.tar.bz2
compilers: Remove /utf-8 from Visual Studio command args once
Instead of looking at it each time get_always_args() is called, do it once. Also avoid mutating global state.
-rw-r--r--mesonbuild/compilers/mixins/visualstudio.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/mesonbuild/compilers/mixins/visualstudio.py b/mesonbuild/compilers/mixins/visualstudio.py
index de179af..864d3b4 100644
--- a/mesonbuild/compilers/mixins/visualstudio.py
+++ b/mesonbuild/compilers/mixins/visualstudio.py
@@ -420,6 +420,15 @@ class MSVCCompiler(VisualStudioLikeCompiler):
id = 'msvc'
+ def __init__(self, target: str):
+ super().__init__(target)
+
+ # Visual Studio 2013 and erlier don't support the /utf-8 argument.
+ # We want to remove it. We also want to make an explicit copy so we
+ # don't mutate class constant state
+ if mesonlib.version_compare(self.version, '<19.00') and '/utf-8' in self.always_args:
+ self.always_args = [r for r in self.always_args if r != '/utf-8']
+
def get_compile_debugfile_args(self, rel_obj: str, pch: bool = False) -> T.List[str]:
args = super().get_compile_debugfile_args(rel_obj, pch)
# When generating a PDB file with PCH, all compile commands write
@@ -435,9 +444,6 @@ class MSVCCompiler(VisualStudioLikeCompiler):
# Override CCompiler.get_always_args
# We want to drop '/utf-8' for Visual Studio 2013 and earlier
def get_always_args(self) -> T.List[str]:
- if mesonlib.version_compare(self.version, '<19.00'):
- if '/utf-8' in self.always_args:
- self.always_args.remove('/utf-8')
return self.always_args
def get_instruction_set_args(self, instruction_set: str) -> T.Optional[T.List[str]]: