CI: Enable Qt5 + lightpreview (#406)

* chore(CI): refine current 'cmake.yml' file content

* chore(CI): enable Qt5 on Linux and macOS

* Appveyor.yml: remove deploy step

we are deploying from GitHub Actions now

* build-linux-64.sh: adjust .zip wildcard

to hopefully not break on PR builds

* build-linux-64.sh: remove fragile unzip/readelf lines

* lightpreview\CMakeLists.txt: only install Qt on Win/Mac

* lightpreview: attempt to fix mac Qt packaging

* lightpreview: apple fixes

* Install qtdbus on macOS

* try alternate dbus module name

* try cmake find_package for dbus

* also find Qt5PrintSupport

* build-osx.sh: remove coreutils install

we don't use sha256sum anymore

* lightpreview/CMakeLists.txt: create .app bundle on macOS

* Update CMakeLists.txt

* build-*: run cpack as part of the build command

on my macOS test system, running cpack separately
is doubling the build time

* cmake: factor out add_loader_path_to_rpath function, apply to all targets

* chore(CI): add steps to re-pack the 'doc' and 'bin' directories

* chore(CI): remove GitHub release-related step (to be re-introduced)

* chore(CI): adjust inflating destination directories

---------

Co-authored-by: Eric Wasylishen <ewasylishen@gmail.com>
This commit is contained in:
Jonathan Linat 2024-01-08 22:16:41 -05:00 committed by GitHub
parent 126931a151
commit 39074b8249
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 183 additions and 141 deletions

View File

@ -1,86 +0,0 @@
name: CMake
on: [push, pull_request]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
# Don't cancel the macOS build if the Linux build fails, etc.
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-11, windows-2019]
use-asan: [YES, NO]
exclude:
- os: windows-2019
use-asan: YES
env:
# Expose to the build-*.sh in an environment variable
USE_ASAN: ${{ matrix.use-asan }}
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
# https://github.com/ilammy/msvc-dev-cmd
- name: Setup MSVC environment
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
- name: Linux Build
if: runner.os == 'Linux'
run: |
sudo apt-get update
# for Sphinx
sudo apt-get install -y python3-pip
./build-linux-64.sh
- name: macOS Build
if: runner.os == 'macOS'
run: |
./build-osx.sh
- name: Windows Build
if: runner.os == 'Windows'
run: |
.\build-windows.ps1
# Upload artifacts.
# These need to be separate, otherwise all of the artifacts are bundled into
# one .zip file.
- name: Upload win64 artifact
uses: actions/upload-artifact@v3
if: ${{ runner.os == 'Windows' && matrix.use-asan == 'NO' }}
with:
name: ericw-tools-${{ github.sha }}-win64
path: |
build-windows/ericw-tools-*.zip
- name: Upload Linux artifact
uses: actions/upload-artifact@v3
if: ${{ runner.os == 'Linux' && matrix.use-asan == 'NO' }}
with:
name: ericw-tools-${{ github.sha }}-Linux
path: |
build-linux/ericw-tools-*.zip
- name: Upload macOS artifact
uses: actions/upload-artifact@v3
if: ${{ runner.os == 'macOS' && matrix.use-asan == 'NO' }}
with:
name: ericw-tools-${{ github.sha }}-macOS
path: |
build-osx/ericw-tools-*.zip
- name: Create GitHub Release and upload builds
uses: softprops/action-gh-release@v1
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.use-asan == 'NO' && runner.os != 'Windows' }}
with:
draft: true
files: |
build-osx/ericw-tools-*.zip
build-linux/ericw-tools-*.zip
build-windows/ericw-tools-*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -0,0 +1,99 @@
name: Continuous Building
on:
- push
- pull_request
jobs:
build-and-upload:
name: Build & upload the artifact
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-22.04
- macos-12
- windows-2022
use-asan:
- YES
- NO
exclude:
- os: windows-2022
use-asan: YES
env:
USE_ASAN: ${{ matrix.use-asan }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: 'Linux: Install Qt5'
if: startsWith(matrix.os, 'ubuntu-')
run: |
sudo apt update
sudo apt install qtbase5-dev libqt5svg5-dev
- name: 'Linux: Build the artifact'
if: startsWith(matrix.os, 'ubuntu-')
run: ./build-linux-64.sh
- name: 'Linux: Prepare the artifact'
if: ${{ startsWith(matrix.os, 'ubuntu-') }}
run: |
unzip build-linux/*-Linux.zip
mv ericw-tools-*/*-Linux/ ericw-tools-linux
- name: 'Linux: Upload the artifact'
if: ${{ startsWith(matrix.os, 'ubuntu-') && matrix.use-asan == 'NO' }}
uses: actions/upload-artifact@v4
with:
path: ericw-tools-linux/
name: ericw-tools-${{ github.sha }}-linux
if-no-files-found: error
- name: 'macOS: Install Qt5'
if: ${{ startsWith(matrix.os, 'macos-') }}
uses: jurplel/install-qt-action@v3
with:
version: 5.15.2
- name: 'macOS: Build the artifact'
if: startsWith(matrix.os, 'macos-')
run: ./build-osx.sh
- name: 'macOS: Prepare the artifact'
if: ${{ startsWith(matrix.os, 'macos-') }}
run: |
unzip build-osx/*-Darwin.zip
mv ericw-tools-*/*-Darwin/ ericw-tools-macos
- name: 'macOS: Upload the artifact'
if: ${{ startsWith(matrix.os, 'macos-') && matrix.use-asan == 'NO' }}
uses: actions/upload-artifact@v4
with:
path: ericw-tools-macos/
name: ericw-tools-${{ github.sha }}-macos
if-no-files-found: error
- name: 'Windows: Setup MSVC environment'
if: startsWith(matrix.os, 'windows-')
uses: ilammy/msvc-dev-cmd@v1
- name: 'Windows: Install Qt5'
if: ${{ startsWith(matrix.os, 'windows-') }}
uses: jurplel/install-qt-action@v3
with:
version: 5.15.2
arch: win64_msvc2019_64
- name: 'Windows: Build the artifact'
if: startsWith(matrix.os, 'windows-')
run: .\build-windows.ps1
- name: 'Windows: Prepare the artifact'
if: ${{ startsWith(matrix.os, 'windows-') }}
run: |
7z x build-windows\*-win64.zip -o"ericw-tools-windows-temp\" -y
New-Item -ItemType Directory -Path ericw-tools-windows
Get-ChildItem -Path ericw-tools-windows-temp\ericw-tools-*\*-win64 -Recurse |
Move-Item -Destination ericw-tools-windows
shell: pwsh
- name: 'Windows: Upload the artifact'
if: ${{ startsWith(matrix.os, 'windows-') && matrix.use-asan == 'NO' }}
uses: actions/upload-artifact@v4
with:
path: ericw-tools-windows/
name: ericw-tools-${{ github.sha }}-windows
if-no-files-found: error

View File

@ -96,6 +96,14 @@ function(copy_mingw_dlls TARGETNAME)
endif()
endfunction()
# so the executable will search for dylib's in the same directory as the executable
function(add_loader_path_to_rpath TARGETNAME)
if(APPLE)
add_custom_command(TARGET ${TARGETNAME} POST_BUILD
COMMAND bash ARGS -c \"install_name_tool -add_rpath @loader_path $<TARGET_FILE:${TARGETNAME}> || true\")
endif()
endfunction()
if (WIN32)
set("NO_ITERATOR_DEBUG" FALSE CACHE BOOL "Whether to use MSVC iterator debugging or not")

View File

@ -13,12 +13,3 @@ build_script:
- cmd: powershell .\build-appveyor.ps1
artifacts:
- path: cmakebuild\*.zip
deploy:
description: 'release description'
provider: GitHub
auth_token:
secure: +KEW/TPBKmDCgwmkYgXMuhDJPY1iGeWz7Qf4Vw42Rnk+6OixNCfbvS+zP9IvYgtD
draft: true
prerelease: false
on:
appveyor_repo_tag: true

View File

@ -7,5 +7,6 @@ add_custom_command(TARGET bspinfo POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:TBB::tbbmalloc>" "$<TARGET_FILE_DIR:bspinfo>"
)
copy_mingw_dlls(bspinfo)
add_loader_path_to_rpath(bspinfo)
install(TARGETS bspinfo RUNTIME DESTINATION bin)

View File

@ -15,5 +15,6 @@ add_custom_command(TARGET bsputil POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:TBB::tbbmalloc>" "$<TARGET_FILE_DIR:bsputil>"
)
copy_mingw_dlls(bsputil)
add_loader_path_to_rpath(bsputil)
install(TARGETS bsputil RUNTIME DESTINATION bin)

View File

@ -25,7 +25,7 @@ TBB_CMAKE_DIR="$(pwd)/oneapi-tbb-2021.3.0/lib/cmake"
# check USE_ASAN environment variable (see cmake.yml)
if [ "$USE_ASAN" == "YES" ]; then
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_PREFIX_PATH="$EMBREE_CMAKE_DIR;$TBB_CMAKE_DIR" -DERICWTOOLS_ASAN=YES
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_PREFIX_PATH="$EMBREE_CMAKE_DIR;$TBB_CMAKE_DIR" -DENABLE_LIGHTPREVIEW=YES -DERICWTOOLS_ASAN=YES
else
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$EMBREE_CMAKE_DIR;$TBB_CMAKE_DIR"
fi
@ -33,8 +33,7 @@ fi
# not yet free of memory leaks, so don't abort on leak detection
export ASAN_OPTIONS=detect_leaks=false
make -j8 VERBOSE=1 || exit 1
cpack || exit 1
make -j8 VERBOSE=1 package || exit 1
# run tests
if [ "$USE_ASAN" != "YES" ]; then
@ -45,5 +44,3 @@ fi
# check rpath
readelf -d ./light/light
unzip -X ericw-tools-*.zip
readelf -d ./ericw-tools-*/bin/light

View File

@ -1,12 +1,9 @@
#!/bin/bash
# for sha256sum, used by the tests
brew install coreutils
python3 -m pip install -r docs/requirements.txt --force-reinstall
BUILD_DIR=build-osx
EMBREE_ZIP="https://github.com/embree/embree/releases/download/v3.13.0/embree-3.13.0.x86_64.macosx.zip"
EMBREE_ZIP="https://github.com/embree/embree/releases/download/v3.13.1/embree-3.13.1.x86_64.macosx.zip"
# embree-3.13.1.x86_64.macosx.zip
EMBREE_ZIP_NAME=$(basename "$EMBREE_ZIP")
@ -14,9 +11,9 @@ EMBREE_ZIP_NAME=$(basename "$EMBREE_ZIP")
# embree-3.13.1.x86_64.macosx
EMBREE_DIR_NAME=$(basename "$EMBREE_ZIP_NAME" ".zip")
TBB_TGZ="https://github.com/oneapi-src/oneTBB/releases/download/v2021.2.0/oneapi-tbb-2021.2.0-mac.tgz"
TBB_TGZ="https://github.com/oneapi-src/oneTBB/releases/download/v2021.3.0/oneapi-tbb-2021.3.0-mac.tgz"
TBB_TGZ_NAME=$(basename "$TBB_TGZ")
TBB_DIR_NAME="oneapi-tbb-2021.2.0"
TBB_DIR_NAME="oneapi-tbb-2021.3.0"
if [ -d "$BUILD_DIR" ]; then
echo "$BUILD_DIR already exists, remove it first"
@ -32,16 +29,16 @@ unzip -q "$EMBREE_ZIP_NAME"
wget -q "$TBB_TGZ"
tar xf "$TBB_TGZ_NAME"
EMBREE_CMAKE_DIR="$(pwd)/$EMBREE_DIR_NAME/lib/cmake/embree-3.13.0"
EMBREE_CMAKE_DIR="$(pwd)/$EMBREE_DIR_NAME/lib/cmake/embree-3.13.1"
TBB_CMAKE_DIR="$(pwd)/${TBB_DIR_NAME}/lib/cmake"
# check USE_ASAN environment variable (see cmake.yml)
if [ "$USE_ASAN" == "YES" ]; then
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_PREFIX_PATH="$EMBREE_CMAKE_DIR;$TBB_CMAKE_DIR" -DERICWTOOLS_ASAN=YES
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_PREFIX_PATH="$EMBREE_CMAKE_DIR;$TBB_CMAKE_DIR" -DENABLE_LIGHTPREVIEW=YES -DERICWTOOLS_ASAN=YES
else
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$EMBREE_CMAKE_DIR;$TBB_CMAKE_DIR"
fi
make -j8 || exit 1
cpack || exit 1
make -j8 package || exit 1
# print shared libraries used
otool -L ./light/light

View File

@ -20,18 +20,13 @@ choco install ninja
mkdir build-windows
cd build-windows
cmake .. -GNinja -Dembree_DIR="C:\embree-3.12.1.x64.vc14.windows" -DTBB_DIR="C:\tbb\cmake" -DCMAKE_BUILD_TYPE=Release
cmake .. -GNinja -Dembree_DIR="C:\embree-3.12.1.x64.vc14.windows" -DTBB_DIR="C:\tbb\cmake" -DCMAKE_BUILD_TYPE=Release -DENABLE_LIGHTPREVIEW=YES -DQt5Widgets_DIR="C:\Qt\5.15.2\msvc2019_64\lib\cmake\Qt5Widgets"
ninja
ninja package
if ( $? -eq $false ) {
throw "build failed"
}
cpack
if ( $? -eq $false ) {
throw "package failed"
}
.\tests\tests.exe --no-skip
if ( $? -eq $false ) {

View File

@ -91,12 +91,6 @@ if (embree_FOUND)
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${EMBREE_TBB_DLL}" "$<TARGET_FILE_DIR:light>")
endif()
# so the executable will search for dylib's in the same directory as the executable
if(APPLE)
add_custom_command(TARGET light POST_BUILD
COMMAND bash ARGS -c \"install_name_tool -add_rpath @loader_path $<TARGET_FILE:light> || true\")
endif()
if(NOT SKIP_EMBREE_INSTALL)
install(FILES $<TARGET_FILE:embree> DESTINATION bin)
endif()
@ -144,6 +138,7 @@ if (embree_FOUND)
endif(embree_FOUND)
copy_mingw_dlls(light)
add_loader_path_to_rpath(light)
install(TARGETS light RUNTIME DESTINATION bin)
install(FILES ../gpl_v3.txt DESTINATION bin)

View File

@ -18,6 +18,7 @@ add_executable(lightpreview
glview.h)
set_target_properties(lightpreview PROPERTIES WIN32_EXECUTABLE YES)
set_target_properties(lightpreview PROPERTIES MACOSX_BUNDLE TRUE)
INCLUDE_DIRECTORIES(${EMBREE_INCLUDE_DIRS})
@ -42,31 +43,70 @@ target_link_libraries(lightpreview
# from: http://stackoverflow.com/questions/40564443/copying-qt-dlls-to-executable-directory-on-windows-using-cmake
# Copy Qt DLL's to bin directory for debugging
add_custom_command(
TARGET lightpreview POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Widgets> $<TARGET_FILE_DIR:lightpreview>
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Gui> $<TARGET_FILE_DIR:lightpreview>
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Core> $<TARGET_FILE_DIR:lightpreview>
)
if (WIN32)
add_custom_command(
TARGET lightpreview POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Widgets> $<TARGET_FILE_DIR:lightpreview>
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Gui> $<TARGET_FILE_DIR:lightpreview>
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Core> $<TARGET_FILE_DIR:lightpreview>
)
# HACK: copy .dll dependencies
add_custom_command(TARGET lightpreview POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:embree>" "$<TARGET_FILE_DIR:lightpreview>"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:TBB::tbb>" "$<TARGET_FILE_DIR:lightpreview>"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:TBB::tbbmalloc>" "$<TARGET_FILE_DIR:lightpreview>"
)
if (NOT EMBREE_TBB_DLL STREQUAL EMBREE_TBB_DLL-NOTFOUND)
# HACK: copy .dll dependencies
add_custom_command(TARGET lightpreview POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${EMBREE_TBB_DLL}" "$<TARGET_FILE_DIR:lightpreview>")
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:embree>" "$<TARGET_FILE_DIR:lightpreview>"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:TBB::tbb>" "$<TARGET_FILE_DIR:lightpreview>"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:TBB::tbbmalloc>" "$<TARGET_FILE_DIR:lightpreview>"
)
if (NOT EMBREE_TBB_DLL STREQUAL EMBREE_TBB_DLL-NOTFOUND)
add_custom_command(TARGET lightpreview POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${EMBREE_TBB_DLL}" "$<TARGET_FILE_DIR:lightpreview>")
endif()
endif()
copy_mingw_dlls(lightpreview)
add_loader_path_to_rpath(lightpreview)
# Install Qt DLL's
install(FILES $<TARGET_FILE:Qt5::Widgets> DESTINATION bin)
install(FILES $<TARGET_FILE:Qt5::Gui> DESTINATION bin)
install(FILES $<TARGET_FILE:Qt5::Core> DESTINATION bin)
if (WIN32)
install(FILES $<TARGET_FILE:Qt5::Widgets> DESTINATION bin)
install(FILES $<TARGET_FILE:Qt5::Gui> DESTINATION bin)
install(FILES $<TARGET_FILE:Qt5::Core> DESTINATION bin)
install(FILES "$<TARGET_FILE:Qt5::QWindowsIntegrationPlugin>" DESTINATION bin/platforms)
endif ()
install(TARGETS lightpreview RUNTIME DESTINATION bin)
function(apple_install_lib SRC_TARGET_NAME DEST_PATH)
# SRC_TARGET_NAME - a target name, e.g. Qt5::Widgets
# DEST_PATH - destination path to install the library to
get_target_property(SO_FILE_SYMLINK ${SRC_TARGET_NAME} IMPORTED_LOCATION_RELEASE)
message(STATUS "${SRC_TARGET_NAME} .so symlink: ${SO_FILE_SYMLINK}")
get_filename_component(SO_FILE_SYMLINK_NAME "${SO_FILE_SYMLINK}" NAME)
message(STATUS "${SRC_TARGET_NAME} .so symlink name: ${SO_FILE_SYMLINK_NAME}")
get_filename_component(SO_FILE "${SO_FILE_SYMLINK}" REALPATH)
message(STATUS "${SRC_TARGET_NAME} .so file: ${SO_FILE}, renaming to: ${SO_FILE_SYMLINK_NAME} and installing in: ${DEST_PATH}")
install(FILES ${SO_FILE} DESTINATION "${DEST_PATH}" RENAME "${SO_FILE_SYMLINK_NAME}")
endfunction()
if (APPLE)
apple_install_lib(TBB::tbb "$<TARGET_FILE_DIR:lightpreview>")
apple_install_lib(TBB::tbbmalloc "$<TARGET_FILE_DIR:lightpreview>")
apple_install_lib(embree "$<TARGET_FILE_DIR:lightpreview>")
# TODO: this should be replaced with macdeployqt
apple_install_lib(Qt5::Widgets "$<TARGET_FILE_DIR:lightpreview>/QtWidgets.framework/Versions/5")
apple_install_lib(Qt5::Gui "$<TARGET_FILE_DIR:lightpreview>/QtGui.framework/Versions/5")
apple_install_lib(Qt5::Core "$<TARGET_FILE_DIR:lightpreview>/QtCore.framework/Versions/5")
apple_install_lib(Qt5::QCocoaIntegrationPlugin "$<TARGET_FILE_DIR:lightpreview>/platforms")
# these are required by QCocoaIntegrationPlugin
find_package(Qt5DBus REQUIRED)
find_package(Qt5PrintSupport REQUIRED)
apple_install_lib(Qt5::PrintSupport "$<TARGET_FILE_DIR:lightpreview>/QtPrintSupport.framework/Versions/5")
apple_install_lib(Qt5::DBus "$<TARGET_FILE_DIR:lightpreview>/QtDBus.framework/Versions/5")
endif ()
install(TARGETS lightpreview RUNTIME DESTINATION bin BUNDLE DESTINATION bin)

View File

@ -28,5 +28,6 @@ add_custom_command(TARGET maputil POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:TBB::tbbmalloc>" "$<TARGET_FILE_DIR:maputil>"
)
copy_mingw_dlls(maputil)
add_loader_path_to_rpath(maputil)
install(TARGETS maputil RUNTIME DESTINATION bin)

View File

@ -46,3 +46,4 @@ add_custom_command(TARGET qbsp POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:TBB::tbbmalloc>" "$<TARGET_FILE_DIR:qbsp>")
copy_mingw_dlls(qbsp)
add_loader_path_to_rpath(qbsp)

View File

@ -43,5 +43,6 @@ if (NOT EMBREE_TBB_DLL STREQUAL EMBREE_TBB_DLL-NOTFOUND)
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${EMBREE_TBB_DLL}" "$<TARGET_FILE_DIR:tests>")
endif()
copy_mingw_dlls(tests)
add_loader_path_to_rpath(tests)
add_definitions(-DHAVE_EMBREE)

View File

@ -27,5 +27,6 @@ add_custom_command(TARGET vis POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:TBB::tbbmalloc>" "$<TARGET_FILE_DIR:vis>"
)
copy_mingw_dlls(vis)
add_loader_path_to_rpath(vis)
install(TARGETS vis RUNTIME DESTINATION bin)