install_swappy_android.py 1.8 KB

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