aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2018-12-05 21:55:13 +0530
committerJussi Pakkanen <jpakkane@gmail.com>2018-12-05 19:39:01 +0200
commitb75ff762f80a76b25f3e53cf1713674d6a850e6c (patch)
tree7189df538e882d069206dccf7611e878ae2c00ef
parent5f8aedfa8be0f35354689558276e58e7ad574203 (diff)
downloadmeson-b75ff762f80a76b25f3e53cf1713674d6a850e6c.zip
meson-b75ff762f80a76b25f3e53cf1713674d6a850e6c.tar.gz
meson-b75ff762f80a76b25f3e53cf1713674d6a850e6c.tar.bz2
Fix detection with VS 2017, and fix a bug in detection on VS 2008
Starting with VS 2017, `Platform` is not always set (f.ex., if you use VsDevCmd.bat directly instead of vcvars*.bat), but `VSCMD_ARG_HOST_ARCH` is always set, so try that first.
-rw-r--r--mesonbuild/environment.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index 9e25add..984dc58 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -185,17 +185,23 @@ def detect_windows_arch(compilers):
if float(compiler.get_toolset_version()) < 10.0:
# On MSVC 2008 and earlier, check 'BUILD_PLAT', where
# 'Win32' means 'x86'
- platform = os.environ.get('BUILD_PLAT', 'x86')
+ platform = os.environ.get('BUILD_PLAT', os_arch)
if platform == 'Win32':
return 'x86'
elif 'VSCMD_ARG_TGT_ARCH' in os.environ:
# On MSVC 2017 'Platform' is not set in VsDevCmd.bat
return os.environ['VSCMD_ARG_TGT_ARCH']
else:
- # On MSVC 2010 and later 'Platform' is only set when the
+ # Starting with VS 2017, `Platform` is not always set (f.ex.,
+ # if you use VsDevCmd.bat directly instead of vcvars*.bat), but
+ # `VSCMD_ARG_HOST_ARCH` is always set, so try that first.
+ if 'VSCMD_ARG_HOST_ARCH' in os.environ:
+ platform = os.environ['VSCMD_ARG_HOST_ARCH'].lower()
+ # On VS 2010-2015, 'Platform' is only set when the
# target arch is not 'x86'. It's 'x64' when targeting
# x86_64 and 'arm' when targeting ARM.
- platform = os.environ.get('Platform', 'x86').lower()
+ else:
+ platform = os.environ.get('Platform', 'x86').lower()
if platform == 'x86':
return platform
if compiler.id == 'clang-cl' and not compiler.is_64: