aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/environment.py
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild/environment.py')
-rw-r--r--mesonbuild/environment.py28
1 files changed, 26 insertions, 2 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index 74bae32..688070f 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -395,6 +395,27 @@ def detect_cpu(compilers: CompilersDict) -> str:
# detect_cpu_family() above.
return trial
+KERNEL_MAPPINGS: T.Mapping[str, str] = {'freebsd': 'freebsd',
+ 'openbsd': 'openbsd',
+ 'netbsd': 'netbsd',
+ 'windows': 'nt',
+ 'android': 'linux',
+ 'linux': 'linux',
+ 'cygwin': 'nt',
+ 'darwin': 'xnu',
+ 'sunos': 'sunos',
+ 'dragonfly': 'dragonfly',
+ 'haiku': 'haiku',
+ }
+
+def detect_kernel(system: str) -> T.Optional[str]:
+ return KERNEL_MAPPINGS.get(system, None)
+
+def detect_subsystem(system: str) -> T.Optional[str]:
+ if system == 'darwin':
+ return 'macos'
+ return system
+
def detect_system() -> str:
if sys.platform == 'cygwin':
return 'cygwin'
@@ -411,11 +432,14 @@ def detect_machine_info(compilers: T.Optional[CompilersDict] = None) -> MachineI
underlying ''detect_*'' method can be called to explicitly use the
partial information.
"""
+ system = detect_system()
return MachineInfo(
- detect_system(),
+ system,
detect_cpu_family(compilers) if compilers is not None else None,
detect_cpu(compilers) if compilers is not None else None,
- sys.byteorder)
+ sys.byteorder,
+ detect_kernel(system),
+ detect_subsystem(system))
# TODO make this compare two `MachineInfo`s purely. How important is the
# `detect_cpu_family({})` distinction? It is the one impediment to that.