2022-01-04 10:12:03 +01:00
|
|
|
#!/usr/bin/python3
|
2023-01-19 10:33:49 +01:00
|
|
|
# SPDX-License-Identifier: LicenseRef-EliasSteurerTachiom OR AGPL-3.0-only
|
2022-01-04 10:12:03 +01:00
|
|
|
from platform import system
|
|
|
|
from pathlib import Path
|
2021-05-16 13:09:32 +02:00
|
|
|
from execute_util import execute
|
2022-07-22 13:35:08 +02:00
|
|
|
import download_ffmpeg
|
2022-10-10 11:35:41 +02:00
|
|
|
import defines
|
|
|
|
import argparse
|
|
|
|
import util
|
2023-11-29 08:02:15 +01:00
|
|
|
import macos_make_universal
|
2022-10-10 11:35:41 +02:00
|
|
|
import datetime
|
2023-08-31 14:53:59 +02:00
|
|
|
import setup_godot
|
2022-11-02 12:15:34 +01:00
|
|
|
from sys import stdout
|
|
|
|
|
|
|
|
stdout.reconfigure(encoding='utf-8')
|
|
|
|
|
2022-01-04 10:12:03 +01:00
|
|
|
|
|
|
|
class commands_list():
|
|
|
|
def __init__(self):
|
|
|
|
self.commands = []
|
|
|
|
|
|
|
|
def add(self, command, cwd=".", ignore_error=False, use_shell=True, print_command=True):
|
|
|
|
self.commands.append({
|
|
|
|
"command": command,
|
|
|
|
"cwd": cwd,
|
|
|
|
"ignore_error": ignore_error,
|
|
|
|
"use_shell": use_shell,
|
|
|
|
"print_command": print_command
|
|
|
|
})
|
|
|
|
|
|
|
|
def get_commands(self):
|
|
|
|
return self.commands
|
|
|
|
|
|
|
|
def execute_commands(self):
|
|
|
|
'''
|
|
|
|
This function execute all commands added to the list.
|
|
|
|
'''
|
|
|
|
for command in self.commands:
|
|
|
|
# Check if the command if a string.
|
|
|
|
if isinstance(command["command"], str):
|
2023-07-24 16:22:09 +02:00
|
|
|
execute(command["command"], command["cwd"], command["ignore_error"],
|
|
|
|
command["use_shell"], command["print_command"])
|
2022-01-04 10:12:03 +01:00
|
|
|
else:
|
|
|
|
# Function call
|
|
|
|
command["command"]()
|
|
|
|
|
2023-07-24 16:22:09 +02:00
|
|
|
|
2022-10-10 11:35:41 +02:00
|
|
|
def download(aqt_path: Path, qt_platform: Path):
|
2023-10-29 11:26:42 +01:00
|
|
|
qt_packages = ""
|
2022-10-14 11:38:14 +02:00
|
|
|
if system() == "Windows":
|
|
|
|
os = "windows"
|
|
|
|
elif system() == "Darwin":
|
|
|
|
os = "mac"
|
|
|
|
elif system() == "Linux":
|
2023-10-29 11:26:42 +01:00
|
|
|
qt_packages = "qtwaylandcompositor "
|
2022-10-14 11:38:14 +02:00
|
|
|
os = "linux"
|
2023-07-24 16:22:09 +02:00
|
|
|
|
2023-10-29 11:26:42 +01:00
|
|
|
qt_packages += "qt3d qtquick3d qtconnectivity qt5compat qtimageformats qtmultimedia qtshadertools qtwebchannel qtwebengine qtwebsockets qtwebview qtpositioning"
|
2023-11-29 10:36:58 +01:00
|
|
|
# Windows: python -m aqt list-qt windows desktop --modules 6.6.1 win64_msvc2019_64
|
|
|
|
# Linux: python3 -m aqt list-qt linux desktop --modules 6.6.1 gcc_64
|
2022-10-10 11:35:41 +02:00
|
|
|
print(f"Downloading: {qt_packages} to {aqt_path}")
|
2022-10-14 11:38:14 +02:00
|
|
|
execute(f"{defines.PYTHON_EXECUTABLE} -m aqt install-qt -O {aqt_path} {os} desktop {defines.QT_VERSION} {qt_platform} -m {qt_packages}")
|
2021-05-16 13:09:32 +02:00
|
|
|
|
2022-10-10 11:35:41 +02:00
|
|
|
# Tools can only be installed one at the time:
|
2023-02-03 10:16:39 +01:00
|
|
|
# see: python -m aqt list-tool windows desktop
|
2023-11-29 08:02:15 +01:00
|
|
|
tools = ["tools_ifw"]
|
2022-10-10 11:35:41 +02:00
|
|
|
for tool in tools:
|
2023-07-24 16:22:09 +02:00
|
|
|
execute(
|
|
|
|
f"{defines.PYTHON_EXECUTABLE} -m aqt install-tool -O {aqt_path} {os} desktop {tool}")
|
|
|
|
|
2021-05-16 13:09:32 +02:00
|
|
|
|
2022-10-10 11:35:41 +02:00
|
|
|
def setup_qt():
|
2021-05-16 13:09:32 +02:00
|
|
|
|
2023-01-05 13:42:58 +01:00
|
|
|
aqt_path = defines.QT_PATH
|
2021-05-16 13:09:32 +02:00
|
|
|
|
2022-10-10 11:35:41 +02:00
|
|
|
print(f"Setup Qt via aqt at {aqt_path}")
|
|
|
|
|
|
|
|
if system() == "Windows":
|
|
|
|
qt_platform = "win64_msvc2019_64"
|
|
|
|
elif system() == "Darwin":
|
|
|
|
qt_platform = "clang_64"
|
|
|
|
elif system() == "Linux":
|
|
|
|
qt_platform = "gcc_64"
|
|
|
|
|
|
|
|
qt_base_path = aqt_path.joinpath(defines.QT_VERSION).resolve()
|
|
|
|
qt_path = qt_base_path.joinpath(qt_platform).resolve()
|
|
|
|
|
|
|
|
if not qt_path.exists():
|
|
|
|
download(aqt_path, qt_platform)
|
2023-07-24 16:22:09 +02:00
|
|
|
else:
|
|
|
|
# Betas & RCs are technically the same version. So limit download to x days
|
2022-10-10 11:35:41 +02:00
|
|
|
days = 30
|
2023-07-24 16:22:09 +02:00
|
|
|
folder_creation_date: datetime = datetime.datetime.fromtimestamp(
|
|
|
|
qt_base_path.stat().st_mtime, tz=datetime.timezone.utc)
|
|
|
|
now: datetime = datetime.datetime.now(tz=datetime.timezone.utc)
|
2022-10-10 11:35:41 +02:00
|
|
|
two_weeks_ago: datetime = now - datetime.timedelta(days=days)
|
2023-07-24 16:22:09 +02:00
|
|
|
if (folder_creation_date < two_weeks_ago):
|
|
|
|
print(
|
|
|
|
f"qt version at `{qt_base_path}` older than {days} days ({folder_creation_date}), redownload!")
|
2022-10-10 11:35:41 +02:00
|
|
|
download(aqt_path, qt_platform)
|
|
|
|
else:
|
|
|
|
print(f"Qt {defines.QT_VERSION} is up to date and ready ")
|
|
|
|
|
2023-07-24 16:22:09 +02:00
|
|
|
|
2022-10-10 11:35:41 +02:00
|
|
|
def main():
|
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
description='Build and Package ScreenPlay')
|
2023-11-09 10:30:01 +01:00
|
|
|
parser.add_argument('--skip-aqt', action="store_true", dest="skip_aqt",
|
2023-11-12 07:32:45 +01:00
|
|
|
help="Downloads QtCreator and needed binaries Windows: C:\\aqt\\nLinux & macOS:~/aqt/.")
|
2022-10-10 11:35:41 +02:00
|
|
|
args = parser.parse_args()
|
2021-05-16 13:09:32 +02:00
|
|
|
|
2022-10-10 11:35:41 +02:00
|
|
|
root_path = Path(util.cd_repo_root_path())
|
|
|
|
project_source_parent_path = root_path.joinpath("../").resolve()
|
2022-12-16 13:34:15 +01:00
|
|
|
vcpkg_path = project_source_parent_path.joinpath("vcpkg").resolve()
|
2023-10-29 18:10:13 +01:00
|
|
|
vcpkg_packages_list = defines.VCPKG_BASE_PACKAGES
|
2022-10-10 11:35:41 +02:00
|
|
|
|
2023-11-16 09:52:35 +01:00
|
|
|
if system() != "Darwin":
|
2023-11-03 17:21:36 +01:00
|
|
|
if not setup_godot.execute():
|
|
|
|
raise RuntimeError("Unable to download godot")
|
2023-11-02 12:50:29 +01:00
|
|
|
|
|
|
|
if not download_ffmpeg.execute():
|
|
|
|
raise RuntimeError("Unable to download ffmpeg")
|
|
|
|
|
2022-07-22 13:35:23 +02:00
|
|
|
|
2022-01-04 10:12:03 +01:00
|
|
|
if system() == "Windows":
|
2021-06-25 12:32:19 +02:00
|
|
|
vcpkg_command = "vcpkg.exe"
|
2021-05-16 13:09:32 +02:00
|
|
|
vcpkg_packages_list.append("infoware[d3d]")
|
2023-02-16 13:06:50 +01:00
|
|
|
vcpkg_packages_list.append("sentry-native[transport]")
|
2022-10-10 11:35:41 +02:00
|
|
|
platform_command = commands_list()
|
2022-07-15 13:11:09 +02:00
|
|
|
platform_command.add("bootstrap-vcpkg.bat", vcpkg_path, False)
|
2022-05-12 14:36:18 +02:00
|
|
|
vcpkg_triplet = ["x64-windows"]
|
2022-01-04 10:12:03 +01:00
|
|
|
elif system() == "Darwin":
|
2021-06-25 12:32:19 +02:00
|
|
|
vcpkg_command = "./vcpkg"
|
2023-07-24 16:22:09 +02:00
|
|
|
# vcpkg_packages_list.append("infoware[opencl]") does not work with arm
|
|
|
|
vcpkg_packages_list.append("curl") # Hidden dependency from sentry
|
2022-10-10 11:35:41 +02:00
|
|
|
platform_command = commands_list()
|
2022-01-04 10:12:03 +01:00
|
|
|
platform_command.add("chmod +x bootstrap-vcpkg.sh", vcpkg_path)
|
|
|
|
platform_command.add("./bootstrap-vcpkg.sh", vcpkg_path, False)
|
|
|
|
platform_command.add("chmod +x vcpkg", vcpkg_path)
|
2023-11-29 08:02:15 +01:00
|
|
|
vcpkg_triplet = ["x64-osx","arm64-osx"]
|
2022-01-04 10:12:03 +01:00
|
|
|
elif system() == "Linux":
|
2021-06-25 12:32:19 +02:00
|
|
|
vcpkg_command = "./vcpkg"
|
2023-07-24 16:22:09 +02:00
|
|
|
# vcpkg_packages_list.append("infoware[opengl]")
|
2022-10-10 11:35:41 +02:00
|
|
|
platform_command = commands_list()
|
2022-01-04 10:12:03 +01:00
|
|
|
platform_command.add("chmod +x bootstrap-vcpkg.sh", vcpkg_path)
|
|
|
|
platform_command.add("./bootstrap-vcpkg.sh", vcpkg_path, False)
|
|
|
|
platform_command.add("chmod +x vcpkg", vcpkg_path)
|
2022-05-12 14:36:18 +02:00
|
|
|
vcpkg_triplet = ["x64-linux"]
|
2022-01-04 10:12:03 +01:00
|
|
|
else:
|
|
|
|
raise NotImplementedError("Unknown system: {}".format(system()))
|
2021-05-16 13:09:32 +02:00
|
|
|
|
2022-10-10 11:35:41 +02:00
|
|
|
print(f"Clone into {vcpkg_path}")
|
2023-11-29 08:02:15 +01:00
|
|
|
execute("git clone https://github.com/microsoft/vcpkg vcpkg",
|
2023-07-24 16:22:09 +02:00
|
|
|
project_source_parent_path, True)
|
2022-10-10 11:35:41 +02:00
|
|
|
execute("git fetch", vcpkg_path)
|
2022-11-02 12:15:34 +01:00
|
|
|
execute(f"git checkout {defines.VCPKG_VERSION}", vcpkg_path)
|
2023-07-24 16:22:09 +02:00
|
|
|
|
2022-10-10 11:35:41 +02:00
|
|
|
# Setup vcpkg via boostrap script first
|
2023-07-24 16:22:09 +02:00
|
|
|
platform_command.execute_commands() # Execute platform specific commands.
|
2022-10-14 11:38:14 +02:00
|
|
|
|
2022-10-14 11:30:26 +02:00
|
|
|
execute(f"{vcpkg_command} remove --outdated --recurse", vcpkg_path, False)
|
2022-10-10 11:35:41 +02:00
|
|
|
|
2022-05-12 14:36:18 +02:00
|
|
|
for triplet in vcpkg_triplet:
|
|
|
|
vcpkg_packages = " ".join(vcpkg_packages_list)
|
2023-07-24 16:22:09 +02:00
|
|
|
execute(
|
|
|
|
f"{vcpkg_command} install {vcpkg_packages} --triplet {triplet} --recurse", vcpkg_path, False)
|
2023-11-29 08:02:15 +01:00
|
|
|
|
|
|
|
# Combine x64 and arm
|
|
|
|
if system() == "Darwin":
|
|
|
|
macos_make_universal.execute()
|
2023-07-24 16:22:09 +02:00
|
|
|
|
2023-11-02 12:50:29 +01:00
|
|
|
if not args.skip_aqt:
|
|
|
|
setup_qt()
|
2022-10-10 11:35:41 +02:00
|
|
|
|
2023-11-29 08:02:15 +01:00
|
|
|
|
|
|
|
|
2022-10-10 11:35:41 +02:00
|
|
|
if __name__ == "__main__":
|
2023-07-24 16:22:09 +02:00
|
|
|
main()
|