aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/environment.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2023-04-17 12:46:46 +0300
committerEli Schwartz <eschwartz@archlinux.org>2023-05-01 15:22:56 -0400
commitf2e292a0e20e84b45f0d0a9acb99dfe32977df43 (patch)
tree7c5f8bd15e2feb2b1126d03a8e5aeb1d793225b0 /mesonbuild/environment.py
parentf3635ff50d90ca2fbf87271dc3146f2aacdb6b3c (diff)
downloadmeson-eli/submit/doc-no-pr-publish.zip
meson-eli/submit/doc-no-pr-publish.tar.gz
meson-eli/submit/doc-no-pr-publish.tar.bz2
Add kernel and userland properties to machine objects.eli/submit/doc-no-pr-publish
Diffstat (limited to 'mesonbuild/environment.py')
-rw-r--r--mesonbuild/environment.py30
1 files changed, 28 insertions, 2 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index 36aa94e..9b67137 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -395,6 +395,29 @@ def detect_cpu(compilers: CompilersDict) -> str:
# detect_cpu_family() above.
return trial
+kernel_mappings = {'freebsd': 'freebsd',
+ 'openbsd': 'openbsd',
+ 'windows': 'windows',
+ 'android': 'linux',
+ 'cygwin': 'windows',
+ 'darwin': 'xnu',
+ }
+
+userland_mappings = {'freebsd': 'freebsd',
+ 'openbsd': 'openbsd',
+ 'windows': 'windows',
+ 'darwin': 'macos',
+ 'gnu': 'gnu',
+ }
+
+def detect_kernel(system: str) -> T.Optional[str]:
+ return kernel_mappings.get(system, None)
+
+def detect_userland(system: str) -> T.Optional[str]:
+ if system == 'linux':
+ return 'gnu' # Fixme, check whether we are on a glibc system.
+ return userland_mappings.get(system, None)
+
def detect_system() -> str:
if sys.platform == 'cygwin':
return 'cygwin'
@@ -411,11 +434,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_userland(system))
# TODO make this compare two `MachineInfo`s purely. How important is the
# `detect_cpu_family({})` distinction? It is the one impediment to that.