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

Refactor build &ci script to use aqt

Refactor gitlab-ci to inherit base
Add defines.py that stores variables like versions
Bump Qt version to 6.3.2
This commit is contained in:
Elias Steurer 2022-10-10 11:35:41 +02:00
parent 09ba827c52
commit bda6716d3a
8 changed files with 143 additions and 99 deletions

View File

@ -2,23 +2,26 @@ stages:
- build - build
- check - check
variables: .base_windows_build:
GIT_STRATEGY: clone before_script:
QT_VERSION: 6.3.1 - python -m pip install -U pip wheel
PYTHON_VERSION: 3.10.1 - python -m pip install -r Tools/requirements.txt
- python Tools/setup.py
.base_unix_build:
before_script:
- pip3 install -U pip
- pip3 install -r Tools/requirements.txt
- python3 Tools/setup.py
standalone:windows: standalone:windows:
stage: build stage: build
extends:
- .base_windows_build
tags: tags:
- windows10 - windows10
script: script:
- python -m pip install -U pip wheel - python Tools/build.py -type release -use-aqt -installer -deploy-version
- python -m pip install -U aqtinstall
- python -m aqt install-qt -O ../aqt windows desktop $QT_VERSION win64_msvc2019_64 -m all
- python -m aqt install-tool -O ../aqt windows desktop tools_ifw
- cd Tools
- python setup.py
- python build.py -type release -use-aqt -installer -deploy
artifacts: artifacts:
expire_in: "2 weeks" expire_in: "2 weeks"
paths: paths:
@ -27,18 +30,14 @@ standalone:windows:
standalone:osx: standalone:osx:
stage: build stage: build
extends:
- .base_unix_build
tags: tags:
- osx - osx
script: script:
- pip3 install -U pip - python3 Tools/build.py -type release -use-aqt -deploy-version -architecture x64
- pip3 install aqtinstall - python3 Tools/build.py -type release -use-aqt -deploy-version -architecture arm64
- python3 -m aqt install-qt -O ../aqt mac desktop $QT_VERSION clang_64 -m all - python3 Tools/macos_lipo.py
- python3 -m aqt install-tool -O ../aqt mac desktop tools_ifw
- cd Tools
- python3 setup.py
- python3 build.py -type release -use-aqt -deploy -architecture x64
- python3 build.py -type release -use-aqt -deploy -architecture arm64
- python3 macos_lipo.py
artifacts: artifacts:
expire_in: "2 weeks" expire_in: "2 weeks"
paths: paths:
@ -46,16 +45,12 @@ standalone:osx:
steam:windows: steam:windows:
stage: build stage: build
extends:
- .base_windows_build
tags: tags:
- windows10 - windows10
script: script:
- python -m pip install -U pip wheel - python Tools/build.py -type release -steam -use-aqt -deploy-version
- python -m pip install -U aqtinstall
- python -m aqt install-qt -O ../aqt windows desktop $QT_VERSION win64_msvc2019_64 -m all
- python -m aqt install-tool -O ../aqt windows desktop tools_ifw
- cd Tools
- python setup.py
- python build.py -type release -steam -use-aqt -deploy
artifacts: artifacts:
expire_in: "2 weeks" expire_in: "2 weeks"
paths: paths:
@ -63,18 +58,14 @@ steam:windows:
steam:osx: steam:osx:
stage: build stage: build
extends:
- .base_unix_build
tags: tags:
- osx - osx
script: script:
- pip3 install -U pip - python3 Tools/build.py -type release -steam -use-aqt -deploy-version -architecture x64
- pip3 install aqtinstall - python3 Tools/build.py -type release -steam -use-aqt -deploy-version -architecture arm64
- python3 -m aqt install-qt -O ../aqt mac desktop $QT_VERSION clang_64 -m all - python3 Tools/macos_lipo.py
- python3 -m aqt install-tool -O ../aqt mac desktop tools_ifw
- cd Tools
- python3 setup.py
- python3 build.py -type release -steam -use-aqt -deploy -architecture x64
- python3 build.py -type release -steam -use-aqt -deploy -architecture arm64
- python3 macos_lipo.py
artifacts: artifacts:
expire_in: "2 weeks" expire_in: "2 weeks"
paths: paths:

View File

@ -1,6 +1,9 @@
#include "ScreenPlay/screenplaymanager.h" #include "ScreenPlay/screenplaymanager.h"
#include <QScopeGuard> #include <QScopeGuard>
#include "util.h"
namespace ScreenPlay { namespace ScreenPlay {
/*! /*!

View File

@ -17,7 +17,7 @@ Rectangle {
if (Wallpaper.videoCodec === VideoCodec.Unknown) { if (Wallpaper.videoCodec === VideoCodec.Unknown) {
Wallpaper.terminate() Wallpaper.terminate()
} }
// macOS only supports h264 via the native Qt MM // macOS only supports h264 via the native Qt MM
if (Qt.platform.os === "osx") { if (Qt.platform.os === "osx") {
if ((Wallpaper.videoCodec === VideoCodec.VP8 if ((Wallpaper.videoCodec === VideoCodec.VP8
@ -36,7 +36,8 @@ Rectangle {
break break
case InstalledType.HTMLWallpaper: case InstalledType.HTMLWallpaper:
loader.setSource( loader.setSource(
"qrc:/qml/ScreenPlayWallpaper/qml/WebsiteWallpaper.qml", { "qrc:/qml/ScreenPlayWallpaper/qml/WebsiteWallpaper.qml",
{
"url": Qt.resolvedUrl( "url": Qt.resolvedUrl(
Wallpaper.projectSourceFileAbsolute) Wallpaper.projectSourceFileAbsolute)
}) })
@ -47,16 +48,18 @@ Rectangle {
break break
case InstalledType.WebsiteWallpaper: case InstalledType.WebsiteWallpaper:
loader.setSource( loader.setSource(
"qrc:/qml/ScreenPlayWallpaper/qml/WebsiteWallpaper.qml", { "qrc:/qml/ScreenPlayWallpaper/qml/WebsiteWallpaper.qml",
{
"url": Wallpaper.projectSourceFileAbsolute "url": Wallpaper.projectSourceFileAbsolute
}) })
fadeIn() fadeIn()
break break
case InstalledType.GifWallpaper: case InstalledType.GifWallpaper:
loader.setSource("qrc:/qml/ScreenPlayWallpaper/qml/GifWallpaper.qml", { loader.setSource(
"source": Qt.resolvedUrl( "qrc:/qml/ScreenPlayWallpaper/qml/GifWallpaper.qml", {
Wallpaper.projectSourceFileAbsolute) "source": Qt.resolvedUrl(
}) Wallpaper.projectSourceFileAbsolute)
})
fadeIn() fadeIn()
break break
} }
@ -297,7 +300,8 @@ Rectangle {
} }
Text { Text {
text: "projectSourceFileAbsolute " + Qt.resolvedUrl(Wallpaper.projectSourceFileAbsolute) text: "projectSourceFileAbsolute " + Qt.resolvedUrl(
Wallpaper.projectSourceFileAbsolute)
font.pointSize: 14 font.pointSize: 14
} }
@ -346,10 +350,13 @@ Rectangle {
text: "imgCover.status " + imgCover.status text: "imgCover.status " + imgCover.status
font.pointSize: 14 font.pointSize: 14
} }
} }
background: Rectangle { background: Rectangle {
opacity: 0.5 opacity: 0.5
} }
} }
} }

View File

@ -6,6 +6,7 @@ import shutil
import argparse import argparse
import time import time
import zipfile import zipfile
import defines
from typing import Tuple from typing import Tuple
from shutil import copytree from shutil import copytree
from pathlib import Path from pathlib import Path
@ -117,8 +118,7 @@ def execute(
def setup(build_config: BuildConfig, build_result: BuildResult) -> Tuple[BuildConfig, BuildResult]: def setup(build_config: BuildConfig, build_result: BuildResult) -> Tuple[BuildConfig, BuildResult]:
if build_config.use_aqt: if build_config.use_aqt:
build_config.aqt_path = Path( build_config.aqt_path = defines.AQT_PATH
f"{build_config.root_path}/../aqt/").resolve()
if not Path(build_config.aqt_path).exists(): if not Path(build_config.aqt_path).exists():
print( print(
@ -386,15 +386,15 @@ if __name__ == "__main__":
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('-deploy', action="store_true", dest="build_deploy", parser.add_argument('-deploy-version', action="store_true", dest="build_deploy",
help="Create a deploy version of ScreenPlay for sharing with the world. A not deploy version is for local development only!") help="Create a deploy version of ScreenPlay for sharing with the world. A not deploy version is for local development only!")
parser.add_argument('-architecture', action="store", dest="build_architecture", 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") 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() args = parser.parse_args()
qt_version = "6.3.1" qt_version = defines.QT_VERSION
screenplay_version = "0.15.0-RC1" screenplay_version = defines.SCREENPLAY_VERSION
qt_ifw_version = "4.4" # Not yet used. qt_ifw_version = defines.QT_IFW_VERSION # Not yet used.
qt_version_overwrite: str qt_version_overwrite: str
use_aqt = False use_aqt = False
@ -407,10 +407,10 @@ if __name__ == "__main__":
print("Using Qt installer framework version {qt_ifw_version}") print("Using Qt installer framework version {qt_ifw_version}")
if not args.build_type: if not args.build_type:
print("Build type argument is missing (release, debug). E.g: python build_config.py -type release -steam") parser.print_help()
print( print("\n\nBuild type argument is missing (release, debug). E.g: python build.py -type release -steam\n\n")
f"Defaulting to Qt version: {qt_version}. This can be overwritten via -qt-version 6.5.0")
exit(1) exit(1)
build_type = args.build_type build_type = args.build_type
build_steam = "OFF" build_steam = "OFF"

View File

@ -9,6 +9,7 @@ from pathlib import Path
from macos_lipo import run_lipo, check_fat_binary from macos_lipo import run_lipo, check_fat_binary
import platform import platform
import paramiko import paramiko
import defines
from util import sftp_exists from util import sftp_exists
if __name__ == "__main__": if __name__ == "__main__":
@ -27,9 +28,9 @@ if __name__ == "__main__":
build_result = build.BuildResult() build_result = build.BuildResult()
build_config = build.BuildConfig() build_config = build.BuildConfig()
build_config.screenplay_version = "0.15.0-RC2" build_config.screenplay_version = defines.SCREENPLAY_VERSION
build_config.qt_version = "6.3.1" build_config.qt_version = defines.QT_VERSION
build_config.qt_ifw_version = "4.4" build_config.qt_ifw_version = defines.QT_IFW_VERSION
build_config.build_steam = "ON" build_config.build_steam = "ON"
build_config.build_tests = "OFF" build_config.build_tests = "OFF"
build_config.build_deploy = "ON" build_config.build_deploy = "ON"

8
Tools/defines.py Normal file
View File

@ -0,0 +1,8 @@
import sys
from pathlib import Path
VCPKG_VERSION = "e2667a41fc2fc578474e9521d7eb90b769569c83" # Master 07.10.2022
QT_VERSION = "6.3.2"
QT_IFW_VERSION = "4.4"
SCREENPLAY_VERSION = "0.15.0-RC1"
AQT_PATH = Path("C:/aqt") if sys.platform == "win32" else Path("~/aqt")

View File

@ -1,4 +1,5 @@
pyunpack pyunpack
py7zr py7zr
cmake-format cmake-format
paramiko paramiko
aqtinstall

View File

@ -4,14 +4,15 @@ from install_requirements import install_requirements
install_requirements() install_requirements()
import argparse
import shutil
from platform import system from platform import system
from pathlib import Path from pathlib import Path
from execute_util import execute from execute_util import execute
import download_ffmpeg import download_ffmpeg
import defines
vcpkg_version = "98f8d00e89fb6a8019c2045cfa1edbe9d92d3405" # Master 09.07.2022 import argparse
import sys
import util
import datetime
class commands_list(): class commands_list():
def __init__(self): def __init__(self):
@ -41,55 +42,83 @@ class commands_list():
# Function call # Function call
command["command"]() command["command"]()
if __name__ == "__main__": def download(aqt_path: Path, qt_platform: Path):
# aqt list-qt windows desktop --modules 6.2.0 win64_msvc2019_64
qt_packages = "qt3d qt5compat qtimageformats qtmultimedia qtshadertools qtquick3d qtwebengine qtwebsockets qtwebview qtpositioning"
print(f"Downloading: {qt_packages} to {aqt_path}")
execute(f"python -m aqt install-qt -O {aqt_path} windows desktop {defines.QT_VERSION} {qt_platform} -m {qt_packages}")
# Tools can only be installed one at the time:
# see: aqt list-tool windows desktop
tools = ["tools_ifw", "tools_qtcreator", "tools_ninja" ,"tools_cmake"]
for tool in tools:
execute(f"python -m aqt install-tool -O {aqt_path} windows desktop {tool}")
def setup_qt():
aqt_path = defines.AQT_PATH
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)
else:
# Betas & RCs are technically the same version. So limit download to x days
days = 30
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)
two_weeks_ago: datetime = now - datetime.timedelta(days=days)
if(folder_creation_date < two_weeks_ago):
print(f"qt version at `{qt_base_path}` older than {days} days ({folder_creation_date}), redownload!")
download(aqt_path, qt_platform)
else:
print(f"Qt {defines.QT_VERSION} is up to date and ready ")
def main():
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description='Install ScreenPlay dependencies.') description='Build and Package ScreenPlay')
parser.add_argument( parser.add_argument('-skip-aqt', action="store_true", dest="skip_aqt",
'--path', help='Manually set the vcpkg path. The path must be an absolute path \ help="Downloads QtCreator and needed binaries \Windows: C:\aqt\nLinux & macOS:~/aqt/.")
without the ScreenPlay-vcpkg folder (E.g. py .\setup.py --path "D:/Backup/Code/Qt/")')
args = parser.parse_args() args = parser.parse_args()
# ScreenPlay source and ScreenPlay-vcpkg have to be on the same file system hierarchy root_path = Path(util.cd_repo_root_path())
project_source_parent_path = "" project_source_parent_path = root_path.joinpath("../").resolve()
project_source_path = Path.cwd().resolve() vcpkg_path = project_source_parent_path.joinpath("ScreenPlay-vcpkg").resolve()
if project_source_path.name == "Tools":
project_source_path = project_source_path.parent
if args.path is not None:
project_source_parent_path = Path(args.path).resolve()
else:
print("No --path provided, using default path.")
project_source_parent_path = project_source_path.parent
print("project_source_parent_path: {}".format(project_source_parent_path))
print("project_source_path: {}".format(project_source_path))
vcpkg_path = project_source_parent_path.joinpath("ScreenPlay-vcpkg")
print("vcpkg_path: ", vcpkg_path)
print("Build vcpkg ", vcpkg_version)
vcpkg_triplet = ""
vcpkg_command = ""
platform_command = commands_list()
vcpkg_packages_list = [ vcpkg_packages_list = [
"openssl", "openssl",
"curl", "curl",
"cpp-httplib", "cpp-httplib",
"libarchive" "libarchive"
] ]
if not args.skip_aqt:
setup_qt()
download_ffmpeg.execute() download_ffmpeg.execute()
if system() == "Windows": if system() == "Windows":
vcpkg_command = "vcpkg.exe" vcpkg_command = "vcpkg.exe"
vcpkg_packages_list.append("infoware[d3d]") vcpkg_packages_list.append("infoware[d3d]")
vcpkg_packages_list.append("sentry-native") vcpkg_packages_list.append("sentry-native")
platform_command = commands_list()
platform_command.add("bootstrap-vcpkg.bat", vcpkg_path, False) platform_command.add("bootstrap-vcpkg.bat", vcpkg_path, False)
vcpkg_triplet = ["x64-windows"] vcpkg_triplet = ["x64-windows"]
elif system() == "Darwin": elif system() == "Darwin":
vcpkg_command = "./vcpkg" vcpkg_command = "./vcpkg"
#vcpkg_packages_list.append("infoware[opencl]") does not work with arm #vcpkg_packages_list.append("infoware[opencl]") does not work with arm
vcpkg_packages_list.append("curl") # Hidden dependency from sentry vcpkg_packages_list.append("curl") # Hidden dependency from sentry
platform_command = commands_list()
platform_command.add("chmod +x bootstrap-vcpkg.sh", vcpkg_path) platform_command.add("chmod +x bootstrap-vcpkg.sh", vcpkg_path)
platform_command.add("./bootstrap-vcpkg.sh", vcpkg_path, False) platform_command.add("./bootstrap-vcpkg.sh", vcpkg_path, False)
platform_command.add("chmod +x vcpkg", vcpkg_path) platform_command.add("chmod +x vcpkg", vcpkg_path)
@ -97,6 +126,7 @@ without the ScreenPlay-vcpkg folder (E.g. py .\setup.py --path "D:/Backup/Code/Q
elif system() == "Linux": elif system() == "Linux":
vcpkg_command = "./vcpkg" vcpkg_command = "./vcpkg"
#vcpkg_packages_list.append("infoware[opengl]") #vcpkg_packages_list.append("infoware[opengl]")
platform_command = commands_list()
platform_command.add("chmod +x bootstrap-vcpkg.sh", vcpkg_path) platform_command.add("chmod +x bootstrap-vcpkg.sh", vcpkg_path)
platform_command.add("./bootstrap-vcpkg.sh", vcpkg_path, False) platform_command.add("./bootstrap-vcpkg.sh", vcpkg_path, False)
platform_command.add("chmod +x vcpkg", vcpkg_path) platform_command.add("chmod +x vcpkg", vcpkg_path)
@ -104,15 +134,18 @@ without the ScreenPlay-vcpkg folder (E.g. py .\setup.py --path "D:/Backup/Code/Q
else: else:
raise NotImplementedError("Unknown system: {}".format(system())) raise NotImplementedError("Unknown system: {}".format(system()))
print(f"Clone into {vcpkg_path}")
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(defines.VCPKG_VERSION), vcpkg_path)
execute(f"{vcpkg_command} remove --outdated --recurse", vcpkg_path, False)
# Setup vcpkg via boostrap script first
platform_command.execute_commands() # Execute platform specific commands.
for triplet in vcpkg_triplet: 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) vcpkg_packages = " ".join(vcpkg_packages_list)
execute("{} remove --outdated --recurse".format(vcpkg_command), vcpkg_path, False) execute(f"{vcpkg_command} install {vcpkg_packages} --triplet {triplet} --recurse", vcpkg_path, False)
execute("{} update".format(vcpkg_command), vcpkg_path, False)
execute("{} upgrade --no-dry-run".format(vcpkg_command), if __name__ == "__main__":
vcpkg_path, False) main()
execute("{} install {} --triplet {} --recurse".format(vcpkg_command,
vcpkg_packages, triplet), vcpkg_path, False)