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
|
|
|
import platform
|
2020-10-29 18:19:22 +01:00
|
|
|
import os
|
2022-07-08 12:33:26 +02:00
|
|
|
import platform
|
2020-10-29 18:19:22 +01:00
|
|
|
import shutil
|
|
|
|
import argparse
|
2022-01-04 10:12:03 +01:00
|
|
|
import time
|
2022-07-09 13:05:42 +02:00
|
|
|
import zipfile
|
2022-10-10 11:35:41 +02:00
|
|
|
import defines
|
2023-08-24 16:17:48 +02:00
|
|
|
from build_result import BuildResult
|
|
|
|
from build_config import BuildConfig
|
2022-08-07 12:24:07 +02:00
|
|
|
from typing import Tuple
|
2022-01-04 10:12:03 +01:00
|
|
|
from pathlib import Path
|
2023-02-11 11:57:09 +01:00
|
|
|
import macos_sign
|
2023-11-02 12:50:29 +01:00
|
|
|
import build_godot
|
2023-11-29 11:33:14 +01:00
|
|
|
from util import sha256, cd_repo_root_path, repo_root_path, zipdir, run, get_vs_env_dict, get_latest_git_tag, parse_semver, semver_to_string, check_universal_binary
|
2022-11-02 12:15:34 +01:00
|
|
|
from sys import stdout
|
|
|
|
|
|
|
|
stdout.reconfigure(encoding='utf-8')
|
|
|
|
|
2022-07-09 13:05:42 +02:00
|
|
|
|
2022-01-04 10:12:03 +01:00
|
|
|
def clean_build_dir(build_dir):
|
2022-07-15 12:43:57 +02:00
|
|
|
if build_dir.exists():
|
|
|
|
print(f"Remove previous build folder: {build_dir}")
|
|
|
|
# ignore_errors removes also not empty folders...
|
|
|
|
shutil.rmtree(build_dir, ignore_errors=True)
|
|
|
|
build_dir.mkdir(parents=True, exist_ok=True)
|
2022-01-04 10:12:03 +01:00
|
|
|
|
2022-07-09 13:05:42 +02:00
|
|
|
|
2022-07-24 17:56:00 +02:00
|
|
|
def execute(
|
|
|
|
build_config: BuildConfig
|
|
|
|
) -> BuildResult:
|
2022-11-02 12:56:34 +01:00
|
|
|
start_time = time.time()
|
2022-07-15 12:43:57 +02:00
|
|
|
# Make sure the script is always started from the same folder
|
2022-07-24 17:56:00 +02:00
|
|
|
build_config.root_path = cd_repo_root_path()
|
|
|
|
|
|
|
|
# Sets all platform spesific paths, arguments etc.
|
2023-02-11 15:17:50 +01:00
|
|
|
[build_config, build_result] = setup(build_config)
|
2022-07-24 17:56:00 +02:00
|
|
|
|
|
|
|
build_result.build = Path(build_config.build_folder)
|
2022-11-02 16:29:35 +01:00
|
|
|
build_result.bin = Path(build_config.bin_dir)
|
2022-07-24 17:56:00 +02:00
|
|
|
|
|
|
|
# Make sure to always delete everything first.
|
|
|
|
# 3rd party tools like the crashreporter create local
|
|
|
|
# temporary files in the build directory.
|
|
|
|
clean_build_dir(build_config.build_folder)
|
2023-08-11 17:00:24 +02:00
|
|
|
|
2022-07-24 17:56:00 +02:00
|
|
|
# Runs cmake configure and cmake build
|
2022-11-02 12:56:34 +01:00
|
|
|
step_time = time.time()
|
2022-07-24 17:56:00 +02:00
|
|
|
build_result = build(build_config, build_result)
|
2022-11-02 12:56:34 +01:00
|
|
|
build_duration = time.time() - step_time
|
2023-08-24 16:43:46 +02:00
|
|
|
print(f"⏱️ build_duration: {build_duration}s")
|
2023-11-23 13:05:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
# Build Godot Wallpaper
|
|
|
|
# Note: This must happen after building ScreenPlay!
|
|
|
|
if platform.system() == "Windows":
|
|
|
|
build_godot.build_godot(str(build_config.bin_dir), build_config.build_type)
|
|
|
|
|
2022-07-24 17:56:00 +02:00
|
|
|
|
|
|
|
# Copies all needed libraries and assets into the bin folder
|
2022-11-02 12:56:34 +01:00
|
|
|
step_time = time.time()
|
2022-08-14 11:58:41 +02:00
|
|
|
package(build_config)
|
2022-11-02 12:56:34 +01:00
|
|
|
package_duration = time.time() - step_time
|
|
|
|
print(f"⏱️ package_duration: {package_duration}s")
|
2022-07-24 17:56:00 +02:00
|
|
|
|
2023-08-24 16:02:43 +02:00
|
|
|
if platform.system() == "Darwin":
|
|
|
|
if (build_config.sign_osx):
|
|
|
|
print(f"Sign binary at: {build_config.bin_dir}")
|
|
|
|
macos_sign.sign(build_config=build_config)
|
|
|
|
|
2022-07-24 17:56:00 +02:00
|
|
|
# Creates a Qt InstallerFrameWork (IFW) installer
|
|
|
|
if build_config.create_installer == "ON":
|
2022-11-02 12:56:34 +01:00
|
|
|
step_time = time.time()
|
2022-07-29 15:24:45 +02:00
|
|
|
build_installer(build_config, build_result)
|
2022-11-02 12:56:34 +01:00
|
|
|
build_installer_duration = time.time() - step_time
|
2023-08-24 16:17:48 +02:00
|
|
|
print(f"⏱️ build_installer_duration: {build_installer_duration}s")
|
|
|
|
|
2023-08-24 16:02:43 +02:00
|
|
|
if platform.system() == "Darwin":
|
2023-12-03 11:42:51 +01:00
|
|
|
# TODO FIX installer signing
|
|
|
|
return
|
2023-08-24 16:02:43 +02:00
|
|
|
if (build_config.sign_osx):
|
2023-12-03 11:42:51 +01:00
|
|
|
# Base directory
|
|
|
|
base_dir = Path(build_config.build_folder)
|
|
|
|
|
|
|
|
# Paths for the original and new filenames
|
|
|
|
original_file = base_dir / 'ScreenPlay-Installer-ScreenPlayComponent.dmg'
|
|
|
|
new_file = base_dir / 'ScreenPlay-Installer.dmg'
|
|
|
|
|
|
|
|
# Renaming the file
|
|
|
|
try:
|
|
|
|
original_file.rename(new_file)
|
|
|
|
print(f"File renamed successfully to {new_file}")
|
|
|
|
except OSError as error:
|
|
|
|
print(f"Error: {error}")
|
|
|
|
|
2023-08-24 16:17:48 +02:00
|
|
|
print(
|
2023-12-03 11:42:51 +01:00
|
|
|
f"Sign ScreenPlay-installer.dmg at: {new_file}")
|
|
|
|
macos_sign.sign_dmg(build_config)
|
2022-07-24 17:56:00 +02:00
|
|
|
|
2023-08-18 20:23:12 +02:00
|
|
|
# Create a zip file of the build
|
2023-08-24 16:02:43 +02:00
|
|
|
if platform.system() != "Darwin":
|
|
|
|
step_time = time.time()
|
|
|
|
build_result = zip(build_config, build_result)
|
|
|
|
zip_duration = time.time() - step_time
|
|
|
|
print(f"⏱️ zip_duration: {zip_duration}s")
|
2022-07-24 17:56:00 +02:00
|
|
|
|
2022-11-02 12:56:34 +01:00
|
|
|
duration = time.time() - start_time
|
|
|
|
print(f"⏱️ Build completed in: {duration}s")
|
2022-07-15 12:43:57 +02:00
|
|
|
|
2022-07-24 17:56:00 +02:00
|
|
|
# Print BuildConfig & BuildResult member for easier debugging
|
2022-11-02 12:56:34 +01:00
|
|
|
print("\n🆗 BuildResult:")
|
2023-08-11 17:00:24 +02:00
|
|
|
print(' '.join("\n- %s: \t\t%s" %
|
|
|
|
item for item in vars(build_result).items()))
|
2022-11-02 12:56:34 +01:00
|
|
|
print("\n⚙️ BuildConfig:")
|
2023-08-11 17:00:24 +02:00
|
|
|
print(' '.join("\n- %s: \t\t%s" %
|
|
|
|
item for item in vars(build_config).items()))
|
2022-07-15 12:43:57 +02:00
|
|
|
|
2022-07-24 17:56:00 +02:00
|
|
|
return build_result
|
|
|
|
|
|
|
|
|
2023-02-11 15:17:50 +01:00
|
|
|
def setup(build_config: BuildConfig) -> Tuple[BuildConfig, BuildResult]:
|
|
|
|
build_result = BuildResult()
|
2023-01-05 13:42:58 +01:00
|
|
|
build_config.qt_path = defines.QT_PATH
|
2022-07-24 17:56:00 +02:00
|
|
|
|
2023-01-05 13:42:58 +01:00
|
|
|
if not build_config.qt_path.exists():
|
2023-08-11 17:00:24 +02:00
|
|
|
print(
|
|
|
|
f"Qt path does not exist at {build_config.qt_path}. Please make sure to run setup.py!")
|
2023-01-05 13:42:58 +01:00
|
|
|
exit(2)
|
2023-08-11 17:00:24 +02:00
|
|
|
build_config.qt_bin_path = Path(build_config.qt_path).joinpath(
|
|
|
|
f"{build_config.qt_version}/{defines.QT_PLATFORM}").resolve()
|
|
|
|
build_config.ifw_root_path = Path(
|
|
|
|
f"{build_config.qt_path}/Tools/QtInstallerFramework/{build_config.qt_ifw_version}").resolve()
|
2022-07-15 12:43:57 +02:00
|
|
|
|
|
|
|
if platform.system() == "Windows":
|
2022-07-24 17:56:00 +02:00
|
|
|
build_config.cmake_target_triplet = "x64-windows"
|
|
|
|
build_config.executable_file_ending = ".exe"
|
2022-11-11 13:09:16 +01:00
|
|
|
env_dict = get_vs_env_dict()
|
|
|
|
env_dict["PATH"] = env_dict["PATH"] + \
|
|
|
|
";" + str(Path(build_config.qt_bin_path).joinpath("bin").resolve()) + \
|
|
|
|
";" + str(build_config.ifw_root_path.resolve())
|
|
|
|
print(f"Using env_dict:\n{env_dict}")
|
|
|
|
os.environ.update(env_dict)
|
2022-07-24 17:56:00 +02:00
|
|
|
# NO f string we fill it later!
|
2023-02-04 16:00:57 +01:00
|
|
|
build_config.package_command = "windeployqt.exe --{type} --qmldir ../../{app}/qml {app}{executable_file_ending}"
|
2022-07-24 17:56:00 +02:00
|
|
|
build_config.aqt_install_qt_packages = f"windows desktop {build_config.qt_version} win64_msvc2019_64 -m all"
|
|
|
|
build_config.aqt_install_tool_packages = "windows desktop tools_ifw"
|
2022-07-15 12:43:57 +02:00
|
|
|
|
|
|
|
elif platform.system() == "Darwin":
|
2023-06-02 09:51:56 +02:00
|
|
|
build_config.cmake_target_triplet = "64-osx-universal"
|
2022-07-29 15:24:45 +02:00
|
|
|
build_config.executable_file_ending = ".app"
|
2022-07-24 17:56:00 +02:00
|
|
|
# NO f string we fill it later!
|
2023-08-11 17:00:24 +02:00
|
|
|
# build_config.package_command = "{prefix_path}/bin/macdeployqt ScreenPlay.app -qmldir=../../{app}/qml -executable=ScreenPlay.app/Contents/MacOS/{app} -appstore-compliant -timestamp -hardened-runtime"
|
2022-07-24 17:56:00 +02:00
|
|
|
build_config.aqt_install_qt_packages = f"mac desktop {build_config.qt_version} clang_64 -m all"
|
|
|
|
build_config.aqt_install_tool_packages = "mac desktop tools_ifw"
|
2023-08-11 17:00:24 +02:00
|
|
|
|
2022-07-15 12:43:57 +02:00
|
|
|
elif platform.system() == "Linux":
|
2022-07-24 17:56:00 +02:00
|
|
|
build_config.cmake_target_triplet = "x64-linux"
|
2022-07-29 15:24:45 +02:00
|
|
|
build_config.executable_file_ending = ""
|
2022-07-24 17:56:00 +02:00
|
|
|
build_config.aqt_install_qt_packages = f"linux desktop {build_config.qt_version} gcc_64 -m all"
|
|
|
|
build_config.aqt_install_tool_packages = "linux desktop tools_ifw"
|
2022-07-15 12:43:57 +02:00
|
|
|
else:
|
|
|
|
raise NotImplementedError(
|
|
|
|
"Unsupported platform, ScreenPlay only supports Windows, macOS and Linux.")
|
|
|
|
|
|
|
|
# Prepare
|
2023-08-11 17:00:24 +02:00
|
|
|
build_config.cmake_toolchain_file = Path(
|
|
|
|
f"{build_config.root_path}/../vcpkg/scripts/buildsystems/vcpkg.cmake").resolve()
|
2022-07-24 17:56:00 +02:00
|
|
|
print(f"cmake_toolchain_file: {build_config.cmake_toolchain_file}")
|
2022-11-11 13:09:16 +01:00
|
|
|
print(f"Starting build with type {build_config.build_type}.")
|
2023-08-11 17:00:24 +02:00
|
|
|
print(
|
|
|
|
f"Qt Version: {build_config.qt_version}. Root path: {build_config.root_path}")
|
2022-07-15 12:43:57 +02:00
|
|
|
|
2023-02-11 15:17:50 +01:00
|
|
|
# Remove old build folder to before configuring to get rid of all cmake chaches
|
2023-08-11 17:00:24 +02:00
|
|
|
build_config.build_folder = build_config.root_path.joinpath(
|
|
|
|
f"build-{build_config.cmake_target_triplet}-{build_config.build_type}")
|
2022-07-24 17:56:00 +02:00
|
|
|
build_config.bin_dir = build_config.build_folder.joinpath("bin")
|
2022-07-22 13:21:30 +02:00
|
|
|
|
2022-07-24 17:56:00 +02:00
|
|
|
if platform.system() == "Windows":
|
2023-08-11 17:00:24 +02:00
|
|
|
build_result.installer = Path(build_config.build_folder).joinpath(
|
|
|
|
"ScreenPlay-Installer.exe")
|
2022-07-24 17:56:00 +02:00
|
|
|
elif platform.system() == "Darwin":
|
2023-08-11 17:00:24 +02:00
|
|
|
build_result.installer = Path(
|
|
|
|
build_config.build_folder).joinpath("ScreenPlay.dmg")
|
2022-07-24 17:56:00 +02:00
|
|
|
elif platform.system() == "Linux":
|
2023-08-11 17:00:24 +02:00
|
|
|
build_result.installer = Path(build_config.build_folder).joinpath(
|
|
|
|
"ScreenPlay-Installer.run")
|
2022-07-24 17:56:00 +02:00
|
|
|
|
|
|
|
return build_config, build_result
|
2022-07-22 13:21:30 +02:00
|
|
|
|
2022-07-15 12:43:57 +02:00
|
|
|
|
2022-07-24 17:56:00 +02:00
|
|
|
def build(build_config: BuildConfig, build_result: BuildResult) -> BuildResult:
|
2022-07-15 12:43:57 +02:00
|
|
|
cmake_configure_command = f'cmake ../ \
|
2022-07-24 17:56:00 +02:00
|
|
|
-DCMAKE_PREFIX_PATH={build_config.qt_bin_path} \
|
|
|
|
-DCMAKE_BUILD_TYPE={build_config.build_type} \
|
|
|
|
-DVCPKG_TARGET_TRIPLET={build_config.cmake_target_triplet} \
|
|
|
|
-DCMAKE_TOOLCHAIN_FILE={build_config.cmake_toolchain_file} \
|
|
|
|
-DSCREENPLAY_STEAM={build_config.build_steam} \
|
|
|
|
-DSCREENPLAY_TESTS={build_config.build_tests} \
|
2022-08-14 11:58:41 +02:00
|
|
|
-DSCREENPLAY_DEPLOY={build_config.build_deploy} \
|
2022-07-24 17:56:00 +02:00
|
|
|
-DSCREENPLAY_INSTALLER={build_config.create_installer} \
|
|
|
|
-DSCREENPLAY_IFW_ROOT:STRING={build_config.ifw_root_path} \
|
2023-08-17 14:26:39 +02:00
|
|
|
-G "Ninja" \
|
2022-05-06 17:23:14 +02:00
|
|
|
-B.'
|
2022-01-04 10:12:03 +01:00
|
|
|
|
2022-11-04 16:31:26 +01:00
|
|
|
print(f"\n⚙️ CMake configure:\n", cmake_configure_command.replace(
|
|
|
|
"-D", "\n-D").replace("-G", "\n-G"), "\n")
|
2022-07-24 17:56:00 +02:00
|
|
|
run(cmake_configure_command, cwd=build_config.build_folder)
|
2022-11-02 12:56:34 +01:00
|
|
|
print(f"\n\n⚙️ CMake build:\n\n")
|
2022-07-24 17:56:00 +02:00
|
|
|
run("cmake --build . --target all", cwd=build_config.build_folder)
|
2022-07-15 12:43:57 +02:00
|
|
|
|
2022-11-02 16:29:35 +01:00
|
|
|
build_result.bin = Path(build_config.bin_dir)
|
2022-07-24 17:56:00 +02:00
|
|
|
|
|
|
|
return build_result
|
2022-07-15 12:43:57 +02:00
|
|
|
|
|
|
|
|
2022-08-14 11:58:41 +02:00
|
|
|
def package(build_config: BuildConfig):
|
2022-07-24 17:56:00 +02:00
|
|
|
|
2023-02-11 11:57:09 +01:00
|
|
|
if platform.system() == "Darwin":
|
|
|
|
# Make sure to reset to tools path
|
|
|
|
os.chdir(repo_root_path())
|
2023-08-11 17:00:24 +02:00
|
|
|
# -sign-for-notarization=\"Developer ID Application: Elias Steurer (V887LHYKRH)\"
|
|
|
|
cmd_raw = "{qt_bin_path}/macdeployqt {build_bin_dir}/ScreenPlay.app -qmldir={repo_root_path}/{app}/qml -executable={build_bin_dir}/ScreenPlay.app/Contents/MacOS/{app} -verbose=1 -appstore-compliant -timestamp -hardened-runtime "
|
|
|
|
build_bin_dir = Path(repo_root_path()).joinpath(
|
|
|
|
f"{build_config.build_folder}/bin/")
|
|
|
|
cwd = Path(repo_root_path()).joinpath(
|
|
|
|
f"{build_bin_dir}/ScreenPlay.app/Contents/MacOS/")
|
2023-02-11 11:57:09 +01:00
|
|
|
qt_bin_path = Path(defines.QT_BIN_PATH).resolve()
|
|
|
|
source_path = Path(repo_root_path()).resolve()
|
|
|
|
|
2023-08-11 17:00:24 +02:00
|
|
|
run(cmd=cmd_raw.format(qt_bin_path=qt_bin_path, repo_root_path=source_path,
|
|
|
|
build_bin_dir=build_bin_dir, app="ScreenPlay"), cwd=cwd)
|
|
|
|
run(cmd=cmd_raw.format(qt_bin_path=qt_bin_path, repo_root_path=source_path,
|
|
|
|
build_bin_dir=build_bin_dir, app="ScreenPlayWallpaper"), cwd=cwd)
|
|
|
|
run(cmd=cmd_raw.format(qt_bin_path=qt_bin_path, repo_root_path=source_path,
|
|
|
|
build_bin_dir=build_bin_dir, app="ScreenPlayWidget"), cwd=cwd)
|
2023-11-29 11:33:14 +01:00
|
|
|
|
|
|
|
check_universal_binary()
|
2023-02-11 11:57:09 +01:00
|
|
|
|
|
|
|
if platform.system() == "Windows":
|
2022-07-15 12:43:57 +02:00
|
|
|
print("Executing deploy commands...")
|
2022-08-14 11:58:41 +02:00
|
|
|
run(build_config.package_command.format(
|
2022-07-24 17:56:00 +02:00
|
|
|
type=build_config.build_type,
|
|
|
|
prefix_path=build_config.qt_bin_path,
|
2022-07-15 12:43:57 +02:00
|
|
|
app="ScreenPlay",
|
2022-07-24 17:56:00 +02:00
|
|
|
executable_file_ending=build_config.executable_file_ending), cwd=build_config.bin_dir)
|
2022-07-15 12:43:57 +02:00
|
|
|
|
2022-08-14 11:58:41 +02:00
|
|
|
run(build_config.package_command.format(
|
2022-07-24 17:56:00 +02:00
|
|
|
type=build_config.build_type,
|
|
|
|
prefix_path=build_config.qt_bin_path,
|
2022-07-15 12:43:57 +02:00
|
|
|
app="ScreenPlayWidget",
|
2022-07-24 17:56:00 +02:00
|
|
|
executable_file_ending=build_config.executable_file_ending), cwd=build_config.bin_dir)
|
2022-07-15 12:43:57 +02:00
|
|
|
|
2022-08-14 11:58:41 +02:00
|
|
|
run(build_config.package_command.format(
|
2022-07-24 17:56:00 +02:00
|
|
|
type=build_config.build_type,
|
|
|
|
prefix_path=build_config.qt_bin_path,
|
2022-07-15 12:43:57 +02:00
|
|
|
app="ScreenPlayWallpaper",
|
2022-07-24 17:56:00 +02:00
|
|
|
executable_file_ending=build_config.executable_file_ending), cwd=build_config.bin_dir)
|
2023-02-11 11:57:09 +01:00
|
|
|
|
|
|
|
if platform.system() == "Linux":
|
2022-07-29 16:08:25 +02:00
|
|
|
# Copy all .so files from the qt_bin_path lib folder into bin_dir
|
|
|
|
qt_lib_path = build_config.qt_bin_path
|
|
|
|
for file in qt_lib_path.joinpath("lib").glob("*.so"):
|
|
|
|
shutil.copy(str(file), str(build_config.bin_dir))
|
|
|
|
|
|
|
|
# Copy qt_qml_path folder content into bin_dir
|
|
|
|
qt_qml_path = build_config.qt_bin_path
|
|
|
|
for folder in qt_qml_path.joinpath("qml").iterdir():
|
|
|
|
if not folder.is_file():
|
|
|
|
shutil.copytree(str(folder), str(
|
|
|
|
build_config.bin_dir.joinpath(folder.name)))
|
|
|
|
print("Copied %s" % folder)
|
|
|
|
|
|
|
|
# Copy all plugin folder from qt_bin_path plugins subfolder into bin_dir
|
|
|
|
qt_plugins_path = build_config.qt_bin_path
|
|
|
|
for folder in build_config.qt_bin_path.joinpath("plugins").iterdir():
|
|
|
|
if not folder.is_file():
|
|
|
|
shutil.copytree(str(folder), str(
|
|
|
|
build_config.bin_dir.joinpath(folder.name)))
|
|
|
|
print("Copied %s" % folder)
|
|
|
|
|
|
|
|
# Copy all folder from qt_bin_path translation files into bin_dir translation folder
|
|
|
|
qt_translations_path = build_config.qt_bin_path
|
|
|
|
for folder in qt_translations_path.joinpath("translations").iterdir():
|
|
|
|
if not folder.is_file():
|
|
|
|
shutil.copytree(str(folder), str(
|
|
|
|
build_config.bin_dir.joinpath("translations").joinpath(folder.name)))
|
|
|
|
print("Copied %s" % folder)
|
|
|
|
|
|
|
|
# Copy all filesfrom qt_bin_path resources folder into bin_dir folder
|
|
|
|
qt_resources_path = build_config.qt_bin_path
|
|
|
|
for file in build_config.qt_bin_path.joinpath("resources").glob("*"):
|
|
|
|
shutil.copy(str(file), str(build_config.bin_dir))
|
|
|
|
print("Copied %s" % file)
|
2022-07-15 12:43:57 +02:00
|
|
|
|
|
|
|
# Some dlls like openssl do no longer get copied automatically.
|
|
|
|
# Lets just copy all of them into bin.
|
|
|
|
if platform.system() == "Windows":
|
|
|
|
vcpkg_bin_path = Path(
|
2022-12-16 13:34:15 +01:00
|
|
|
f"{build_config.root_path}/../vcpkg/installed/x64-windows/bin").resolve()
|
2022-07-15 12:43:57 +02:00
|
|
|
for file in vcpkg_bin_path.iterdir():
|
|
|
|
if file.suffix == ".dll" and file.is_file():
|
2023-06-02 13:25:42 +02:00
|
|
|
print("Copy: ", file, build_config.bin_dir)
|
|
|
|
shutil.copy2(file, build_config.bin_dir)
|
|
|
|
|
2022-07-15 12:43:57 +02:00
|
|
|
if not platform.system() == "Darwin":
|
2022-07-24 17:56:00 +02:00
|
|
|
file_endings = [".ninja_deps", ".ninja", ".ninja_log", ".lib", ".a", ".exp",
|
|
|
|
".manifest", ".cmake", ".cbp", "CMakeCache.txt"]
|
2022-07-15 12:43:57 +02:00
|
|
|
for file_ending in file_endings:
|
2022-07-24 17:56:00 +02:00
|
|
|
for file in build_config.bin_dir.rglob("*" + file_ending):
|
2022-07-15 12:43:57 +02:00
|
|
|
if file.is_file():
|
|
|
|
print("Remove: %s" % file.resolve())
|
|
|
|
file.unlink()
|
2023-11-29 11:33:14 +01:00
|
|
|
|
2022-07-15 12:43:57 +02:00
|
|
|
|
|
|
|
|
2022-07-29 15:24:45 +02:00
|
|
|
def build_installer(build_config: BuildConfig, build_result: BuildResult):
|
2022-07-24 17:56:00 +02:00
|
|
|
os.chdir(build_result.build)
|
|
|
|
print("Running cpack at: ", os.getcwd())
|
|
|
|
run("cpack", cwd=build_config.build_folder)
|
|
|
|
|
2023-08-11 17:00:24 +02:00
|
|
|
|
2022-07-24 17:56:00 +02:00
|
|
|
def zip(build_config: BuildConfig, build_result: BuildResult) -> BuildResult:
|
|
|
|
zipName = f"ScreenPlay-{build_config.screenplay_version}-{build_config.cmake_target_triplet}-{build_config.build_type}.zip"
|
2022-08-07 12:24:07 +02:00
|
|
|
build_result.build_zip = Path(build_result.build).joinpath(zipName)
|
|
|
|
print(f"Creating bin folder zip file: {build_result.build_zip}")
|
2022-07-24 17:56:00 +02:00
|
|
|
os.chdir(build_config.build_folder)
|
|
|
|
with zipfile.ZipFile(zipName, 'w', zipfile.ZIP_DEFLATED) as zipf:
|
|
|
|
zipdir(build_config.bin_dir, zipf)
|
|
|
|
|
|
|
|
zip_file_path = os.path.join(build_result.build, zipName)
|
|
|
|
build_hash = sha256(zip_file_path)
|
|
|
|
build_result.build_hash = Path(
|
|
|
|
build_result.build).joinpath(zipName + ".sha256.txt")
|
2022-08-07 12:24:07 +02:00
|
|
|
print(f"Create sha256 hash: {build_result.build_hash}")
|
2022-07-24 17:56:00 +02:00
|
|
|
f = open(build_result.build_hash, "a")
|
|
|
|
f.write(build_hash)
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
# Some weird company firewalls do not allow direct .exe downloads
|
|
|
|
# lets just zip the installer lol
|
2022-08-07 18:20:16 +02:00
|
|
|
if build_config.create_installer == "ON":
|
2023-08-11 17:00:24 +02:00
|
|
|
build_result.installer_zip = Path(build_result.build).joinpath(
|
|
|
|
build_result.installer.stem + ".zip")
|
2022-08-07 18:20:16 +02:00
|
|
|
print(f"Create zip from installer: {build_result.installer_zip}")
|
2023-08-11 17:00:24 +02:00
|
|
|
zipfile.ZipFile(build_result.installer_zip, 'w').write(
|
|
|
|
build_result.installer, build_result.installer.name)
|
2022-07-24 17:56:00 +02:00
|
|
|
|
|
|
|
return build_result
|
2022-07-09 13:05:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
2022-07-15 12:43:57 +02:00
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
description='Build and Package ScreenPlay')
|
2023-08-12 11:53:34 +02:00
|
|
|
parser.add_argument('--qt-version', action="store", dest="qt_version_overwrite",
|
2022-07-15 12:43:57 +02:00
|
|
|
help="Overwrites the default Qt version")
|
2023-08-12 11:53:34 +02:00
|
|
|
parser.add_argument('--qt-installer-version', action="store", dest="qt_installer_version_overwrite",
|
2022-07-15 12:43:57 +02:00
|
|
|
help="Overwrites the default Qt installer framework version")
|
2023-08-12 11:53:34 +02:00
|
|
|
parser.add_argument('--type', action="store", dest="build_type", default="release",
|
2022-07-15 12:43:57 +02:00
|
|
|
help="Build type. This is either debug or release.")
|
2023-08-12 11:53:34 +02:00
|
|
|
parser.add_argument('--use-aqt', action="store_true", dest="use_aqt",
|
2022-07-15 12:43:57 +02:00
|
|
|
help="Absolute qt path. If not set the default path is used\Windows: C:\Qt\nLinux & macOS:~/Qt/.")
|
2023-08-12 11:53:34 +02:00
|
|
|
parser.add_argument('--steam', action="store_true", dest="build_steam",
|
2022-07-15 12:43:57 +02:00
|
|
|
help="Enable if you want to build the Steam workshop plugin.")
|
2023-08-12 11:53:34 +02:00
|
|
|
parser.add_argument('--tests', action="store_true", dest="build_tests",
|
2022-07-15 12:43:57 +02:00
|
|
|
help="Build tests.")
|
2023-08-12 11:53:34 +02:00
|
|
|
parser.add_argument('--installer', action="store_true", dest="create_installer",
|
2022-07-15 12:43:57 +02:00
|
|
|
help="Create a installer.")
|
2023-08-12 11:53:34 +02:00
|
|
|
parser.add_argument('--sign_osx', action="store_true", dest="sign_osx", default=False,
|
2023-02-11 11:57:09 +01:00
|
|
|
help="Signs the executable on macOS. This requires a valid Apple Developer ID set up.")
|
2023-08-12 11:53:34 +02:00
|
|
|
parser.add_argument('--deploy-version', action="store_true", dest="build_deploy",
|
2022-08-14 11:58:41 +02:00
|
|
|
help="Create a deploy version of ScreenPlay for sharing with the world. A not deploy version is for local development only!")
|
2023-08-12 11:53:34 +02:00
|
|
|
parser.add_argument('--architecture', action="store", dest="build_architecture", default="",
|
2022-07-15 12:43:57 +02:00
|
|
|
help="Sets the build architecture. Used to build x86 and ARM osx versions. Currently only works with x86_64 and arm64")
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
2022-10-10 11:35:41 +02:00
|
|
|
qt_version = defines.QT_VERSION
|
|
|
|
qt_ifw_version = defines.QT_IFW_VERSION # Not yet used.
|
2022-07-24 17:56:00 +02:00
|
|
|
qt_version_overwrite: str
|
2022-07-15 12:43:57 +02:00
|
|
|
use_aqt = False
|
|
|
|
|
2023-08-17 14:26:39 +02:00
|
|
|
tag = get_latest_git_tag()
|
|
|
|
if tag:
|
|
|
|
print(f"Latest Git tag: {tag}")
|
|
|
|
semver = parse_semver(tag)
|
|
|
|
if semver:
|
|
|
|
print(f"Parsed SemVer: {semver}")
|
|
|
|
screenplay_version = semver_to_string(semver)
|
|
|
|
else:
|
|
|
|
print("Failed to parse SemVer.")
|
|
|
|
exit(-1)
|
|
|
|
else:
|
|
|
|
print("No git tags found.")
|
|
|
|
exit(-1)
|
|
|
|
|
2022-07-15 12:43:57 +02:00
|
|
|
if args.qt_version_overwrite:
|
|
|
|
qt_version = args.qt_version_overwrite
|
|
|
|
print("Using Qt version {qt_version}")
|
|
|
|
|
|
|
|
if args.qt_installer_version_overwrite:
|
|
|
|
qt_ifw_version = args.qt_installer_version_overwrite
|
|
|
|
print("Using Qt installer framework version {qt_ifw_version}")
|
|
|
|
|
2023-11-02 12:50:29 +01:00
|
|
|
build_type = args.build_type.lower()
|
2022-07-15 12:43:57 +02:00
|
|
|
|
|
|
|
build_steam = "OFF"
|
|
|
|
if args.build_steam:
|
|
|
|
build_steam = "ON"
|
|
|
|
|
|
|
|
build_tests = "OFF"
|
|
|
|
if args.build_tests:
|
|
|
|
build_tests = "ON"
|
|
|
|
|
2022-08-14 11:58:41 +02:00
|
|
|
build_deploy = "OFF"
|
|
|
|
if args.build_deploy:
|
|
|
|
build_deploy = "ON"
|
2022-07-15 12:43:57 +02:00
|
|
|
|
|
|
|
create_installer = "OFF"
|
|
|
|
if args.create_installer:
|
|
|
|
create_installer = "ON"
|
|
|
|
|
2022-07-29 14:56:45 +02:00
|
|
|
if args.use_aqt:
|
|
|
|
use_aqt = True
|
|
|
|
|
2023-06-02 09:51:56 +02:00
|
|
|
if not args.build_architecture:
|
|
|
|
build_architecture = ""
|
|
|
|
|
2022-07-24 17:56:00 +02:00
|
|
|
build_config = BuildConfig()
|
|
|
|
build_config.qt_version = qt_version
|
|
|
|
build_config.qt_ifw_version = qt_ifw_version
|
|
|
|
build_config.build_steam = build_steam
|
|
|
|
build_config.build_tests = build_tests
|
2022-08-14 11:58:41 +02:00
|
|
|
build_config.build_deploy = build_deploy
|
2022-07-24 17:56:00 +02:00
|
|
|
build_config.create_installer = create_installer
|
|
|
|
build_config.build_type = build_type
|
2022-07-29 15:34:01 +02:00
|
|
|
build_config.screenplay_version = screenplay_version
|
2023-06-02 09:51:56 +02:00
|
|
|
build_config.build_architecture = build_architecture
|
2023-02-11 11:57:09 +01:00
|
|
|
build_config.sign_osx = args.sign_osx
|
2022-07-24 17:56:00 +02:00
|
|
|
|
|
|
|
execute(build_config)
|