1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-25 04:02:50 +01:00

Change macos building fat universal binary as default

For this we now use a custom triplet. This has some drawbacks like openssl
does not work with this config. Luckily we can
use openssl that is provided by Qt. On macOS
they use Secure Transport.
This commit is contained in:
Elias Steurer 2023-06-02 09:51:56 +02:00
parent 9b8b8e0374
commit 287730e9c7
11 changed files with 28 additions and 86 deletions

View File

@ -94,7 +94,7 @@ steam_osx:
artifacts:
expire_in: "2 weeks"
paths:
- build-universal-osx-release/bin/
- build-64-osx-universal-release/bin/
formatting:
stage: check

3
.vscode/tasks.json vendored
View File

@ -104,8 +104,7 @@
"build.py",
"-type=release",
"-deploy-version",
"-steam",
"-architecture=arm64"
"-steam"
]
},
"args": [

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.26.0)
cmake_minimum_required(VERSION 3.23.0)
project(
ScreenPlay
@ -13,20 +13,8 @@ if(WIN32)
elseif(UNIX AND NOT APPLE)
set(VCPKG_ARCH "x64-linux")
elseif(APPLE)
# CMAKE_HOST_SYSTEM_PROCESSOR returns the value of `uname -p` on host. Universal builds are not available with vcpkg, but the prebuild
# Qt binaries are. CMake also handles https://github.com/microsoft/vcpkg/discussions/19454 This means we must compile twice and then
# merge the binaries with lipo
if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL amd64)
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}")
set(VCPKG_ARCH "64-osx-universal") # Our own triplet for universal binaries
set(VCPKG_TARGET_ARCHITECTURE "arm64;x86_64")
endif()
# This sets cmake to compile all dlls into the main directory
@ -37,6 +25,7 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH})
set(THIRD_PARTY_PATH "${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/")
option(OSX_BUNDLE "Enable distribution macOS bundle" OFF)
set(CMAKE_OSX_DEPLOYMENT_TARGET "13.0")
# This is needed for OSX: Because we bundle ScreenPlay and ScreenPlayWallpaper into .app they both need other QML dependencies like
# ScreenPlayUtil. The fastest way is to use a shared QML module path for development and add this path to the qml engines import pah. For

View File

@ -2,7 +2,7 @@
"version": 5,
"cmakeMinimumRequired": {
"major": 3,
"minor": 26,
"minor": 23,
"patch": 0
},
"configurePresets": [
@ -78,7 +78,7 @@
"displayName": "ScreenPlay 64bit Debug Linux",
"description": "Linux only!",
"generator": "Ninja",
"binaryDir": "${sourceDir}/../build_ScreenPlay_Qt_6.4.2_GCC_Debug",
"binaryDir": "${sourceDir}/../build_ScreenPlay_Qt_6.5.1_GCC_Debug",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
@ -95,7 +95,7 @@
"CMAKE_CXX_COMPILER": "g++",
"CMAKE_C_COMPILER": "gcc",
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_PREFIX_PATH": "$env{qt_path}/6.4.2/gcc_64",
"CMAKE_PREFIX_PATH": "$env{qt_path}/6.5.1/gcc_64",
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/../vcpkg/scripts/buildsystems/vcpkg.cmake",
"VCPKG_TARGET_TRIPLET": "x64-linux"
}
@ -104,7 +104,7 @@
"name": "linux-relwithdebinfo",
"displayName": "ScreenPlay 64bit RelWithDebInfo Linux",
"inherits":"linux-debug",
"binaryDir": "${sourceDir}/../build_ScreenPlay_Qt_6.4.2_GCC_RelWithDebInfo",
"binaryDir": "${sourceDir}/../build_ScreenPlay_Qt_6.5.1_GCC_RelWithDebInfo",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
@ -123,11 +123,9 @@
"environment" : {
"qt_path": "${sourceDir}/../aqt"
},
"architecture": {
"value": "x64",
"strategy": "external"
},
"cacheVariables": {
"VCPKG_OSX_ARCHITECTURES":"arm64;x86_64",
"VCPKG_TARGET_TRIPLET": "64-osx-universal",
"CMAKE_CXX_COMPILER": "clang++",
"CMAKE_C_COMPILER": "clang",
"CMAKE_BUILD_TYPE": "Debug",

View File

@ -244,7 +244,6 @@ set(RESOURCES
# Needed on macos
find_package(Threads REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(LibArchive REQUIRED)
# Make sentry win only for now because it is constantly buggy on osx
@ -252,6 +251,7 @@ if(WIN32)
# CURL must be included before sentry because sentry needs the module and does not include it itself on macos...
find_package(CURL CONFIG REQUIRED)
find_package(sentry CONFIG REQUIRED)
find_package(OpenSSL CONFIG REQUIRED)
endif()
find_package(

View File

@ -9,9 +9,7 @@ import time
import zipfile
import defines
from typing import Tuple
from shutil import copytree
from pathlib import Path
from macos_lipo import run_lipo, check_fat_binary
import macos_sign
from util import sha256, cd_repo_root_path,repo_root_path, zipdir, run, get_vs_env_dict
from sys import stdout
@ -82,11 +80,6 @@ def execute(
# Make sure the script is always started from the same folder
build_config.root_path = cd_repo_root_path()
if platform.system() == "Darwin":
build_config.build_architecture = "x64"
build_config.cmake_target_triplet = "x64-osx"
build_config.cmake_osx_architectures = "-DCMAKE_OSX_ARCHITECTURES=x86_64"
# Sets all platform spesific paths, arguments etc.
[build_config, build_result] = setup(build_config)
@ -102,35 +95,7 @@ def execute(
step_time = time.time()
build_result = build(build_config, build_result)
build_duration = time.time() - step_time
print(f"⏱️ build_duration (for {build_config.build_architecture}): {build_duration}s")
if platform.system() == "Darwin":
# Make sure the script is always started from the same folder
build_config.root_path = cd_repo_root_path()
# Swap the architecture for the second build
build_config.build_architecture = "arm64"
build_config.cmake_target_triplet = "arm64-osx"
build_config.cmake_osx_architectures = "-DCMAKE_OSX_ARCHITECTURES=arm64"
# Sets all platform spesific paths, arguments etc.
[build_config, build_result] = setup(build_config)
build_result.build = Path(build_config.build_folder)
build_result.bin = Path(build_config.bin_dir)
# 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)
step_time = time.time()
build_result = build(build_config, build_result)
build_duration = time.time() - step_time
print(f"⏱️ Second build_duration (for {build_config.build_architecture}): {build_duration}s")
#print(f"⏱️ build_duration (for {build_config.build_architecture}): {build_duration}s")
# Copies all needed libraries and assets into the bin folder
step_time = time.time()
@ -138,7 +103,6 @@ def execute(
package_duration = time.time() - step_time
print(f"⏱️ package_duration: {package_duration}s")
# Creates a Qt InstallerFrameWork (IFW) installer
if build_config.create_installer == "ON":
step_time = time.time()
@ -176,7 +140,6 @@ def setup(build_config: BuildConfig) -> Tuple[BuildConfig, BuildResult]:
build_config.ifw_root_path = Path(f"{build_config.qt_path}/Tools/QtInstallerFramework/{build_config.qt_ifw_version}").resolve()
if platform.system() == "Windows":
build_config.cmake_osx_architectures = ""
build_config.cmake_target_triplet = "x64-windows"
build_config.executable_file_ending = ".exe"
env_dict = get_vs_env_dict()
@ -191,6 +154,7 @@ def setup(build_config: BuildConfig) -> Tuple[BuildConfig, BuildResult]:
build_config.aqt_install_tool_packages = "windows desktop tools_ifw"
elif platform.system() == "Darwin":
build_config.cmake_target_triplet = "64-osx-universal"
build_config.executable_file_ending = ".app"
# NO f string we fill it later!
#build_config.package_command = "{prefix_path}/bin/macdeployqt ScreenPlay.app -qmldir=../../{app}/qml -executable=ScreenPlay.app/Contents/MacOS/{app} -appstore-compliant -timestamp -hardened-runtime"
@ -198,7 +162,6 @@ def setup(build_config: BuildConfig) -> Tuple[BuildConfig, BuildResult]:
build_config.aqt_install_tool_packages = "mac desktop tools_ifw"
elif platform.system() == "Linux":
build_config.cmake_osx_architectures = ""
build_config.cmake_target_triplet = "x64-linux"
build_config.executable_file_ending = ""
build_config.aqt_install_qt_packages = f"linux desktop {build_config.qt_version} gcc_64 -m all"
@ -229,7 +192,6 @@ def setup(build_config: BuildConfig) -> Tuple[BuildConfig, BuildResult]:
def build(build_config: BuildConfig, build_result: BuildResult) -> BuildResult:
cmake_configure_command = f'cmake ../ \
{build_config.cmake_osx_architectures} \
-DCMAKE_PREFIX_PATH={build_config.qt_bin_path} \
-DCMAKE_BUILD_TYPE={build_config.build_type} \
-DVCPKG_TARGET_TRIPLET={build_config.cmake_target_triplet} \
@ -256,21 +218,11 @@ def build(build_config: BuildConfig, build_result: BuildResult) -> BuildResult:
def package(build_config: BuildConfig):
if platform.system() == "Darwin":
universal_build_dir = Path(os.path.join(repo_root_path(), "build-universal-osx-release"))
if universal_build_dir.exists():
print(f"Remove previous build folder: {universal_build_dir}")
# ignore_errors removes also not empty folders...
shutil.rmtree(universal_build_dir, ignore_errors=True)
# Make sure to reset to tools path
os.chdir(repo_root_path())
# Create universal (fat) binary
run_lipo()
check_fat_binary()
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 " # -sign-for-notarization=\"Developer ID Application: Elias Steurer (V887LHYKRH)\"
build_bin_dir = Path(repo_root_path()).joinpath("build-universal-osx-release/bin/")
cwd = Path(repo_root_path()).joinpath("build-universal-osx-release/bin/ScreenPlay.app/Contents/MacOS/")
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/")
qt_bin_path = Path(defines.QT_BIN_PATH).resolve()
source_path = Path(repo_root_path()).resolve()
@ -279,7 +231,6 @@ def package(build_config: BuildConfig):
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)
if(build_config.sign_osx):
build_config.bin_dir = os.path.join(repo_root_path(),'build-universal-osx-release/bin/')
print(f"Sign binary at: {build_config.bin_dir}")
macos_sign.sign(build_config=build_config)
@ -457,6 +408,9 @@ if __name__ == "__main__":
if args.use_aqt:
use_aqt = True
if not args.build_architecture:
build_architecture = ""
build_config = BuildConfig()
build_config.qt_version = qt_version
build_config.qt_ifw_version = qt_ifw_version
@ -466,7 +420,7 @@ if __name__ == "__main__":
build_config.create_installer = create_installer
build_config.build_type = build_type
build_config.screenplay_version = screenplay_version
build_config.build_architecture = args.build_architecture
build_config.build_architecture = build_architecture
build_config.sign_osx = args.sign_osx
execute(build_config)

View File

@ -24,6 +24,7 @@ QT_VERSION = "6.5.1"
QT_BIN_PATH = QT_PATH.joinpath(f"{QT_VERSION}/{QT_PLATFORM}/bin")
QT_TOOLS_PATH = QT_PATH.joinpath("Tools/")
QT_IFW_VERSION = "4.5"
VCPKG_VERSION = "1cc9525" # Master 15.02.2023
# 02.06.2023 https://gitlab.com/kelteseth/screenplay-vcpkg :
VCPKG_VERSION = "e9e5a6fa2e23bc4928fd6281f0cbd66f58d89209"
PYTHON_EXECUTABLE = "python" if sys.platform == "win32" else "python3"
FFMPEG_VERSION = "5.0.1"

View File

@ -50,7 +50,7 @@ def check_fat_binary():
print(f"Change root directory to: {root_path}")
os.chdir(root_path)
dir = 'build-universal-osx-release/bin/'
dir = 'build-osx-release/bin/'
files = listfiles(str(Path.joinpath(root_path, dir)))
for file in files:

View File

@ -58,6 +58,8 @@ def download(aqt_path: Path, qt_platform: Path):
# Tools can only be installed one at the time:
# see: python -m aqt list-tool windows desktop
tools = ["tools_ifw", "tools_qtcreator", "tools_ninja" ,"tools_cmake"]
if system() == "Windows":
tools += "tools_opensslv3_x64"
for tool in tools:
execute(f"{defines.PYTHON_EXECUTABLE} -m aqt install-tool -O {aqt_path} {os} desktop {tool}")
@ -103,7 +105,6 @@ def main():
project_source_parent_path = root_path.joinpath("../").resolve()
vcpkg_path = project_source_parent_path.joinpath("vcpkg").resolve()
vcpkg_packages_list = [
"openssl",
"curl",
"cpp-httplib",
"libarchive"
@ -128,7 +129,7 @@ def main():
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)
vcpkg_triplet = ["x64-osx", "arm64-osx"]
vcpkg_triplet = ["64-osx-universal"]
elif system() == "Linux":
vcpkg_command = "./vcpkg"
#vcpkg_packages_list.append("infoware[opengl]")
@ -141,7 +142,7 @@ def main():
raise NotImplementedError("Unknown system: {}".format(system()))
print(f"Clone into {vcpkg_path}")
execute("git clone https://github.com/microsoft/vcpkg.git vcpkg", project_source_parent_path, True)
execute("git clone https://gitlab.com/kelteseth/screenplay-vcpkg vcpkg", project_source_parent_path, True)
execute("git fetch", vcpkg_path)
execute(f"git checkout {defines.VCPKG_VERSION}", vcpkg_path)