aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/environment.py
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2018-10-30 20:03:37 +0000
committerJon Turney <jon.turney@dronecode.org.uk>2018-12-06 13:26:51 +0000
commitf3b5c3c27d03fa03d4ede49a9c3ddeb519c14d17 (patch)
tree974e96934c2deddea2062ff7093abd56b3ba1eab /mesonbuild/environment.py
parenta872b925ea41be3e6beffeb934030068c0d83be9 (diff)
downloadmeson-f3b5c3c27d03fa03d4ede49a9c3ddeb519c14d17.zip
meson-f3b5c3c27d03fa03d4ede49a9c3ddeb519c14d17.tar.gz
meson-f3b5c3c27d03fa03d4ede49a9c3ddeb519c14d17.tar.bz2
Simplify test for x86 targeted MSVC cross-compiler
We can't just do compiler.has_builtin_define('_M_IX86'), because the VisualStudioCCompiler class doesn't implement has_builtin_define(), and getting the compiler to disgorge it's builtin defines isn't easy... But we can now use the target we stored when we identifed the compiler. Also update comment appropriately
Diffstat (limited to 'mesonbuild/environment.py')
-rw-r--r--mesonbuild/environment.py40
1 files changed, 10 insertions, 30 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index 95a64c6..d18c546 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -166,11 +166,13 @@ def detect_windows_arch(compilers):
easily detected.
In the end, the sanest method is as follows:
- 1. Check if we're in an MSVC toolchain environment, and if so, return the
- MSVC toolchain architecture as our 'native' architecture.
- 2. If not, check environment variables that are set by Windows and WOW64 to
- find out the architecture that Windows is built for, and use that as our
- 'native' architecture.
+ 1. Check environment variables that are set by Windows and WOW64 to find out
+ if this is x86 (possibly in WOW64), if so use that as our 'native'
+ architecture.
+ 2. If the compiler toolchain target architecture is x86, use that as our
+ 'native' architecture.
+ 3. Otherwise, use the actual Windows architecture
+
"""
os_arch = detect_native_windows_arch()
if os_arch != 'amd64':
@@ -180,31 +182,9 @@ def detect_windows_arch(compilers):
# 32-bit and pretend like we're running under WOW64. Else, return the
# actual Windows architecture that we deduced above.
for compiler in compilers.values():
- # Check if we're using and inside an MSVC toolchain environment
- if compiler.id == 'msvc' and 'VCINSTALLDIR' in os.environ:
- 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', 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:
- # 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.
- else:
- platform = os.environ.get('Platform', 'x86').lower()
- if platform == 'x86':
- return platform
- if compiler.id == 'clang-cl' and not compiler.is_64:
+ if compiler.id == 'msvc' and compiler.target == 'x86':
+ return 'x86'
+ if compiler.id == 'clang-cl' and compiler.target == 'x86':
return 'x86'
if compiler.id == 'gcc' and compiler.has_builtin_define('__i386__'):
return 'x86'