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
pull/7672/head
Christoph Reiter 4 years ago committed by Jussi Pakkanen
parent da1b6d0a9f
commit 0710ad18d9
  1. 4
      mesonbuild/envconfig.py
  2. 5
      mesonbuild/environment.py
  3. 4
      mesonbuild/mesonlib.py
  4. 5
      mesonbuild/mtest.py
  5. 2
      test cases/common/215 link custom/custom_stlib.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:
"""

@ -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:

@ -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:

@ -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'

@ -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']

Loading…
Cancel
Save