Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/misc/scripts/install_swappy_android.py
20884 views
1
#!/usr/bin/env python
2
3
import os
4
import shutil
5
import sys
6
import tempfile
7
import urllib.request
8
from zipfile import ZipFile
9
10
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../"))
11
12
from misc.utility.color import Ansi, color_print
13
14
# Swappy
15
# Check for latest version: https://github.com/godotengine/godot-swappy/releases/latest
16
swappy_tag = "from-source-2025-01-31"
17
swappy_filename = "godot-swappy.zip"
18
swappy_folder = "thirdparty/swappy-frame-pacing"
19
swappy_archs = [
20
"arm64-v8a",
21
"armeabi-v7a",
22
"x86",
23
"x86_64",
24
]
25
26
swappy_archive_destination = os.path.join(tempfile.gettempdir(), swappy_filename)
27
28
if os.path.isfile(swappy_archive_destination):
29
os.remove(swappy_archive_destination)
30
31
print(f"Downloading Swappy {swappy_tag} ...")
32
urllib.request.urlretrieve(
33
f"https://github.com/godotengine/godot-swappy/releases/download/{swappy_tag}/{swappy_filename}",
34
swappy_archive_destination,
35
)
36
37
for arch in swappy_archs:
38
folder = os.path.join(swappy_folder, arch)
39
if os.path.exists(folder):
40
print(f"Removing existing local Swappy installation in {folder} ...")
41
shutil.rmtree(folder)
42
43
print(f"Extracting Swappy {swappy_tag} to {swappy_folder} ...")
44
with ZipFile(swappy_archive_destination, "r") as zip_file:
45
for arch in swappy_archs:
46
zip_file.getinfo(f"{arch}/libswappy_static.a").filename = os.path.join(
47
swappy_folder, f"{arch}/libswappy_static.a"
48
)
49
zip_file.extract(f"{arch}/libswappy_static.a")
50
os.remove(swappy_archive_destination)
51
print("Swappy installed successfully.\n")
52
53
# Complete message
54
color_print(f'{Ansi.GREEN}Swappy was installed to "{swappy_folder}" successfully!')
55
color_print(
56
f'{Ansi.GREEN}You can now build Godot with Swappy support enabled by running "scons platform=android swappy=yes".'
57
)
58
59