Path: blob/master/misc/scripts/install_swappy_android.py
20884 views
#!/usr/bin/env python12import os3import shutil4import sys5import tempfile6import urllib.request7from zipfile import ZipFile89sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../"))1011from misc.utility.color import Ansi, color_print1213# Swappy14# Check for latest version: https://github.com/godotengine/godot-swappy/releases/latest15swappy_tag = "from-source-2025-01-31"16swappy_filename = "godot-swappy.zip"17swappy_folder = "thirdparty/swappy-frame-pacing"18swappy_archs = [19"arm64-v8a",20"armeabi-v7a",21"x86",22"x86_64",23]2425swappy_archive_destination = os.path.join(tempfile.gettempdir(), swappy_filename)2627if os.path.isfile(swappy_archive_destination):28os.remove(swappy_archive_destination)2930print(f"Downloading Swappy {swappy_tag} ...")31urllib.request.urlretrieve(32f"https://github.com/godotengine/godot-swappy/releases/download/{swappy_tag}/{swappy_filename}",33swappy_archive_destination,34)3536for arch in swappy_archs:37folder = os.path.join(swappy_folder, arch)38if os.path.exists(folder):39print(f"Removing existing local Swappy installation in {folder} ...")40shutil.rmtree(folder)4142print(f"Extracting Swappy {swappy_tag} to {swappy_folder} ...")43with ZipFile(swappy_archive_destination, "r") as zip_file:44for arch in swappy_archs:45zip_file.getinfo(f"{arch}/libswappy_static.a").filename = os.path.join(46swappy_folder, f"{arch}/libswappy_static.a"47)48zip_file.extract(f"{arch}/libswappy_static.a")49os.remove(swappy_archive_destination)50print("Swappy installed successfully.\n")5152# Complete message53color_print(f'{Ansi.GREEN}Swappy was installed to "{swappy_folder}" successfully!')54color_print(55f'{Ansi.GREEN}You can now build Godot with Swappy support enabled by running "scons platform=android swappy=yes".'56)575859