Skip to content

Commit

Permalink
Add packaging GitHub workflow (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikke89 committed Mar 15, 2024
1 parent 6cd8c7b commit cc6910f
Show file tree
Hide file tree
Showing 6 changed files with 269 additions and 38 deletions.
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ indent_style = tab
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true

[*.yml]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
32 changes: 16 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: Build

on: [push, pull_request]
on: [] #"[push, pull_request]

jobs:
Linux:
runs-on: ubuntu-20.04

env:
BUILD_TYPE: Release
CC: "${{ matrix.cc }}"
CXX: "${{ matrix.cxx }}"

strategy:
fail-fast: false
matrix:
Expand All @@ -30,12 +30,12 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Install Dependencies
run: |-
sudo apt update -yq
sudo apt install -yq cmake ninja-build clang libsdl2-dev libsdl2-image-dev libfreetype6-dev libglew-dev liblua5.2-dev libsfml-dev librlottie-dev libglfw3-dev
- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/Build

Expand All @@ -58,23 +58,23 @@ jobs:

macOS:
runs-on: macos-latest

env:
BUILD_TYPE: Release

strategy:
fail-fast: false
matrix:
include:
# - cmake_options: -DRMLUI_BACKEND=auto
- cmake_options: -DRMLUI_BACKEND=GLFW_GL2

steps:
- uses: actions/checkout@v3

- name: Install Dependencies
run: brew install lua sdl2 sdl2_image glfw

- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/Build

Expand All @@ -91,11 +91,11 @@ jobs:

Windows:
runs-on: windows-latest

env:
BUILD_TYPE: Release
VCPKG_DEFAULT_TRIPLET: x64-windows

strategy:
fail-fast: false
matrix:
Expand All @@ -104,10 +104,10 @@ jobs:
# After upgrading minimum CMake to >= 3.18, CMake should automatically find Vulkan using the VULKAN_SDK environment variable
- cmake_options: -DRMLUI_BACKEND=Win32_VK -DRMLUI_VK_DEBUG=ON -DVulkan_LIBRARY="C:\VulkanSDK\1.3.250.1\Lib\vulkan-1.lib" -DVulkan_INCLUDE_DIR="C:\VulkanSDK\1.3.250.1\Include\vulkan"
- cmake_options: -DRMLUI_BACKEND=SDL_VK -DRMLUI_BUILD_LUA_BINDINGS_FOR_LUAJIT=ON -DVulkan_LIBRARY="C:\VulkanSDK\1.3.250.1\Lib\vulkan-1.lib" -DVulkan_INCLUDE_DIR="C:\VulkanSDK\1.3.250.1\Include\vulkan"

steps:
- uses: actions/checkout@v3

- name: Enable Developer Command Prompt
uses: ilammy/[email protected]

Expand All @@ -116,7 +116,7 @@ jobs:
Invoke-WebRequest -Uri https://sdk.lunarg.com/sdk/download/1.3.250.1/windows/VulkanSDK-1.3.250.1-Installer.exe -OutFile vulkansdk.exe
.\vulkansdk.exe --confirm-command --accept-licenses --default-answer in com.lunarg.vulkan
C:\vcpkg\vcpkg install freetype[core] sdl2[core,vulkan] lua[core] luajit
- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/Build

Expand Down Expand Up @@ -151,7 +151,7 @@ jobs:
- name: Create Build Environment
run: cmake -E make_directory Build

- name: Configure CMake
run: |-
source ~/emsdk/emsdk_env.sh
Expand Down
206 changes: 206 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
name: Package

on: push

jobs:
Build:
runs-on: windows-2019

strategy:
fail-fast: false
matrix:
build_type: [Debug, Release]
library_linkage: [Dynamic, Static]
architecture: [win32, win64]

env:
GENERATOR: Visual Studio 16 2019
VCPKG_DEFAULT_TRIPLET: ${{ matrix.architecture == 'win32' && 'x86' || 'x64' }}-${{ matrix.library_linkage == 'Dynamic' && 'windows' || 'windows-static-md' }}

steps:
- uses: actions/checkout@v4

- name: Install Dependencies
run: |-
echo "Using vcpkg triplet: $env:VCPKG_DEFAULT_TRIPLET"
C:\vcpkg\vcpkg install freetype[core]
- name: Configure CMake
run: >-
cmake -B Build
-G "$env:GENERATOR"
-A ${{ matrix.architecture == 'win32' && 'Win32' || 'x64' }}
-DRMLUI_WARNINGS_AS_ERRORS=ON
-DBUILD_SHARED_LIBS=${{ matrix.library_linkage == 'Dynamic' && 'ON' || 'OFF' }}
-DVCPKG_TARGET_TRIPLET="$env:VCPKG_DEFAULT_TRIPLET"
-DCMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake"
-DCMAKE_INSTALL_PREFIX="${{github.workspace}}/Install"
-DCMAKE_INSTALL_BINDIR=Bin-${{matrix.library_linkage}}/${{matrix.build_type}}
-DCMAKE_INSTALL_LIBDIR=Bin-${{matrix.library_linkage}}/${{matrix.build_type}}
-DCMAKE_INSTALL_INCLUDEDIR=Include
-DRMLUI_INSTALL_TARGETS_DIR=Bin-${{matrix.library_linkage}}/CMake
- name: Build
run: cmake --build Build --config ${{ matrix.build_type }}

- name: Install
run: cmake --install Build --config ${{ matrix.build_type }}

- name: Copy licenses
run: |-
cp LICENSE.txt Install/LICENSE.txt
$vcpkg_installed_dir="C:/vcpkg/installed/$env:VCPKG_DEFAULT_TRIPLET/"
$destination_dir="./Install/Dependencies/Licenses/"
$copyright_files = Get-ChildItem -Path "$vcpkg_installed_dir/share" -Filter "copyright" -Recurse | Where-Object { $_.Directory.Name -notmatch '^vcpkg-' }
mkdir $destination_dir -Force | Out-Null
foreach ($file in $copyright_files) {
$name = $file.Directory.Name
Copy-Item -Path $file.FullName -Destination "$destination_dir/$name.txt"
}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.architecture }}-${{ matrix.build_type }}-${{ matrix.library_linkage }}
path: ${{github.workspace}}/Install/
if-no-files-found: error

Samples:
runs-on: windows-2019

strategy:
fail-fast: false
matrix:
architecture: [win32, win64]

env:
GENERATOR: Visual Studio 16 2019
VCPKG_DEFAULT_TRIPLET: ${{ matrix.architecture == 'win32' && 'x86' || 'x64' }}-windows${{ matrix.architecture == 'win64' && '-release' || '' }}

steps:
- uses: actions/checkout@v4

- uses: actions/checkout@v4
name: Checkout dependency rlottie
with:
repository: 'Samsung/rlottie'
ref: 'd40008707addacb636ff435236d31c694ce2b6cf'
path: 'Dependencies/rlottie'

- name: Install Dependencies
run: |-
echo "Using vcpkg triplet: $env:VCPKG_DEFAULT_TRIPLET"
C:\vcpkg\vcpkg install freetype[core] glfw3[core] lua[core] lunasvg[core]
cd Dependencies\rlottie
cmake -B build -G "$env:GENERATOR" -A ${{ matrix.architecture == 'win32' && 'Win32' || 'x64' }} -DBUILD_SHARED_LIBS=ON -DLOTTIE_MODULE=OFF
cmake --build build --target rlottie --config Release -- "/clp:ErrorsOnly"
- name: Configure CMake
run: >-
cmake -B Build
-G "$env:GENERATOR"
-A ${{ matrix.architecture == 'win32' && 'Win32' || 'x64' }}
--preset samples-all
-DRMLUI_BACKEND=GLFW_GL3
-DBUILD_SHARED_LIBS=ON
-DRMLUI_WARNINGS_AS_ERRORS=ON
-DVCPKG_TARGET_TRIPLET="$env:VCPKG_DEFAULT_TRIPLET"
-DCMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake"
-DCMAKE_INSTALL_PREFIX="${{github.workspace}}/Install"
-DCMAKE_INSTALL_BINDIR="samples"
-DCMAKE_INSTALL_LIBDIR="ignore/lib"
-DCMAKE_INSTALL_INCLUDEDIR="ignore/include"
-DCMAKE_INSTALL_DATADIR=""
- name: Build
run: cmake --build Build --config Release

- name: Copy runtime dependencies
run: cp Dependencies/rlottie/build/Release/rlottie.dll Build/bin/Release/

- name: Install
run: cmake --install Build --config Release

- name: Copy licenses
run: |-
$vcpkg_installed_dir="C:/vcpkg/installed/$env:VCPKG_DEFAULT_TRIPLET/"
$destination_dir="./Install/dependencies/"
$copyright_files = Get-ChildItem -Path "$vcpkg_installed_dir/share" -Filter "copyright" -Recurse | Where-Object { $_.Directory.Name -notmatch '^vcpkg-' }
mkdir $destination_dir -Force | Out-Null
foreach ($file in $copyright_files) {
$name = $file.Directory.Name
Copy-Item -Path $file.FullName -Destination "$destination_dir/$name.txt"
}
cp Dependencies/rlottie/licenses Install/Dependencies/rlottie -Recurse
cp Dependencies/rlottie/COPYING Install/Dependencies/rlottie
cp LICENSE.txt Install/LICENSE.txt
cp Include/RmlUi/Core/Containers/LICENSE.txt Install/LICENSE.Core.ThirdParty.txt
cp Source/Debugger/LICENSE.txt Install/LICENSE.Debugger.ThirdParty.txt
echo @'
The rlottie library includes source code licensed under Mozilla Public License Version 2.0.
The source for this code can be found in the rlottie library at the following URL:
https://github.com/Samsung/rlottie/blob/d40008707addacb636ff435236d31c694ce2b6cf/src/vector/vinterpolator.cpp
'@ > "Install/Dependencies/rlottie/vinterpolator.txt"
- name: Write readme
run: |-
$rmlui_version=""
if ("$env:GITHUB_REF" -like "refs/tags/*") {
$rmlui_version=" $env:GITHUB_REF" -replace "refs/tags/", ""
}
$date=git show $env:GITHUB_SHA --no-patch --format=%cd --date=iso
echo @"
RmlUi$rmlui_version library and sample binaries for ${{ matrix.architecture }}.
https://github.com/mikke89/RmlUi
Built using $env:GENERATOR on $date (run $env:GITHUB_RUN_ID).
Commit id: $env:GITHUB_SHA
"@ > "Install/Build.txt"
- uses: actions/upload-artifact@v4
with:
name: samples-${{ matrix.architecture }}
path: |
${{github.workspace}}/Install/
!${{github.workspace}}/Install/ignore
if-no-files-found: error

Package:
needs: [Build, Samples]
runs-on: windows-2019

strategy:
fail-fast: true
matrix:
architecture: [win32, win64]

steps:
- uses: actions/download-artifact@v4
with:
pattern: build-${{ matrix.architecture }}-*
merge-multiple: false

- uses: actions/download-artifact@v4
with:
name: samples-${{ matrix.architecture }}
path: Samples

- name: List artifact contents
run: |
Get-ChildItem -Recurse | ForEach-Object { $_.FullName }
- name: Zip artifacts
run: |
7z a RmlUi-vs2019-${{ matrix.architecture }}.zip ./
- name: Artifact SHA256 sum
run: |
cmake -E sha256sum RmlUi-vs2019-${{ matrix.architecture }}.zip
- uses: actions/upload-artifact@v4
with:
name: RmlUi-vs2019-${{ matrix.architecture }}
path: RmlUi-vs2019-${{ matrix.architecture }}.zip
25 changes: 25 additions & 0 deletions CMake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,36 @@ if(RMLUI_FONT_ENGINE STREQUAL "freetype")
endif()

if(RMLUI_LOTTIE_PLUGIN)
execute_process(COMMAND cmake --help-property-list OUTPUT_VARIABLE CMAKE_PROPERTY_LIST)
## Convert command output into a CMake list
STRING(REGEX REPLACE ";" "\\\\;" CMAKE_PROPERTY_LIST "${CMAKE_PROPERTY_LIST}")
STRING(REGEX REPLACE "\n" ";" CMAKE_PROPERTY_LIST "${CMAKE_PROPERTY_LIST}")

list(REMOVE_DUPLICATES CMAKE_PROPERTY_LIST)

function(print_target_properties tgt)
if(NOT TARGET ${tgt})
message("There is no target named '${tgt}'")
return()
endif()

foreach(prop ${CMAKE_PROPERTY_LIST})
string(REPLACE "<CONFIG>" "${CMAKE_BUILD_TYPE}" prop ${prop})
get_target_property(propval ${tgt} ${prop})
if(propval)
message("${tgt} ${prop} = ${propval}")
endif()
endforeach(prop)
endfunction(print_target_properties)

find_package("rlottie")

if(NOT TARGET rlottie::rlottie)
report_not_found_dependency("rlottie" rlottie::rlottie)
endif()

message(STATUS "Lottie plugin enabled, rlottie found.")
print_target_properties(rlottie::rlottie)
endif()

if(RMLUI_SVG_PLUGIN)
Expand Down
Loading

0 comments on commit cc6910f

Please sign in to comment.