aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2020-08-30 17:53:41 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2020-08-30 23:37:46 +0300
commit0710ad18d919ba38d00aa5f68444e2fcb47a45ac (patch)
treeaf0d16148bac75236b21cdf29152992c74247e4d
parentda1b6d0a9fd723f0cb17a4ce73d5adc51a0c5199 (diff)
downloadmeson-0710ad18d919ba38d00aa5f68444e2fcb47a45ac.zip
meson-0710ad18d919ba38d00aa5f68444e2fcb47a45ac.tar.gz
meson-0710ad18d919ba38d00aa5f68444e2fcb47a45ac.tar.bz2
Be stricter when detecting Windows/Cygwin
This removes the check for "mingw" for platform.system(). The only case I know where "mingw" is return is if using a msys Python under a msys2 mingw environment. This combination is not really supported by meson and will result in weird errors, so remove the check. The second change is checking sys.platform for cygwin instead of platform.system(). The former is document to return "cygwin", while the latter is not and just returns uname(). While under Cygwin it uname() always starts with "cygwin" it's not hardcoded in MSYS2 and starts with the environment name. Using sys.platform is safer here. Fixes #7552
-rw-r--r--mesonbuild/envconfig.py4
-rw-r--r--mesonbuild/environment.py5
-rw-r--r--mesonbuild/mesonlib.py4
-rw-r--r--mesonbuild/mtest.py5
-rwxr-xr-xtest cases/common/215 link custom/custom_stlib.py2
5 files changed, 9 insertions, 11 deletions
diff --git a/mesonbuild/envconfig.py b/mesonbuild/envconfig.py
index 9402d38..5258fa0 100644
--- a/mesonbuild/envconfig.py
+++ b/mesonbuild/envconfig.py
@@ -211,13 +211,13 @@ class MachineInfo:
"""
Machine is windows?
"""
- return self.system == 'windows' or 'mingw' in self.system
+ return self.system == 'windows'
def is_cygwin(self) -> bool:
"""
Machine is cygwin?
"""
- return self.system.startswith('cygwin')
+ return self.system == 'cygwin'
def is_linux(self) -> bool:
"""
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index f1bd2e1..eb7189c 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -429,10 +429,9 @@ def detect_cpu(compilers: CompilersDict):
return trial
def detect_system():
- system = platform.system().lower()
- if system.startswith('cygwin'):
+ if sys.platform == 'cygwin':
return 'cygwin'
- return system
+ return platform.system().lower()
def detect_msys2_arch():
if 'MSYSTEM_CARCH' in os.environ:
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
index 45e3b34..a510ab9 100644
--- a/mesonbuild/mesonlib.py
+++ b/mesonbuild/mesonlib.py
@@ -502,11 +502,11 @@ def is_openbsd() -> bool:
def is_windows() -> bool:
platname = platform.system().lower()
- return platname == 'windows' or 'mingw' in platname
+ return platname == 'windows'
def is_cygwin() -> bool:
- return platform.system().lower().startswith('cygwin')
+ return sys.platform == 'cygwin'
def is_debianlike() -> bool:
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py
index d7fe54a..de82234 100644
--- a/mesonbuild/mtest.py
+++ b/mesonbuild/mtest.py
@@ -58,11 +58,10 @@ GNU_ERROR_RETURNCODE = 99
def is_windows() -> bool:
platname = platform.system().lower()
- return platname == 'windows' or 'mingw' in platname
+ return platname == 'windows'
def is_cygwin() -> bool:
- platname = platform.system().lower()
- return 'cygwin' in platname
+ return sys.platform == 'cygwin'
def determine_worker_count() -> int:
varname = 'MESON_TESTTHREADS'
diff --git a/test cases/common/215 link custom/custom_stlib.py b/test cases/common/215 link custom/custom_stlib.py
index 0157fb1..6a090f3 100755
--- a/test cases/common/215 link custom/custom_stlib.py
+++ b/test cases/common/215 link custom/custom_stlib.py
@@ -18,7 +18,7 @@ void flob(void) {
def get_pic_args():
platname = platform.system().lower()
- if platname in ['windows', 'mingw', 'darwin'] or platname.startswith('cygwin'):
+ if platname in ['windows', 'darwin'] or sys.platform == 'cygwin':
return []
return ['-fPIC']