aboutsummaryrefslogtreecommitdiffstats
path: root/python/servo/util.py
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2023-05-18 15:09:30 +0200
committerMartin Robinson <mrobinson@igalia.com>2023-05-19 13:08:43 +0200
commit5be14ecc3cc92309637604b48bdcf249b110ac16 (patch)
treeef5f13d8e79866eda1a84c847837938c884ebb2c /python/servo/util.py
parente09f85e17bd504a4c1c218ad14fa1a0ecbcaa839 (diff)
downloadservo-5be14ecc3cc92309637604b48bdcf249b110ac16.tar.gz
servo-5be14ecc3cc92309637604b48bdcf249b110ac16.zip
Start organizing platform-specific Python code
This starts to split platform-specific Python code into its own module, which should help to tidy up our mach commands and make things more reusable.
Diffstat (limited to 'python/servo/util.py')
-rw-r--r--python/servo/util.py39
1 files changed, 4 insertions, 35 deletions
diff --git a/python/servo/util.py b/python/servo/util.py
index c41cb1e1640..4151bbd4929 100644
--- a/python/servo/util.py
+++ b/python/servo/util.py
@@ -12,7 +12,6 @@ from __future__ import absolute_import, print_function, unicode_literals
import hashlib
import os
import os.path
-import platform
import shutil
import stat
import sys
@@ -59,40 +58,6 @@ def delete(path):
os.remove(path)
-def host_platform():
- os_type = platform.system().lower()
- if os_type == "linux":
- os_type = "unknown-linux-gnu"
- elif os_type == "darwin":
- os_type = "apple-darwin"
- elif os_type == "android":
- os_type = "linux-androideabi"
- elif os_type == "windows":
- os_type = "pc-windows-msvc"
- elif os_type == "freebsd":
- os_type = "unknown-freebsd"
- else:
- os_type = "unknown"
- return os_type
-
-
-def host_triple():
- os_type = host_platform()
- cpu_type = platform.machine().lower()
- if cpu_type in ["i386", "i486", "i686", "i768", "x86"]:
- cpu_type = "i686"
- elif cpu_type in ["x86_64", "x86-64", "x64", "amd64"]:
- cpu_type = "x86_64"
- elif cpu_type == "arm":
- cpu_type = "arm"
- elif cpu_type == "aarch64":
- cpu_type = "aarch64"
- else:
- cpu_type = "unknown"
-
- return "{}-{}".format(cpu_type, os_type)
-
-
def download(desc, src, writer, start_byte=0):
if start_byte:
print("Resuming download of {} ...".format(src))
@@ -229,3 +194,7 @@ def check_hash(filename, expected, algorithm):
if hasher.hexdigest() != expected:
print("Incorrect {} hash for {}".format(algorithm, filename))
sys.exit(1)
+
+
+def get_default_cache_dir(topdir):
+ return os.environ.get("SERVO_CACHE_DIR", os.path.join(topdir, ".servo"))