aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChun-wei Fan <fanc999@yahoo.com.tw>2023-01-10 15:28:37 +0800
committerNirbheek Chauhan <nirbheek@centricular.com>2023-02-19 02:55:58 +0530
commit12c1e13ea1176203242c0ac4d94001eb1b12bb1e (patch)
tree5c5d184b0485e8015d1290c2d81bfaa4abbe3d5a
parent5dcca393232b1f4a62b4110ae6dc26388a523a62 (diff)
downloadmeson-12c1e13ea1176203242c0ac4d94001eb1b12bb1e.zip
meson-12c1e13ea1176203242c0ac4d94001eb1b12bb1e.tar.gz
meson-12c1e13ea1176203242c0ac4d94001eb1b12bb1e.tar.bz2
Visual Studio: Drop /utf-8 if it is not supported
We assume /utf-8 for all C builds unless /source-charset or /execution-charset is specified, but then this will cause trouble for Visual Studio 2013 or earler since the /utf-8 flag is only supported since Visual Studio 2015. Specifically, if we try to check whether compiler flags are supported, those checks will fail since /utf-8 is never supported on these older Visual Studio versions. Drop /utf-8 from get_always_args() if we are using Visual Studio 2013 or earlier.
-rw-r--r--mesonbuild/compilers/mixins/visualstudio.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/mesonbuild/compilers/mixins/visualstudio.py b/mesonbuild/compilers/mixins/visualstudio.py
index 5a326dc..48d0bbb 100644
--- a/mesonbuild/compilers/mixins/visualstudio.py
+++ b/mesonbuild/compilers/mixins/visualstudio.py
@@ -105,6 +105,8 @@ class VisualStudioLikeCompiler(Compiler, metaclass=abc.ABCMeta):
# See: https://ninja-build.org/manual.html#_deps
# Assume UTF-8 sources by default, but self.unix_args_to_native() removes it
# if `/source-charset` is set too.
+ # It is also dropped if Visual Studio 2013 or earlier is used, since it would
+ # not be supported in that case.
always_args = ['/nologo', '/showIncludes', '/utf-8']
warn_args = {
'0': [],
@@ -429,6 +431,14 @@ class MSVCCompiler(VisualStudioLikeCompiler):
args = ['/FS'] + args
return args
+ # 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]]:
if self.version.split('.')[0] == '16' and instruction_set == 'avx':
# VS documentation says that this exists and should work, but