aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2023-04-17 12:46:46 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2023-04-17 12:46:46 +0300
commit83f37d2c351366fb4a88a0ed4400bc5ce370a248 (patch)
tree032de5cab3d94cdae1957b4528ba3b6f3af799ab
parentd2eba9e944a7473495d4842232923852bf18ea33 (diff)
downloadmeson-83f37d2c351366fb4a88a0ed4400bc5ce370a248.zip
meson-83f37d2c351366fb4a88a0ed4400bc5ce370a248.tar.gz
meson-83f37d2c351366fb4a88a0ed4400bc5ce370a248.tar.bz2
Add kernel and userland properties to machine objects.sysprops
-rw-r--r--mesonbuild/envconfig.py8
-rw-r--r--mesonbuild/environment.py19
-rw-r--r--mesonbuild/interpreter/interpreterobjects.py13
3 files changed, 37 insertions, 3 deletions
diff --git a/mesonbuild/envconfig.py b/mesonbuild/envconfig.py
index 50c974b..b3a5905 100644
--- a/mesonbuild/envconfig.py
+++ b/mesonbuild/envconfig.py
@@ -260,6 +260,8 @@ class MachineInfo(HoldableObject):
cpu_family: str
cpu: str
endian: str
+ kernel: str
+ userland: str
def __post_init__(self) -> None:
self.is_64_bit: bool = self.cpu_family in CPU_FAMILIES_64_BIT
@@ -283,7 +285,11 @@ class MachineInfo(HoldableObject):
if endian not in ('little', 'big'):
mlog.warning(f'Unknown endian {endian}')
- return cls(literal['system'], cpu_family, literal['cpu'], endian)
+ system = literal['system']
+ kernel = literal.get('kernel', system)
+ userland = literal.get('userland', system)
+
+ return cls(system, cpu_family, literal['cpu'], endian, kernel, userland)
def is_windows(self) -> bool:
"""
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index ccd31eb..91f58ef 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -387,6 +387,18 @@ def detect_cpu(compilers: CompilersDict) -> str:
# detect_cpu_family() above.
return trial
+def detect_kernel(system: str) -> str:
+ if system == 'android':
+ return 'linux'
+ return system
+
+def detect_userland(system: str) -> str:
+ if system == 'linux':
+ return 'gnu' # Fixme, check whether we are on a glibc system.
+ if system == 'darwin':
+ return 'macos'
+ return system
+
def detect_system() -> str:
if sys.platform == 'cygwin':
return 'cygwin'
@@ -403,11 +415,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.
diff --git a/mesonbuild/interpreter/interpreterobjects.py b/mesonbuild/interpreter/interpreterobjects.py
index fa91714..52b4bdb 100644
--- a/mesonbuild/interpreter/interpreterobjects.py
+++ b/mesonbuild/interpreter/interpreterobjects.py
@@ -639,6 +639,8 @@ class MachineHolder(ObjectHolder['MachineInfo']):
'cpu': self.cpu_method,
'cpu_family': self.cpu_family_method,
'endian': self.endian_method,
+ 'kernel': self.kernel_method,
+ 'userland': self.userland_method,
})
@noPosargs
@@ -661,6 +663,17 @@ class MachineHolder(ObjectHolder['MachineInfo']):
def endian_method(self, args: T.List[TYPE_var], kwargs: TYPE_kwargs) -> str:
return self.held_object.endian
+ @noPosargs
+ @noKwargs
+ def kernel_method(self, args: T.List[TYPE_var], kwargs: TYPE_kwargs) -> str:
+ return self.held_object.kernel
+
+ @noPosargs
+ @noKwargs
+ def userland_method(self, args: T.List[TYPE_var], kwargs: TYPE_kwargs) -> str:
+ return self.held_object.userland
+
+
class IncludeDirsHolder(ObjectHolder[build.IncludeDirs]):
pass