1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-09-02 00:29:48 +02:00

Merge remote-tracking branch 'origin/master'

This commit is contained in:
Elias Steurer 2022-07-15 13:08:23 +02:00
commit 29ca12fc6e
4 changed files with 336 additions and 320 deletions

View File

@ -13,19 +13,22 @@ if(WIN32)
elseif(UNIX AND NOT APPLE) elseif(UNIX AND NOT APPLE)
set(VCPKG_ARCH "x64-linux") set(VCPKG_ARCH "x64-linux")
elseif(APPLE) elseif(APPLE)
# CMAKE_HOST_SYSTEM_PROCESSOR returns the value of `uname -p` on host. # CMAKE_HOST_SYSTEM_PROCESSOR returns the value of `uname -p` on host.
if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL amd64)
set(VCPKG_ARCH "x64-osx")
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL arm)
set(VCPKG_ARCH "arm64-osx")
endif()
# Universal builds are not available with vcpkg, # Universal builds are not available with vcpkg,
# but the prebuild Qt binaries are. # but the prebuild Qt binaries are. CMake also handles
# https://github.com/microsoft/vcpkg/discussions/19454 # https://github.com/microsoft/vcpkg/discussions/19454
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64") # This means we must compile twice and then merge the binaries with lipo
set(VCPKG_TARGET_ARCHITECTURE x86_64 arm64) if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL amd64)
message(STATUS "[PROJECT] CMAKE_OSX_ARCHITECTURES = ${CMAKE_OSX_ARCHITECTURES}") set(VCPKG_ARCH "x64-osx")
set(CMAKE_OSX_ARCHITECTURES "x86_64")
set(VCPKG_TARGET_ARCHITECTURE x86_64)
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL arm)
set(VCPKG_ARCH "arm64-osx")
set(CMAKE_OSX_ARCHITECTURES "arm64")
set(VCPKG_TARGET_ARCHITECTURE arm64)
endif()
message(STATUS "[PROJECT] CMAKE_OSX_ARCHITECTURES = ${CMAKE_OSX_ARCHITECTURES}")
endif() endif()
# This sets cmake to compile all dlls into the main directory # This sets cmake to compile all dlls into the main directory

View File

@ -43,7 +43,6 @@ set(HEADER
inc/public/ScreenPlayUtil/AutoPropertyHelpers.h inc/public/ScreenPlayUtil/AutoPropertyHelpers.h
inc/public/ScreenPlayUtil/ConstRefPropertyHelpers.h inc/public/ScreenPlayUtil/ConstRefPropertyHelpers.h
inc/public/ScreenPlayUtil/contenttypes.h inc/public/ScreenPlayUtil/contenttypes.h
#inc/public/ScreenPlayUtil/EnumClassHelper.h
inc/public/ScreenPlayUtil/HelpersCommon.h inc/public/ScreenPlayUtil/HelpersCommon.h
inc/public/ScreenPlayUtil/httpfileserver.h inc/public/ScreenPlayUtil/httpfileserver.h
inc/public/ScreenPlayUtil/ListPropertyHelper.h inc/public/ScreenPlayUtil/ListPropertyHelper.h

View File

@ -46,7 +46,8 @@ MacWindow::MacWindow(
workingDir.cdUp(); workingDir.cdUp();
workingDir.cdUp(); workingDir.cdUp();
// OSX Development workaround: // OSX Development workaround:
// // This folder needs then to be copied into the .app/Contents/MacOS/
// for the deploy version.
m_window.engine()->addImportPath(workingDir.path()+"/qml"); m_window.engine()->addImportPath(workingDir.path()+"/qml");
#endif #endif

View File

@ -7,177 +7,185 @@ import shutil
import argparse import argparse
import time import time
import zipfile import zipfile
from shutil import copytree
from pathlib import Path from pathlib import Path
from concurrent.futures import ThreadPoolExecutor from concurrent.futures import ThreadPoolExecutor
from datetime import datetime from datetime import datetime
SCREENPLAY_VERSION = "0.15.0-RC1" SCREENPLAY_VERSION = "0.15.0-RC1"
def zipdir(path, ziph): def zipdir(path, ziph):
# ziph is zipfile handle # ziph is zipfile handle
for root, dirs, files in os.walk(path): for root, dirs, files in os.walk(path):
for file in files: for file in files:
ziph.write(os.path.join(root, file), ziph.write(os.path.join(root, file),
os.path.relpath(os.path.join(root, file), os.path.relpath(os.path.join(root, file),
os.path.join(path, '..'))) os.path.join(path, '..')))
# Based on https://gist.github.com/l2m2/0d3146c53c767841c6ba8c4edbeb4c2c # Based on https://gist.github.com/l2m2/0d3146c53c767841c6ba8c4edbeb4c2c
def get_vs_env_dict(): def get_vs_env_dict():
vcvars = "" # We support 2019 or 2022 vcvars = "" # We support 2019 or 2022
# Hardcoded VS path # Hardcoded VS path
# check if vcvars64.bat is available. # check if vcvars64.bat is available.
msvc_2019_path = "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Auxiliary\\Build\\vcvars64.bat" msvc_2019_path = "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Auxiliary\\Build\\vcvars64.bat"
msvc_2022_path = "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\Build\\vcvars64.bat" msvc_2022_path = "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\Build\\vcvars64.bat"
if Path(msvc_2019_path).exists(): if Path(msvc_2019_path).exists():
vcvars = msvc_2019_path vcvars = msvc_2019_path
# Prefer newer MSVC and override if exists # Prefer newer MSVC and override if exists
if Path(msvc_2022_path).exists(): if Path(msvc_2022_path).exists():
vcvars = msvc_2022_path vcvars = msvc_2022_path
if not vcvars: if not vcvars:
raise RuntimeError( raise RuntimeError(
"No Visual Studio installation found, only 2019 and 2022 are supported.") "No Visual Studio installation found, only 2019 and 2022 are supported.")
print(f"\n\nLoading MSVC env variables via {vcvars}\n\n") print(f"\n\nLoading MSVC env variables via {vcvars}\n\n")
cmd = [vcvars, '&&', 'set'] cmd = [vcvars, '&&', 'set']
popen = subprocess.Popen( popen = subprocess.Popen(
cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = popen.communicate() stdout, stderr = popen.communicate()
if popen.wait() != 0: if popen.wait() != 0:
raise ValueError(stderr.decode("mbcs")) raise ValueError(stderr.decode("mbcs"))
output = stdout.decode("mbcs").split("\r\n") output = stdout.decode("mbcs").split("\r\n")
return dict((e[0].upper(), e[1]) for e in [p.rstrip().split("=", 1) for p in output] if len(e) == 2) return dict((e[0].upper(), e[1]) for e in [p.rstrip().split("=", 1) for p in output] if len(e) == 2)
def run_io_tasks_in_parallel(tasks): def run_io_tasks_in_parallel(tasks):
with ThreadPoolExecutor() as executor: with ThreadPoolExecutor() as executor:
running_tasks = [executor.submit(task) for task in tasks] running_tasks = [executor.submit(task) for task in tasks]
for running_task in running_tasks: for running_task in running_tasks:
running_task.result() running_task.result()
def clean_build_dir(build_dir): def clean_build_dir(build_dir):
if isinstance(build_dir, str): if isinstance(build_dir, str):
build_dir = Path(build_dir) build_dir = Path(build_dir)
if build_dir.exists(): if build_dir.exists():
print(f"Remove previous build folder: {build_dir}") print(f"Remove previous build folder: {build_dir}")
# ignore_errors removes also not empty folders... # ignore_errors removes also not empty folders...
shutil.rmtree(build_dir, ignore_errors=True) shutil.rmtree(build_dir, ignore_errors=True)
build_dir.mkdir(parents=True, exist_ok=True) build_dir.mkdir(parents=True, exist_ok=True)
def run(cmd, cwd=Path.cwd()): def run(cmd, cwd=Path.cwd()):
result = subprocess.run(cmd, shell=True, cwd=cwd) result = subprocess.run(cmd, shell=True, cwd=cwd)
if result.returncode != 0: if result.returncode != 0:
raise RuntimeError(f"Failed to execute {cmd}") raise RuntimeError(f"Failed to execute {cmd}")
def build( def build(
qt_version, qt_version: str,
qt_ifw_version, qt_ifw_version: str,
build_steam, build_steam: str,
build_tests, build_tests: str,
build_release, build_release: str,
create_installer, create_installer: str,
build_type, build_type: str,
sign_build, sign_build: str,
use_aqt use_aqt: bool,
build_architecture: str
): ):
# Make sure the script is always started from the same folder # Make sure the script is always started from the same folder
root_path = Path.cwd() root_path = Path.cwd()
if root_path.name == "Tools": if root_path.name == "Tools":
root_path = root_path.parent root_path = root_path.parent
print(f"Change root directory to: {root_path}") print(f"Change root directory to: {root_path}")
os.chdir(root_path) os.chdir(root_path)
aqt_path="" aqt_path = ""
if use_aqt: if use_aqt:
aqt_path = Path(f"{root_path}/../aqt/").resolve() aqt_path = Path(f"{root_path}/../aqt/").resolve()
if not Path(aqt_path).exists(): if not Path(aqt_path).exists():
print( print(
f"aqt path does not exist at {aqt_path}. Please make sure you have installed aqt.") f"aqt path does not exist at {aqt_path}. Please make sure you have installed aqt.")
exit(2) exit(2)
deploy_command = "" deploy_command: str = ""
executable_file_ending="" executable_file_ending: str = ""
qt_path = "" qt_path: str = ""
aqt_install_qt_packages = "" aqt_install_qt_packages: str = ""
aqt_install_tool_packages = "" aqt_install_tool_packages: str = ""
cmake_target_triplet = "" cmake_target_triplet: str = ""
file_endings = [".ninja_deps", ".ninja", ".ninja_log", ".lib", ".a", ".exp", file_endings = [".ninja_deps", ".ninja", ".ninja_log", ".lib", ".a", ".exp",
".manifest", ".cmake", ".cbp", "CMakeCache.txt"] ".manifest", ".cmake", ".cbp", "CMakeCache.txt"]
if platform.system() == "Windows":
cmake_target_triplet = "x64-windows"
windows_msvc = "msvc2019_64"
executable_file_ending = ".exe"
qt_path = aqt_path.joinpath(qt_version).joinpath(
windows_msvc) if use_aqt else Path(f"C:/Qt/{qt_version}/{windows_msvc}")
vs_env_dict = get_vs_env_dict()
vs_env_dict["PATH"] = vs_env_dict["PATH"] + \
";" + str(qt_path) + "\\bin"
os.environ.update(vs_env_dict)
deploy_command = "windeployqt.exe --{type} --qmldir ../../{app}/qml {app}{executable_file_ending}"
if platform.system() == "Windows": aqt_install_qt_packages = f"windows desktop {qt_version} win64_msvc2019_64 -m all"
cmake_target_triplet = "x64-windows" aqt_install_tool_packages = "windows desktop tools_ifw"
windows_msvc = "msvc2019_64"
executable_file_ending = ".exe"
qt_path = aqt_path.joinpath(qt_version).joinpath(
windows_msvc) if use_aqt else Path(f"C:/Qt/{qt_version}/{windows_msvc}")
vs_env_dict = get_vs_env_dict()
vs_env_dict["PATH"] = vs_env_dict["PATH"] + \
";" + str(qt_path) + "\\bin"
os.environ.update(vs_env_dict)
deploy_command = "windeployqt.exe --{type} --qmldir ../../{app}/qml {app}{executable_file_ending}"
aqt_install_qt_packages = f"windows desktop {qt_version} win64_msvc2019_64 -m all" elif platform.system() == "Darwin":
aqt_install_tool_packages = "windows desktop tools_ifw" if(build_architecture == "arm64"):
cmake_target_triplet = "arm64-osx"
else:
cmake_target_triplet = "x64-osx"
elif platform.system() == "Darwin": qt_path = aqt_path.joinpath(
if(platform.processor() == "arm"): f"{qt_version}/macos") if use_aqt else Path(f"~/Qt/{qt_version}/macos")
cmake_target_triplet = "arm64-osx" deploy_command = "{prefix_path}/bin/macdeployqt {app}.app -qmldir=../../{app}/qml -executable={app}.app/Contents/MacOS/{app}"
else:
cmake_target_triplet = "x64-osx"
qt_path = aqt_path.joinpath( aqt_install_qt_packages = f"mac desktop {qt_version} clang_64 -m all"
f"{qt_version}/macos") if use_aqt else Path(f"~/Qt/{qt_version}/macos") aqt_install_tool_packages = "mac desktop tools_ifw"
deploy_command = "{prefix_path}/bin/macdeployqt {app}.app -qmldir=../../{app}/qml -executable={app}.app/Contents/MacOS/{app}"
aqt_install_qt_packages = f"mac desktop {qt_version} clang_64 -m all" elif platform.system() == "Linux":
aqt_install_tool_packages = "mac desktop tools_ifw" cmake_target_triplet = "x64-linux"
qt_path = aqt_path.joinpath(
f"{qt_version}/gcc_64") if use_aqt else Path(f"~/Qt/{qt_version}/gcc_64")
aqt_install_qt_packages = f"linux desktop {qt_version} gcc_64 -m all"
aqt_install_tool_packages = "linux desktop tools_ifw"
if shutil.which("cqtdeployer"):
deploy_command = "cqtdeployer -qmlDir ../../{app}/qml -bin {app}"
else:
print("cqtdeployer not available, build may be incomplete and incompatible with some distro (typically Ubuntu)")
home_path = str(Path.home())
qt_path = aqt_path.joinpath(
f"{qt_version}/gcc_64") if use_aqt else Path(f"{home_path}/Qt/{qt_version}/gcc_64")
else:
raise NotImplementedError(
"Unsupported platform, ScreenPlay only supports Windows, macOS and Linux.")
elif platform.system() == "Linux": # Default to QtMaintainance installation.
cmake_target_triplet = "x64-linux" if use_aqt:
qt_path = aqt_path.joinpath( print(f"qt_path: {qt_path}.")
f"{qt_version}/gcc_64") if use_aqt else Path(f"~/Qt/{qt_version}/gcc_64") if not Path(aqt_path).exists():
aqt_install_qt_packages = f"linux desktop {qt_version} gcc_64 -m all" print(
aqt_install_tool_packages = "linux desktop tools_ifw" f"aqt path does not exist at {aqt_path}. Installing now into...")
if shutil.which("cqtdeployer"): run(f"aqt install-qt -O ../aqt {aqt_install_qt_packages}", cwd=root_path)
deploy_command = "cqtdeployer -qmlDir ../../{app}/qml -bin {app}" run(
else: f"aqt install-tool -O ../aqt {aqt_install_tool_packages}", cwd=root_path)
print("cqtdeployer not available, build may be incomplete and incompatible with some distro (typically Ubuntu)")
home_path = str(Path.home())
qt_path = aqt_path.joinpath(
f"{qt_version}/gcc_64") if use_aqt else Path(f"{home_path}/Qt/{qt_version}/gcc_64")
else:
raise NotImplementedError(
"Unsupported platform, ScreenPlay only supports Windows, macOS and Linux.")
# Prepare
cmake_toolchain_file = f"'{root_path}/../ScreenPlay-vcpkg/scripts/buildsystems/vcpkg.cmake'"
ifw_root_path = f"{qt_path}\\Tools\\QtInstallerFramework\\{qt_ifw_version}"
print(f"cmake_toolchain_file: {cmake_toolchain_file}")
print(
f"Starting build with type {build_type}. Qt Version: {qt_version}. Root path: {root_path}")
# Default to QtMaintainance installation. CMAKE_OSX_ARCHITECTURES: str = ""
if use_aqt: # The entire parameter should be optional. We need this to explicity build
print(f"qt_path: {qt_path}.") # x84 and arm version seperat, only because we cannot compile two at once with vcpkg
if not Path(aqt_path).exists(): if build_architecture:
print( CMAKE_OSX_ARCHITECTURES = f"-DCMAKE_OSX_ARCHITECTURES={build_architecture}"
f"aqt path does not exist at {aqt_path}. Installing now into...")
run(f"aqt install-qt -O ../aqt {aqt_install_qt_packages}", cwd=root_path)
run(
f"aqt install-tool -O ../aqt {aqt_install_tool_packages}", cwd=root_path)
# Prepare cmake_configure_command = f'cmake ../ \
cmake_toolchain_file = f"'{root_path}/../ScreenPlay-vcpkg/scripts/buildsystems/vcpkg.cmake'" {CMAKE_OSX_ARCHITECTURES} \
ifw_root_path=f"{qt_path}\\Tools\\QtInstallerFramework\\{qt_ifw_version}"
print(f"cmake_toolchain_file: {cmake_toolchain_file}")
print(
f"Starting build with type {build_type}. Qt Version: {qt_version}. Root path: {root_path}")
cmake_configure_command = f'cmake ../ \
-DCMAKE_PREFIX_PATH={qt_path} \ -DCMAKE_PREFIX_PATH={qt_path} \
-DCMAKE_BUILD_TYPE={build_type} \ -DCMAKE_BUILD_TYPE={build_type} \
-DVCPKG_TARGET_TRIPLET={cmake_target_triplet} \ -DVCPKG_TARGET_TRIPLET={cmake_target_triplet} \
@ -190,221 +198,226 @@ def build(
-G "CodeBlocks - Ninja" \ -G "CodeBlocks - Ninja" \
-B.' -B.'
build_folder = root_path.joinpath( build_folder = root_path.joinpath(
f"build-{cmake_target_triplet}-{build_type}") f"build-{cmake_target_triplet}-{build_type}")
clean_build_dir(build_folder) clean_build_dir(build_folder)
# Build # Build
start_time = time.time() start_time = time.time()
print(cmake_configure_command) print(cmake_configure_command)
run(cmake_configure_command, cwd=build_folder) run(cmake_configure_command, cwd=build_folder)
run("cmake --build . --target all", cwd=build_folder) run("cmake --build . --target all", cwd=build_folder)
bin_dir = build_folder.joinpath("bin") bin_dir = build_folder.joinpath("bin")
# Deploy dependencies # Deploy dependencies
if deploy_command: # Only deploy if we have the dependencies if deploy_command: # Only deploy if we have the dependencies
print("Executing deploy commands...") print("Executing deploy commands...")
run(deploy_command.format( run(deploy_command.format(
type=build_type, type=build_type,
prefix_path=qt_path, prefix_path=qt_path,
app="ScreenPlay", app="ScreenPlay",
executable_file_ending=executable_file_ending), cwd=bin_dir) executable_file_ending=executable_file_ending), cwd=bin_dir)
run(deploy_command.format( run(deploy_command.format(
type=build_type, type=build_type,
prefix_path=qt_path, prefix_path=qt_path,
app="ScreenPlayWidget", app="ScreenPlayWidget",
executable_file_ending=executable_file_ending), cwd=bin_dir) executable_file_ending=executable_file_ending), cwd=bin_dir)
run(deploy_command.format( run(deploy_command.format(
type=build_type, type=build_type,
prefix_path=qt_path, prefix_path=qt_path,
app="ScreenPlayWallpaper", app="ScreenPlayWallpaper",
executable_file_ending=executable_file_ending), cwd=bin_dir) executable_file_ending=executable_file_ending), cwd=bin_dir)
else: else:
# just copy the folders and be done with it # just copy the folders and be done with it
if platform.system() == "Linux": if platform.system() == "Linux":
# Copy all .so files from the qt_path lib folder into bin_dir # Copy all .so files from the qt_path lib folder into bin_dir
qt_lib_path = qt_path qt_lib_path = qt_path
for file in qt_lib_path.joinpath("lib").glob("*.so"): for file in qt_lib_path.joinpath("lib").glob("*.so"):
shutil.copy(str(file), str(bin_dir)) shutil.copy(str(file), str(bin_dir))
# Copy qt_qml_path folder content into bin_dir # Copy qt_qml_path folder content into bin_dir
qt_qml_path = qt_path qt_qml_path = qt_path
for folder in qt_qml_path.joinpath("qml").iterdir(): for folder in qt_qml_path.joinpath("qml").iterdir():
if not folder.is_file(): if not folder.is_file():
shutil.copytree(str(folder), str( shutil.copytree(str(folder), str(
bin_dir.joinpath(folder.name))) bin_dir.joinpath(folder.name)))
print("Copied %s" % folder) print("Copied %s" % folder)
# Copy all plugin folder from qt_path plugins subfolder into bin_dir # Copy all plugin folder from qt_path plugins subfolder into bin_dir
qt_plugins_path = qt_path qt_plugins_path = qt_path
for folder in qt_path.joinpath("plugins").iterdir(): for folder in qt_path.joinpath("plugins").iterdir():
if not folder.is_file(): if not folder.is_file():
shutil.copytree(str(folder), str( shutil.copytree(str(folder), str(
bin_dir.joinpath(folder.name))) bin_dir.joinpath(folder.name)))
print("Copied %s" % folder) print("Copied %s" % folder)
# Copy all folder from qt_path translation files into bin_dir translation folder # Copy all folder from qt_path translation files into bin_dir translation folder
qt_translations_path = qt_path qt_translations_path = qt_path
for folder in qt_translations_path.joinpath("translations").iterdir(): for folder in qt_translations_path.joinpath("translations").iterdir():
if not folder.is_file(): if not folder.is_file():
shutil.copytree(str(folder), str( shutil.copytree(str(folder), str(
bin_dir.joinpath("translations").joinpath(folder.name))) bin_dir.joinpath("translations").joinpath(folder.name)))
print("Copied %s" % folder) print("Copied %s" % folder)
# Copy all filesfrom qt_path resources folder into bin_dir folder # Copy all filesfrom qt_path resources folder into bin_dir folder
qt_resources_path = qt_path qt_resources_path = qt_path
for file in qt_path.joinpath("resources").glob("*"): for file in qt_path.joinpath("resources").glob("*"):
shutil.copy(str(file), str(bin_dir)) shutil.copy(str(file), str(bin_dir))
print("Copied %s" % file) print("Copied %s" % file)
else: else:
print("Not executing deploy commands due to missing dependencies.") print("Not executing deploy commands due to missing dependencies.")
# Post-build # Post-build
if platform.system() == "Darwin" and sign_build: if platform.system() == "Darwin" and sign_build == "ON":
run("codesign --deep -f -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --timestamp --options \"runtime\" -f --entitlements \"../../ScreenPlay/entitlements.plist\" --deep \"ScreenPlay.app/\"", cwd=bin_dir) run("codesign --deep -f -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --timestamp --options \"runtime\" -f --entitlements \"../../ScreenPlay/entitlements.plist\" --deep \"ScreenPlay.app/\"", cwd=bin_dir)
run("codesign --deep -f -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --timestamp --options \"runtime\" -f --deep \"ScreenPlayWallpaper.app/\"", cwd=bin_dir) run("codesign --deep -f -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --timestamp --options \"runtime\" -f --deep \"ScreenPlayWallpaper.app/\"", cwd=bin_dir)
run("codesign --deep -f -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --timestamp --options \"runtime\" -f --deep \"ScreenPlayWidget.app/\"", cwd=bin_dir) run("codesign --deep -f -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --timestamp --options \"runtime\" -f --deep \"ScreenPlayWidget.app/\"", cwd=bin_dir)
run("codesign --verify --verbose=4 \"ScreenPlay.app/\"", cwd=bin_dir) run("codesign --verify --verbose=4 \"ScreenPlay.app/\"", cwd=bin_dir)
run("codesign --verify --verbose=4 \"ScreenPlayWallpaper.app/\"", cwd=bin_dir) run("codesign --verify --verbose=4 \"ScreenPlayWallpaper.app/\"", cwd=bin_dir)
run("codesign --verify --verbose=4 \"ScreenPlayWidget.app/\"", cwd=bin_dir) run("codesign --verify --verbose=4 \"ScreenPlayWidget.app/\"", cwd=bin_dir)
run("xcnotary notarize ScreenPlay.app -d kelteseth@gmail.com -k ScreenPlay", cwd=bin_dir), run("xcnotary notarize ScreenPlay.app -d kelteseth@gmail.com -k ScreenPlay", cwd=bin_dir),
run("xcnotary notarize ScreenPlayWallpaper.app -d kelteseth@gmail.com -k ScreenPlay", cwd=bin_dir), run("xcnotary notarize ScreenPlayWallpaper.app -d kelteseth@gmail.com -k ScreenPlay", cwd=bin_dir),
run("xcnotary notarize ScreenPlayWidget.app -d kelteseth@gmail.com -k ScreenPlay", cwd=bin_dir) run("xcnotary notarize ScreenPlayWidget.app -d kelteseth@gmail.com -k ScreenPlay", cwd=bin_dir)
run("spctl --assess --verbose \"ScreenPlay.app/\"", cwd=bin_dir) run("spctl --assess --verbose \"ScreenPlay.app/\"", cwd=bin_dir)
run("spctl --assess --verbose \"ScreenPlayWallpaper.app/\"", cwd=bin_dir) run("spctl --assess --verbose \"ScreenPlayWallpaper.app/\"", cwd=bin_dir)
run("spctl --assess --verbose \"ScreenPlayWidget.app/\"", cwd=bin_dir) run("spctl --assess --verbose \"ScreenPlayWidget.app/\"", cwd=bin_dir)
# Some dlls like openssl do no longer get copied automatically. # Copy qml dir into all .app/Contents/MacOS/
# Lets just copy all of them into bin. if platform.system() == "Darwin":
if platform.system() == "Windows": copytree(Path.joinpath(bin_dir, "qml"), Path.joinpath(bin_dir, "ScreenPlay.app/Contents/MacOS/qml"))
vcpkg_bin_path = Path( copytree(Path.joinpath(bin_dir, "qml"), Path.joinpath(bin_dir, "ScreenPlayWallpaper.app/Contents/MacOS/qml"))
f"{root_path}/../ScreenPlay-vcpkg/installed/x64-windows/bin").resolve() copytree(Path.joinpath(bin_dir, "qml"), Path.joinpath(bin_dir, "ScreenPlayWidget.app/Contents/MacOS/qml"))
print(vcpkg_bin_path)
for file in vcpkg_bin_path.iterdir():
if file.suffix == ".dll" and file.is_file():
print(file, bin_dir)
shutil.copy2(file, bin_dir)
if not platform.system() == "Darwin":
for file_ending in file_endings:
for file in bin_dir.rglob("*" + file_ending):
if file.is_file():
print("Remove: %s" % file.resolve())
file.unlink()
if create_installer == "ON": # Some dlls like openssl do no longer get copied automatically.
os.chdir(build_folder) # Lets just copy all of them into bin.
print("Running cpack at: ", os.getcwd()) if platform.system() == "Windows":
run("cpack", cwd=build_folder) vcpkg_bin_path = Path(
# We also need to sign the installer in osx: f"{root_path}/../ScreenPlay-vcpkg/installed/x64-windows/bin").resolve()
if platform.system() == "Darwin" and sign_build: print(vcpkg_bin_path)
run("codesign --deep -f -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --timestamp --options \"runtime\" -f --deep \"ScreenPlay-Installer.dmg/ScreenPlay-Installer.app/Contents/MacOS/ScreenPlay-Installer\"", cwd=build_folder) for file in vcpkg_bin_path.iterdir():
run("codesign --verify --verbose=4 \"ScreenPlay-Installer.dmg/ScreenPlay-Installer.app/Contents/MacOS/ScreenPlay-Installer\"", cwd=build_folder) if file.suffix == ".dll" and file.is_file():
run("xcnotary notarize ScreenPlay-Installer.dmg/ScreenPlay-Installer.app -d kelteseth@gmail.com -k ScreenPlay", cwd=build_folder) print(file, bin_dir)
run("spctl --assess --verbose \"ScreenPlay-Installer.dmg/ScreenPlay-Installer.app/\"", cwd=build_folder) shutil.copy2(file, bin_dir)
if not platform.system() == "Darwin":
for file_ending in file_endings:
for file in bin_dir.rglob("*" + file_ending):
if file.is_file():
print("Remove: %s" % file.resolve())
file.unlink()
run("codesign --deep -f -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --timestamp --options \"runtime\" -f --deep \"ScreenPlay-Installer.dmg/\"", cwd=build_folder) if create_installer == "ON":
run("codesign --verify --verbose=4 \"ScreenPlay-Installer.dmg/\"", os.chdir(build_folder)
cwd=build_folder) print("Running cpack at: ", os.getcwd())
run("xcnotary notarize ScreenPlay-Installer.dmg -d kelteseth@gmail.com -k ScreenPlay", cwd=build_folder) run("cpack", cwd=build_folder)
run("spctl --assess --verbose \"ScreenPlay-Installer.dmg/\"", # We also need to sign the installer in osx:
cwd=build_folder) if platform.system() == "Darwin" and sign_build == "ON":
run("codesign --deep -f -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --timestamp --options \"runtime\" -f --deep \"ScreenPlay-Installer.dmg/ScreenPlay-Installer.app/Contents/MacOS/ScreenPlay-Installer\"", cwd=build_folder)
run("codesign --verify --verbose=4 \"ScreenPlay-Installer.dmg/ScreenPlay-Installer.app/Contents/MacOS/ScreenPlay-Installer\"", cwd=build_folder)
run("xcnotary notarize ScreenPlay-Installer.dmg/ScreenPlay-Installer.app -d kelteseth@gmail.com -k ScreenPlay", cwd=build_folder)
run("spctl --assess --verbose \"ScreenPlay-Installer.dmg/ScreenPlay-Installer.app/\"", cwd=build_folder)
# Create a zip file for scoop run("codesign --deep -f -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --timestamp --options \"runtime\" -f --deep \"ScreenPlay-Installer.dmg/\"", cwd=build_folder)
if platform.system() == "Windows": run("codesign --verify --verbose=4 \"ScreenPlay-Installer.dmg/\"",
zipName = f"ScreenPlay-{SCREENPLAY_VERSION}-{cmake_target_triplet}-{build_type}.zip" cwd=build_folder)
print(f"Creating scoop zip file: \n{bin_dir} \n{zipName}") run("xcnotary notarize ScreenPlay-Installer.dmg -d kelteseth@gmail.com -k ScreenPlay", cwd=build_folder)
os.chdir(build_folder) run("spctl --assess --verbose \"ScreenPlay-Installer.dmg/\"",
with zipfile.ZipFile(zipName, 'w', zipfile.ZIP_DEFLATED) as zipf: cwd=build_folder)
zipdir(bin_dir, zipf)
print("Time taken: {}s".format(time.time() - start_time)) # Create a zip file for scoop
if platform.system() == "Windows":
zipName = f"ScreenPlay-{SCREENPLAY_VERSION}-{cmake_target_triplet}-{build_type}.zip"
print(f"Creating scoop zip file: \n{bin_dir} \n{zipName}")
os.chdir(build_folder)
with zipfile.ZipFile(zipName, 'w', zipfile.ZIP_DEFLATED) as zipf:
zipdir(bin_dir, zipf)
print("Time taken: {}s".format(time.time() - start_time))
if __name__ == "__main__": if __name__ == "__main__":
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description='Build and Package ScreenPlay') description='Build and Package ScreenPlay')
parser.add_argument('-qt-version', action="store", dest="qt_version_overwrite", parser.add_argument('-qt-version', action="store", dest="qt_version_overwrite",
help="Overwrites the default Qt version") help="Overwrites the default Qt version")
parser.add_argument('-qt-installer-version', action="store", dest="qt_installer_version_overwrite", parser.add_argument('-qt-installer-version', action="store", dest="qt_installer_version_overwrite",
help="Overwrites the default Qt installer framework version") help="Overwrites the default Qt installer framework version")
parser.add_argument('-type', action="store", dest="build_type", parser.add_argument('-type', action="store", dest="build_type",
help="Build type. This is either debug or release.") help="Build type. This is either debug or release.")
parser.add_argument('-use-aqt', action="store_true", dest="use_aqt", parser.add_argument('-use-aqt', action="store_true", dest="use_aqt",
help="Absolute qt path. If not set the default path is used\Windows: C:\Qt\nLinux & macOS:~/Qt/.") help="Absolute qt path. If not set the default path is used\Windows: C:\Qt\nLinux & macOS:~/Qt/.")
parser.add_argument('-sign', action="store_true", dest="sign_build", parser.add_argument('-sign', action="store_true", dest="sign_build",
help="Enable if you want to sign the apps. This is macOS only for now.") help="Enable if you want to sign the apps. This is macOS only for now.")
parser.add_argument('-steam', action="store_true", dest="build_steam", parser.add_argument('-steam', action="store_true", dest="build_steam",
help="Enable if you want to build the Steam workshop plugin.") help="Enable if you want to build the Steam workshop plugin.")
parser.add_argument('-tests', action="store_true", dest="build_tests", parser.add_argument('-tests', action="store_true", dest="build_tests",
help="Build tests.") help="Build tests.")
parser.add_argument('-installer', action="store_true", dest="create_installer", parser.add_argument('-installer', action="store_true", dest="create_installer",
help="Create a installer.") help="Create a installer.")
parser.add_argument('-release', action="store_true", dest="build_release", parser.add_argument('-release', action="store_true", dest="build_release",
help="Create a release version of ScreenPlay for sharing with the world. This is not about debug/release build, but the c++ define SCREENPLAY_RELEASE.") help="Create a release version of ScreenPlay for sharing with the world. This is not about debug/release build, but the c++ define SCREENPLAY_RELEASE.")
args = parser.parse_args() parser.add_argument('-architecture', action="store", dest="build_architecture",
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()
qt_version = "6.3.0" qt_version = "6.3.0"
qt_ifw_version = "4.4" # Not yet used. qt_ifw_version = "4.4" # Not yet used.
qt_version_overwrite = "" qt_version_overwrite = ""
use_aqt = False use_aqt = False
if args.qt_version_overwrite: if args.qt_version_overwrite:
qt_version = args.qt_version_overwrite qt_version = args.qt_version_overwrite
print("Using Qt version {qt_version}") print("Using Qt version {qt_version}")
if args.qt_installer_version_overwrite: if args.qt_installer_version_overwrite:
qt_ifw_version = args.qt_installer_version_overwrite qt_ifw_version = args.qt_installer_version_overwrite
print("Using Qt installer framework version {qt_ifw_version}") print("Using Qt installer framework version {qt_ifw_version}")
if args.build_steam and not args.build_release: if not args.build_type:
print("Steam Builds must have release option enabled via -release") print("Build type argument is missing (release, debug). E.g: python build.py -type release -steam")
exit(4) print(
f"Defaulting to Qt version: {qt_version}. This can be overwritten via -qt-version 6.5.0")
exit(1)
build_type = args.build_type
if not args.build_type: build_steam = "OFF"
print("Build type argument is missing (release, debug). E.g: python build.py -type release -steam") if args.build_steam:
print( build_steam = "ON"
f"Defaulting to Qt version: {qt_version}. This can be overwritten via -qt-version 6.5.0")
exit(1)
build_type = args.build_type
build_steam = "OFF" build_tests = "OFF"
if args.build_steam: if args.build_tests:
build_steam = "ON" build_tests = "ON"
build_tests = "OFF" build_release = "OFF"
if args.build_tests: if args.build_release:
build_tests = "ON" build_release = "ON"
build_release = "OFF" create_installer = "OFF"
if args.build_release: if args.create_installer:
build_release = "ON" create_installer = "ON"
create_installer = "OFF" sign_build = "OFF"
if args.create_installer: if args.sign_build:
create_installer = "ON" sign_build = "ON"
sign_build ="OFF"
if args.sign_build:
sign_build = "ON"
build( build(
qt_version, qt_version,
qt_ifw_version, qt_ifw_version,
build_steam, build_steam,
build_tests, build_tests,
build_release, build_release,
create_installer, create_installer,
build_type, build_type,
sign_build, sign_build,
args.use_aqt args.use_aqt,
) args.build_architecture
)