mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-25 04:02:50 +01:00
Add new ci build script and check step
This is python based and is now functional for windows. We now should be able to extend this script for linux and mac. Move setup script to Tools folder.
This commit is contained in:
parent
f6b02cfea5
commit
b5dae423cb
8
.cmake-format.py
Normal file
8
.cmake-format.py
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
with section("format"):
|
||||
|
||||
# How wide to allow formatted cmake files
|
||||
line_width = 140
|
||||
|
||||
# How many spaces to tab for indent
|
||||
tab_size = 4
|
101
.gitlab-ci.yml
101
.gitlab-ci.yml
@ -1,47 +1,78 @@
|
||||
stages:
|
||||
- check
|
||||
- build
|
||||
|
||||
build:windows:
|
||||
check:
|
||||
stage: check
|
||||
tags:
|
||||
- vs2019
|
||||
- windows10
|
||||
script:
|
||||
- cd Tools
|
||||
- pip install cmakelang
|
||||
- python format-cmake.py
|
||||
- python format-cpp.py
|
||||
|
||||
build:windows_debug:
|
||||
stage: build
|
||||
tags:
|
||||
- vs2017
|
||||
- windows
|
||||
before_script:
|
||||
- git clean -xdf
|
||||
- git submodule sync --recursive
|
||||
- git submodule update --init --recursive
|
||||
# Needs MSVC 2019 installed!
|
||||
# Setup vcvars32.bat manually because this is powershell and MS does not have something simmilar for PS. Wtf?
|
||||
# https://gist.github.com/justinian/81a2e55c89e8301a8a96
|
||||
# https://stackoverflow.com/questions/2124753/how-can-i-use-powershell-with-the-visual-studio-command-prompt
|
||||
- $tempFile = [IO.Path]::GetTempFileName()
|
||||
- cmd /c " `"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat`" && set > `"$tempFile`" "
|
||||
- Get-Content $tempFile | Foreach-Object {if($_ -match "^(.*?)=(.*)$"){Set-Content "env:\$($matches[1])" $matches[2]}}
|
||||
- Remove-Item $tempFile
|
||||
- $Env:Path += ';C:\Qt\5.15.1\msvc2019_64\bin'
|
||||
- $Env:Path += ';C:\Qt\Tools\QtCreator\bin'
|
||||
- $env:path -split ";"
|
||||
cache:
|
||||
key: ${CI_RUNNER_DESCRIPTION}
|
||||
paths:
|
||||
- Common\vcpkg\
|
||||
- vs2019
|
||||
- windows10
|
||||
needs:
|
||||
- check
|
||||
script:
|
||||
- cmd /c install_dependencies_windows.bat
|
||||
- mkdir BUILD_WINDOWS
|
||||
- cd BUILD_WINDOWS
|
||||
- cmake.exe ../ -DCMAKE_PREFIX_PATH=c:/Qt/5.15.1/msvc2019 -DCMAKE_IGNORE_PATH=C:/Strawberry/c/bin -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_TOOLCHAIN_FILE="$(Get-Location)/../Common/vcpkg/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=x64-windows "-GCodeBlocks - Ninja" -B.
|
||||
- cmake.exe --build . --target all
|
||||
- cd bin
|
||||
- windeployqt.exe --release --qmldir ../../ScreenPlay/qml ScreenPlay.exe
|
||||
- windeployqt.exe --release --qmldir ../../ScreenPlayWidget ScreenPlayWidget.exe
|
||||
- windeployqt.exe --release --qmldir ../../ScreenPlayWallpaper ScreenPlayWallpaper.exe
|
||||
- del *.cpp,*.moc,*.h,*.obj,*.res,*.exp,*.lib,*.lik,*.pch, *.ninja, *.exe.manifest, *.cbp, *.cmake, *.ninja_log, *.ninja_deps, *.manifest
|
||||
- cd Tools
|
||||
- python build.py -t debug
|
||||
artifacts:
|
||||
expire_in: '12 weeks'
|
||||
expire_in: '4 weeks'
|
||||
paths:
|
||||
- BUILD_WINDOWS/bin/
|
||||
- build-x64-window-debug/bin/
|
||||
|
||||
build:windows_release:
|
||||
stage: build
|
||||
tags:
|
||||
- vs2019
|
||||
- windows10
|
||||
needs:
|
||||
- check
|
||||
script:
|
||||
- cd Tools
|
||||
- python build.py -t release
|
||||
artifacts:
|
||||
expire_in: '4 weeks'
|
||||
paths:
|
||||
- build-x64-window-release/bin/
|
||||
|
||||
build:linux_debug:
|
||||
stage: build
|
||||
tags:
|
||||
- gcc
|
||||
needs:
|
||||
- check
|
||||
script:
|
||||
- cd Tools
|
||||
- python build.py -t debug
|
||||
artifacts:
|
||||
expire_in: '4 weeks'
|
||||
paths:
|
||||
- build-x64-linux-debug/bin/
|
||||
|
||||
build:linux_release:
|
||||
stage: build
|
||||
tags:
|
||||
- gcc
|
||||
needs:
|
||||
- check
|
||||
script:
|
||||
- cd Tools
|
||||
- python build.py -t release
|
||||
artifacts:
|
||||
expire_in: '4 weeks'
|
||||
paths:
|
||||
- build-x64-linux-release/bin/
|
||||
|
||||
|
||||
build_docs:
|
||||
stage: .post
|
||||
script:
|
||||
- curl --request POST --form "token=$CI_JOB_TOKEN" --form ref=master https://gitlab.com/api/v4/projects/15800262/trigger/pipeline
|
||||
- curl --request POST --form "token=$CI_JOB_TOKEN" --form ref=master https://gitlab.com/api/v4/projects/15800262/trigger/pipeline
|
||||
|
@ -1,5 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.16.0 )
|
||||
|
||||
project(ScreenPlay)
|
||||
|
||||
# This sets cmake to compile all dlls into the main directory
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
@ -47,16 +49,13 @@ execute_process(COMMAND
|
||||
|
||||
add_compile_definitions(COMPILE_INFO="${BUILD_DATE} + ${GIT_COMMIT_HASH}")
|
||||
|
||||
|
||||
|
||||
if(UNIX)
|
||||
# Fixes QWebEngine linker errors
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=gold")
|
||||
endif()
|
||||
|
||||
|
||||
project(ScreenPlay)
|
||||
|
||||
add_subdirectory(ScreenPlay)
|
||||
add_subdirectory(ScreenPlaySDK)
|
||||
add_subdirectory(ScreenPlayShader)
|
||||
|
@ -8,12 +8,12 @@ git clone --recursive https://gitlab.com/kelteseth/ScreenPlay.git
|
||||
4. Start install-dependencies.bat to download dependencies into the Common/ folder
|
||||
``` bash
|
||||
//Windows
|
||||
.\install-dependencies.bat
|
||||
.\Tools\install-dependencies.bat
|
||||
|
||||
//Linux
|
||||
sudo apt install git gcc cmake build-essential libgl1-mesa-dev
|
||||
chmod +x install-dependencies.sh
|
||||
.\install-dependencies.sh
|
||||
.\Tools\install-dependencies.sh
|
||||
```
|
||||
* This will install these dependencies via __vcpkg__
|
||||
* openSSL 1.1.1d
|
||||
|
118
Tools/build.py
Normal file
118
Tools/build.py
Normal file
@ -0,0 +1,118 @@
|
||||
from sys import platform
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import shutil
|
||||
import argparse
|
||||
|
||||
# Based on https://gist.github.com/l2m2/0d3146c53c767841c6ba8c4edbeb4c2c
|
||||
def vs_env_dict():
|
||||
vsvar32 = 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Auxiliary\\Build\\vcvars64.bat'
|
||||
cmd = [vsvar32, '&&', 'set']
|
||||
popen = subprocess.Popen(
|
||||
cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
stdout, stderr = popen.communicate()
|
||||
|
||||
if popen.wait() != 0:
|
||||
raise ValueError(stderr.decode("mbcs"))
|
||||
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)
|
||||
|
||||
|
||||
# MAIN
|
||||
parser = argparse.ArgumentParser(description='Build and Package ScreenPlay')
|
||||
parser.add_argument('-t', action="store", dest="build_type")
|
||||
args = parser.parse_args()
|
||||
|
||||
qt_version = "5.15.1"
|
||||
print("Starting build with type %s. Qt Version: %s" %
|
||||
(args.build_type, qt_version))
|
||||
|
||||
|
||||
cmake_prefix_path = ""
|
||||
cmake_target_triplet = ""
|
||||
executable_file_ending = ""
|
||||
deploy_executable = ""
|
||||
|
||||
if platform == "win32":
|
||||
print("Loading MSVC env variables via vsvars32.bat")
|
||||
windows_msvc = "msvc2019_64"
|
||||
executable_file_ending = ".exe"
|
||||
deploy_executable = "windeployqt.exe"
|
||||
dict = vs_env_dict()
|
||||
dict["PATH"] = dict["PATH"] + ";C:\\Qt\\" + qt_version + "\\" + windows_msvc + "\\bin;C:\\Qt\\Tools\\QtCreator\\bin"
|
||||
os.environ.update(dict)
|
||||
cmake_prefix_path = "c:/Qt/" + qt_version + "/" + windows_msvc
|
||||
cmake_target_triplet = "x64-windows"
|
||||
os.system("install_dependencies_windows.bat")
|
||||
elif platform == "darwin":
|
||||
cmake_prefix_path = "~/Qt/"
|
||||
deploy_executable = "macdeployqt"
|
||||
cmake_target_triplet = "x64-osx"
|
||||
elif platform == "linux":
|
||||
# Windows...
|
||||
deploy_executable = "linuxdeployqt"
|
||||
cmake_prefix_path = "~/Qt/"
|
||||
cmake_target_triplet = "x64-linux"
|
||||
|
||||
# REMOVE OLD BUILD FOLDER
|
||||
cwd = os.getcwd()
|
||||
root_path = os.path.abspath((cwd+"/../"))
|
||||
os.chdir(root_path)
|
||||
cmake_toolchain_file = ("'{root_path}/Common/vcpkg/scripts/buildsystems/vcpkg.cmake'").format(root_path=root_path)
|
||||
print("cmake_toolchain_file: %s " % cmake_toolchain_file)
|
||||
|
||||
build_folder = "build-" + cmake_target_triplet + "-" + args.build_type
|
||||
|
||||
if os.path.isdir(build_folder):
|
||||
print("Remove previous build folder")
|
||||
shutil.rmtree(build_folder)
|
||||
|
||||
|
||||
os.mkdir(build_folder)
|
||||
os.chdir(root_path + "/" + build_folder)
|
||||
|
||||
cmake_configure_command = """cmake ../
|
||||
-DCMAKE_PREFIX_PATH={prefix_path}
|
||||
-DCMAKE_BUILD_TYPE={type}
|
||||
-DCMAKE_TOOLCHAIN_FILE={toolchain}
|
||||
-DVCPKG_TARGET_TRIPLET={triplet}
|
||||
-G "CodeBlocks - Ninja"
|
||||
-B.
|
||||
""".format(
|
||||
type=args.build_type,
|
||||
prefix_path=cmake_prefix_path,
|
||||
triplet=cmake_target_triplet,
|
||||
toolchain=cmake_toolchain_file).replace("\n", "")
|
||||
|
||||
print("cmake_configure_command: %s" % cmake_configure_command)
|
||||
|
||||
os.system(cmake_configure_command)
|
||||
os.system("cmake --build . --target all")
|
||||
os.chdir("bin")
|
||||
|
||||
os.system(("{deploy_executable} --{type} --qmldir ../../ScreenPlay/qml ScreenPlay{executable_file_ending}").format(
|
||||
type=args.build_type,
|
||||
executable_file_ending=executable_file_ending,
|
||||
deploy_executable=deploy_executable))
|
||||
|
||||
os.system(("{deploy_executable} --{type} --qmldir ../../ScreenPlayWidget ScreenPlayWidget{executable_file_ending}").format(
|
||||
type=args.build_type,
|
||||
executable_file_ending=executable_file_ending,
|
||||
deploy_executable=deploy_executable))
|
||||
|
||||
os.system(("{deploy_executable} --{type} --qmldir ../../ScreenPlayWallpaper ScreenPlayWallpaper{executable_file_ending}").format(
|
||||
type=args.build_type,
|
||||
executable_file_ending=executable_file_ending,
|
||||
deploy_executable=deploy_executable))
|
||||
|
||||
|
||||
file_endings = [".ninja_deps", ".ninja", ".ninja_log", ".lib", ".exp",
|
||||
".manifest", ".cmake", ".cbp", "CMakeCache.txt"]
|
||||
|
||||
for filename in os.listdir(os.getcwd()):
|
||||
for ending in file_endings:
|
||||
if filename.endswith(ending):
|
||||
full_file_path = os.path.join(os.getcwd(), filename)
|
||||
print("Remove: %s" % full_file_path)
|
||||
os.remove(full_file_path)
|
20
Tools/format-cmake.py
Normal file
20
Tools/format-cmake.py
Normal file
@ -0,0 +1,20 @@
|
||||
import fnmatch
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
executable = "cmake-format"
|
||||
if os.name == 'nt':
|
||||
executable += ".exe"
|
||||
|
||||
for root, dirnames, filenames in os.walk('../'):
|
||||
for filename in fnmatch.filter(filenames, 'CMakeLists.txt'):
|
||||
print(executable, root+"/"+filename)
|
||||
os.system(" %s -c ../.cmake-format.py -i %s" % (executable, (root + "/" + filename)))
|
||||
|
||||
# Check if all files are formatter
|
||||
output = subprocess.check_output("git diff", shell=True)
|
||||
|
||||
if output:
|
||||
print("Git diff is not empty. This means your CMakeLists.txt file was not formatted via %s!" % executable)
|
||||
sys.exit(1)
|
21
Tools/format-cpp.py
Normal file
21
Tools/format-cpp.py
Normal file
@ -0,0 +1,21 @@
|
||||
import fnmatch
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
executable = "clang-format"
|
||||
if os.name == 'nt':
|
||||
executable += ".exe"
|
||||
|
||||
for root, dirnames, files in os.walk('../'):
|
||||
for filename in files:
|
||||
if filename.endswith(('.cpp', '.h')):
|
||||
print(executable, root+"/"+filename)
|
||||
os.system(" %s -style=file -i %s" % (executable, (root + "/" + filename)))
|
||||
|
||||
# Check if all files are formatter
|
||||
output = subprocess.check_output("git diff", shell=True)
|
||||
|
||||
if output:
|
||||
print("Git diff is not empty. This means your code was not formatted via %s!" % executable)
|
||||
sys.exit(1)
|
@ -1,5 +1,6 @@
|
||||
git submodule update --init
|
||||
git submodule update --recursive
|
||||
cd ..
|
||||
cd Common
|
||||
git clone https://github.com/microsoft/vcpkg.git
|
||||
cd vcpkg
|
@ -1,5 +1,6 @@
|
||||
git submodule update --init
|
||||
git submodule update --recursive
|
||||
cd ..
|
||||
cd Common
|
||||
git clone https://github.com/microsoft/vcpkg.git
|
||||
cd vcpkg
|
13
Tools/lint-cmake.py
Normal file
13
Tools/lint-cmake.py
Normal file
@ -0,0 +1,13 @@
|
||||
import fnmatch
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
executable = "cmake-lint"
|
||||
if os.name == 'nt':
|
||||
executable += ".exe"
|
||||
|
||||
for root, dirnames, filenames in os.walk('../'):
|
||||
for filename in fnmatch.filter(filenames, 'CMakeLists.txt'):
|
||||
print(executable, root + "/" + filename)
|
||||
os.system(" %s %s" % (executable, (root + "/" + filename)))
|
Loading…
Reference in New Issue
Block a user