]> glassweightruler.freedombox.rocks Git - waydroid.git/blob - tools/helpers/arch.py
app_manager: Allow install/remove/list while frozen
[waydroid.git] / tools / helpers / arch.py
1 # Copyright 2021 Oliver Smith
2 # SPDX-License-Identifier: GPL-3.0-or-later
3 import platform
4 import logging
5
6 def host():
7 machine = platform.machine()
8
9 mapping = {
10 "i686": "x86",
11 "x86_64": "x86_64",
12 "aarch64": "arm64",
13 "armv7l": "arm",
14 "armv8l": "arm"
15 }
16 if machine in mapping:
17 return maybe_remap(mapping[machine])
18 raise ValueError("platform.machine '" + machine + "'"
19 " architecture is not supported")
20
21 def maybe_remap(target):
22 if target == "x86_64":
23 with open("/proc/cpuinfo") as f:
24 if "sse4_2" not in f.read():
25 logging.info("x86_64 CPU does not support SSE4.2, falling back to x86...")
26 return "x86"
27
28 return target