2022-01-04 10:12:03 +01:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
2022-07-22 12:31:52 +02:00
|
|
|
from install_requirements import install_requirements
|
|
|
|
|
|
|
|
install_requirements()
|
|
|
|
|
2021-05-16 13:09:32 +02:00
|
|
|
import argparse
|
2022-01-04 10:12:03 +01:00
|
|
|
import shutil
|
|
|
|
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-01-04 10:12:03 +01:00
|
|
|
|
2022-07-15 13:08:17 +02:00
|
|
|
vcpkg_version = "98f8d00e89fb6a8019c2045cfa1edbe9d92d3405" # Master 09.07.2022
|
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):
|
|
|
|
execute(command["command"], command["cwd"], command["ignore_error"], command["use_shell"], command["print_command"])
|
|
|
|
else:
|
|
|
|
# Function call
|
|
|
|
command["command"]()
|
|
|
|
|
2021-05-16 13:09:32 +02:00
|
|
|
if __name__ == "__main__":
|
|
|
|
parser = argparse.ArgumentParser(
|
2022-01-04 10:12:03 +01:00
|
|
|
description='Install ScreenPlay dependencies.')
|
2021-05-16 13:09:32 +02:00
|
|
|
parser.add_argument(
|
2022-01-04 10:12:03 +01:00
|
|
|
'--path', help='Manually set the vcpkg path. The path must be an absolute path \
|
|
|
|
without the ScreenPlay-vcpkg folder (E.g. py .\setup.py --path "D:/Backup/Code/Qt/")')
|
2021-05-16 13:09:32 +02:00
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
# ScreenPlay source and ScreenPlay-vcpkg have to be on the same file system hierarchy
|
|
|
|
project_source_parent_path = ""
|
2022-01-04 10:12:03 +01:00
|
|
|
project_source_path = Path.cwd().resolve()
|
|
|
|
if project_source_path.name == "Tools":
|
|
|
|
project_source_path = project_source_path.parent
|
2021-05-16 13:09:32 +02:00
|
|
|
|
2021-05-16 14:10:37 +02:00
|
|
|
if args.path is not None:
|
2022-01-04 10:12:03 +01:00
|
|
|
project_source_parent_path = Path(args.path).resolve()
|
2021-05-16 13:09:32 +02:00
|
|
|
else:
|
2022-01-04 10:12:03 +01:00
|
|
|
print("No --path provided, using default path.")
|
|
|
|
project_source_parent_path = project_source_path.parent
|
2021-05-16 13:09:32 +02:00
|
|
|
|
2022-01-04 10:12:03 +01:00
|
|
|
print("project_source_parent_path: {}".format(project_source_parent_path))
|
|
|
|
print("project_source_path: {}".format(project_source_path))
|
2021-05-16 13:09:32 +02:00
|
|
|
|
2022-01-04 10:12:03 +01:00
|
|
|
vcpkg_path = project_source_parent_path.joinpath("ScreenPlay-vcpkg")
|
2021-05-16 13:09:32 +02:00
|
|
|
print("vcpkg_path: ", vcpkg_path)
|
|
|
|
print("Build vcpkg ", vcpkg_version)
|
|
|
|
|
|
|
|
vcpkg_triplet = ""
|
2022-01-04 10:12:03 +01:00
|
|
|
vcpkg_command = ""
|
|
|
|
platform_command = commands_list()
|
2022-05-12 14:36:18 +02:00
|
|
|
vcpkg_packages_list = [
|
|
|
|
"openssl",
|
|
|
|
"curl",
|
|
|
|
"cpp-httplib",
|
|
|
|
"libarchive"
|
|
|
|
]
|
2022-04-24 09:01:59 +02:00
|
|
|
|
2022-07-22 13:35:23 +02:00
|
|
|
download_ffmpeg.execute()
|
|
|
|
|
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]")
|
2022-04-24 09:01:59 +02:00
|
|
|
vcpkg_packages_list.append("sentry-native")
|
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"
|
2022-05-12 14:36:18 +02:00
|
|
|
#vcpkg_packages_list.append("infoware[opencl]") does not work with arm
|
2021-06-12 15:17:38 +02:00
|
|
|
vcpkg_packages_list.append("curl") # Hidden dependency from sentry
|
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-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"
|
2021-07-25 16:21:16 +02:00
|
|
|
#vcpkg_packages_list.append("infoware[opengl]")
|
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-05-12 14:36:18 +02:00
|
|
|
for triplet in vcpkg_triplet:
|
|
|
|
execute("git clone https://github.com/microsoft/vcpkg.git ScreenPlay-vcpkg", project_source_parent_path, True)
|
|
|
|
execute("git fetch", vcpkg_path)
|
|
|
|
execute("git checkout {}".format(vcpkg_version), vcpkg_path)
|
|
|
|
platform_command.execute_commands() # Execute platform specific commands.
|
|
|
|
vcpkg_packages = " ".join(vcpkg_packages_list)
|
|
|
|
execute("{} remove --outdated --recurse".format(vcpkg_command), vcpkg_path, False)
|
|
|
|
execute("{} update".format(vcpkg_command), vcpkg_path, False)
|
|
|
|
execute("{} upgrade --no-dry-run".format(vcpkg_command),
|
|
|
|
vcpkg_path, False)
|
|
|
|
execute("{} install {} --triplet {} --recurse".format(vcpkg_command,
|
|
|
|
vcpkg_packages, triplet), vcpkg_path, False)
|