mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 09:39:39 +00:00
Meta: Extract platform detection utilities to their own file
This will be needed by other scripts. To do so, this patch gives up on the importlib method of importing packages. I tried extracting this helper to e.g. __init__.py, but the python runtime was unable to find the imported symbols.
This commit is contained in:
parent
872a112cad
commit
a76e880dfe
Notes:
github-actions[bot]
2025-05-29 23:35:33 +00:00
Author: https://github.com/trflynn89
Commit: a76e880dfe
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4904
Reviewed-by: https://github.com/ADKaster
2 changed files with 49 additions and 61 deletions
42
Meta/host_platform.py
Normal file
42
Meta/host_platform.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
# Copyright (c) 2025, ayeteadoe <ayeteadoe@gmail.com>
|
||||
# Copyright (c) 2025, Tim Flynn <trflynn89@ladybird.org>
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
import enum
|
||||
import platform
|
||||
import sys
|
||||
|
||||
|
||||
class HostArchitecture(enum.IntEnum):
|
||||
x86_64 = enum.auto()
|
||||
AArch64 = enum.auto()
|
||||
|
||||
|
||||
class HostSystem(enum.IntEnum):
|
||||
Linux = enum.auto()
|
||||
macOS = enum.auto()
|
||||
Windows = enum.auto()
|
||||
|
||||
|
||||
class Platform:
|
||||
def __init__(self):
|
||||
self.system = platform.system()
|
||||
if self.system == "Windows":
|
||||
self.host_system = HostSystem.Windows
|
||||
elif self.system == "Darwin":
|
||||
self.host_system = HostSystem.macOS
|
||||
elif self.system == "Linux":
|
||||
self.host_system = HostSystem.Linux
|
||||
else:
|
||||
print(f"Unsupported host system {self.system}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
self.architecture = platform.machine().lower()
|
||||
if self.architecture in ("x86_64", "amd64"):
|
||||
self.host_architecture = HostArchitecture.x86_64
|
||||
elif self.architecture in ("aarch64", "arm64"):
|
||||
self.host_architecture = HostArchitecture.AArch64
|
||||
else:
|
||||
print(f"Unsupported host architecture {self.architecture}", file=sys.stderr)
|
||||
sys.exit(1)
|
Loading…
Add table
Add a link
Reference in a new issue