Skip to content

Enable CrossPlatform Builds and CI (#345 and #355) #462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ PenaltyBreakTemplateDeclaration: 100
PenaltyReturnTypeOnItsOwnLine: 300
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortIncludes: false
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/Engine-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ jobs:
uses: ./.github/workflows/macOS-build.yml
with:
targetFramework: net8.0

linux:
needs: clang-format
uses: ./.github/workflows/linux-build.yml
with:
targetFramework: net8.0
49 changes: 49 additions & 0 deletions .github/workflows/job-cmakebuild-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: ZEngine Cmake Linux Workflow

on:
workflow_call:
inputs:
configuration:
type: string
default: 'Debug'
targetFramework:
type: string
default: 'net8.0'

jobs:
Linux-Build:
name: cmake-build-linux-${{ inputs.configuration }}
runs-on: ubuntu-24.04

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Download the Microsoft repository GPG keys
run: wget -q https://packages.microsoft.com/config/ubuntu/24.04/packages-microsoft-prod.deb

- name: Register the Microsoft repository GPG keys
run: sudo dpkg -i packages-microsoft-prod.deb

- name: Update the list of packages after we added packages.microsoft.com
run: sudo apt-get update

- name: Install development library
run: sudo apt-get install libasound2-dev libgl1-mesa-dev libpulse-dev libdbus-1-dev libx11-dev libxcursor-dev libxext-dev libxi-dev libxinerama-dev libxrandr-dev libxss-dev libxt-dev libxxf86vm-dev cmake apt-transport-https software-properties-common gcc g++ powershell clang-format glslang-tools libwayland-dev libxkbcommon-dev

- name: CMake Build
run: .\Scripts\BuildEngine.ps1 -Configurations ${{inputs.configuration}}
shell: pwsh

- name: Publish Build Artifacts
uses: actions/upload-artifact@v4
with:
name: Build-linux-${{inputs.configuration}}
path: |
Panzerfaust/bin/${{inputs.configuration}}/publish/
Result.Linux.x64.${{inputs.configuration}}/__externals/Vulkan-Loader/loader/
Result.Linux.x64.${{inputs.configuration}}/ZEngine/tests/
Panzerfaust/bin/${{inputs.configuration}}/${{inputs.targetFramework}}/**/Microsoft.CodeAnalysis.CSharp.resources.dll
!Panzerfaust/bin/${{inputs.configuration}}/${{inputs.targetFramework}}/**/Microsoft.CodeAnalysis.CSharp.Scripting.resources.dll
!Panzerfaust/bin/${{inputs.configuration}}/${{inputs.targetFramework}}/**/Microsoft.CodeAnalysis.resources.dll
!Panzerfaust/bin/${{inputs.configuration}}/${{inputs.targetFramework}}/**/Microsoft.CodeAnalysis.Scripting.resources.dll
29 changes: 29 additions & 0 deletions .github/workflows/job-deploy-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Deploy for linux
#
name: linux Deploy Workflow

on:
workflow_call:
inputs:
targetFramework:
type: string
required: true
configuration:
type: string
default: 'Release'

jobs:
deploy:
name: deploy-linux-${{ inputs.configuration }}
runs-on: ubuntu-24.04
steps:
- uses: actions/download-artifact@v4
with:
path: Result.Darwin.x64.${{ inputs.configuration }}
name: Build-linux-Release

- name: Publish Artifacts
uses: actions/upload-artifact@v4
with:
name: linux-${{ inputs.configuration }}
path: Panzerfaust/bin/${{ inputs.configuration }}/${{inputs.targetFramework}}/publish/
30 changes: 30 additions & 0 deletions .github/workflows/job-test-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Run tests for linux
#
name: linux Test Workflow

on:
workflow_call:
inputs:
configuration:
type: string
default: 'Debug'

jobs:
test:
name: test-linux-${{ inputs.configuration }}
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: Build-linux-${{ inputs.configuration }}

- name: Update access permission of ZEngineTests
run: chmod +x ./Result.Linux.x64.${{ inputs.configuration }}/ZEngine/tests/ZEngineTests

- name: Run Tests
run: .\Scripts\RunTests.ps1 -Configurations ${{ inputs.configuration }}
shell: pwsh
78 changes: 28 additions & 50 deletions .github/workflows/linux-build.yml
Original file line number Diff line number Diff line change
@@ -1,59 +1,37 @@
# @JeanPhilippeKernel : Disabled because we only support Windows as platform for now
# @JeanPhilippeKernel
#
name: ZEngine Linux Build

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_call:
inputs:
targetFramework:
required: true
type: string

jobs:
Linux-Build:
runs-on: ubuntu-latest
cmake-build:
strategy:
matrix:
buildConfiguration: [Debug, Release]

steps:
- name: Checkout repository
uses: actions/checkout@v2

# - name: Checkout submodules
# run: git submodule update --init --recursive

# - name: Install development library
# run: sudo apt-get install libasound2-dev libgl1-mesa-dev libpulse-dev libdbus-1-dev libx11-dev libxcursor-dev libxext-dev libxi-dev libxinerama-dev libxrandr-dev libxss-dev libxt-dev libxxf86vm-dev

# - name: Install CMake
# uses: jwlawson/[email protected]
# with:
# cmake-version: '3.20.x'

# - name: Install pre-requisite packages.
# run: sudo apt-get install -y wget apt-transport-https software-properties-common

# - name: Download the Microsoft repository GPG keys
# run: wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb

# - name: Register the Microsoft repository GPG keys
# run: sudo dpkg -i packages-microsoft-prod.deb

# - name: Update the list of packages after we added packages.microsoft.com
# run: sudo apt-get update

# - name: Install PowerShell
# run: sudo apt-get install -y powershell

# - name: Add GCC Toolchain repository
# run: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test

# - name: Install GCC compiler
# run: sudo apt install -y gcc-11

# - name: Install G++ compiler
# run: sudo apt install -y g++-11
buildConfiguration: [Debug, Release]
uses: ./.github/workflows/job-cmakebuild-linux.yml
with:
configuration: ${{matrix.buildConfiguration}}
targetframework: ${{inputs.targetFramework}}

test:
needs: cmake-build
strategy:
matrix:
testConfiguration: [Debug, Release]
uses: ./.github/workflows/job-test-linux.yml
with:
configuration: ${{matrix.testConfiguration}}

deploy:
needs: test
uses: ./.github/workflows/job-deploy-linux.yml
with:
configuration: Release
targetframework: ${{inputs.targetFramework}}

# - name: CMake Build
# run: .\Scripts\BuildEngine.ps1 -Configurations ${{matrix.buildConfiguration}}
# shell: pwsh
32 changes: 8 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
cmake_minimum_required (VERSION 3.17 FATAL_ERROR)

set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (CMAKE_CXX_STANDARD 20)
set (CMAKE_CXX_EXTENSIONS OFF)

project (RendererEngine
VERSION 1.0
DESCRIPTION "Renderer Engine is an open-source 2D - 3D rendering engine written in C/C++"
Expand Down Expand Up @@ -42,30 +46,10 @@ endif()
# Externals dependencies
#
if (NOT LAUNCHER_ONLY)
add_subdirectory (${EXTERNAL_DIR}/fmt)
add_subdirectory (${EXTERNAL_DIR}/imgui)
add_subdirectory (${EXTERNAL_DIR}/glfw)
add_subdirectory (${EXTERNAL_DIR}/spdlog)
add_subdirectory (${EXTERNAL_DIR}/glm)
add_subdirectory (${EXTERNAL_DIR}/entt)
add_subdirectory (${EXTERNAL_DIR}/assimp)
add_subdirectory (${EXTERNAL_DIR}/stduuid)
add_subdirectory (${EXTERNAL_DIR}/yaml-cpp)
add_subdirectory (${EXTERNAL_DIR}/SPIRV-headers)
add_subdirectory (${EXTERNAL_DIR}/SPIRV-Tools)
add_subdirectory (${EXTERNAL_DIR}/glslang)
add_subdirectory (${EXTERNAL_DIR}/SPIRV-Cross)
add_subdirectory (${EXTERNAL_DIR}/gtest)
add_subdirectory (${EXTERNAL_DIR}/VulkanMemoryAllocator)
add_subdirectory (${EXTERNAL_DIR}/tlsf)
add_subdirectory (${EXTERNAL_DIR}/rapidhash)
add_subdirectory (${EXTERNAL_DIR}/CLI11)

set (CMAKE_PREFIX_PATH
${CMAKE_PREFIX_PATH}
${EXTERNAL_DIR}/Vulkan-Headers/build/install/share/cmake
)
add_subdirectory (${EXTERNAL_DIR}/Vulkan-Loader)

## Setup Dependencies

include(${EXTERNAL_DIR}/externals.cmake)

# Core engine lib is here
#
Expand Down
39 changes: 9 additions & 30 deletions Scripts/BuildEngine.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,7 @@ if(-Not $LauncherOnly) {
$RepoRoot = [IO.Path]::Combine($PSScriptRoot, "..")
Write-Host "Ensuring submodules are initialized and updated..."
& git -C $RepoRoot submodule update --init --recursive

Write-Host "Configuring Vulkan-Header submodule..."

$ExternalVulkanHeadersDir = Join-Path -Path $RepoRoot -ChildPath "__externals/Vulkan-Headers"
$ExternalVulkanHeadersOutputDir = Join-Path -Path $ExternalVulkanHeadersDir -ChildPath "build"
$ExternalVulkanHeadersInstallDir = Join-Path -Path $ExternalVulkanHeadersOutputDir -ChildPath "install"

if(-Not (Test-Path -Path $ExternalVulkanHeadersInstallDir)) {
& $cMakeProgram -S $ExternalVulkanHeadersDir -B $ExternalVulkanHeadersOutputDir
& $cMakeProgram --install $ExternalVulkanHeadersOutputDir --prefix $ExternalVulkanHeadersInstallDir
}
} else {
Write-Host "Skipping submodules initialization..."
}

}

function Build([string]$configuration, [int]$VsVersion , [bool]$runBuild) {

Expand All @@ -113,7 +99,6 @@ function Build([string]$configuration, [int]$VsVersion , [bool]$runBuild) {
# Check the system name
if ($IsLinux) {
$systemName = "Linux"
$cMakeGenerator
}
elseif ($IsMacOS) {
$systemName = "Darwin"
Expand All @@ -131,28 +116,26 @@ function Build([string]$configuration, [int]$VsVersion , [bool]$runBuild) {
[string]$BuildDirectoryName = "Result." + $systemName + "." + $architecture + "." + $BuildDirectoryNameExtension
[string]$buildDirectoryPath = [IO.Path]::Combine($RepoRoot, $BuildDirectoryName)
[string]$cMakeCacheVariableOverride = ""
[string]$cMakeGenerator = ""

# Create build directory
if (-Not (Test-Path $buildDirectoryPath)) {
$Null = New-Item -ItemType Directory -Path $BuildDirectoryPath -ErrorAction SilentlyContinue
}

# Define CMake Generator arguments
$cMakeOptions = " -DCMAKE_SYSTEM_NAME=$systemName", " -DCMAKE_BUILD_TYPE=$configuration"
$cMakeOptions = " -DCMAKE_SYSTEM_NAME=$systemName", " -DCMAKE_BUILD_TYPE=$configuration", " -DBUILD_SHARED_LIBS=OFF"
$submoduleCMakeOptions = @{
'ENTT' = @("-DENTT_INCLUDE_HEADERS=ON")
'SPDLOG' = @("-DSPDLOG_BUILD_SHARED=OFF", "-DBUILD_STATIC_LIBS=ON", "-DSPDLOG_FMT_EXTERNAL=ON", "-DSPDLOG_FMT_EXTERNAL_HO=OFF");
'GLFW ' = @("-DGLFW_BUILD_DOCS=OFF", "-DGLFW_BUILD_EXAMPLES=OFF", "-DGLFW_INSTALL=OFF");
'SPDLOG' = @("-DSPDLOG_BUILD_SHARED=OFF", "-DSPDLOG_FMT_EXTERNAL=ON", "-DSPDLOG_FMT_EXTERNAL_HO=OFF");
'GLFW ' = @("-DGLFW_BUILD_DOCS=OFF", "-DGLFW_INSTALL=OFF", "-DGLFW_BUILD_WAYLAND=OFF");
'ASSIMP' = @("-DASSIMP_BUILD_TESTS=OFF", "-DASSIMP_INSTALL=OFF", "-DASSIMP_BUILD_SAMPLES=OFF", "-DASSIMP_BUILD_ASSIMP_TOOLS=OFF", "-DASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT=OFF", "-DASSIMP_BUILD_OBJ_IMPORTER=ON", "-DASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT=OFF", "-DASSIMP_BUILD_OBJ_EXPORTER=ON");
'STDUUID' = @("-DUUID_BUILD_TESTS=OFF", "-DUUID_USING_CXX20_SPAN=ON", "-DUUID_SYSTEM_GENERATOR=OFF");
'YAMLCPP' = @("-DYAML_CPP_BUILD_TOOLS=OFF", "-DYAML_CPP_BUILD_TESTS=OFF", "-DYAML_CPP_FORMAT_SOURCE=OFF", "-DYAML_BUILD_SHARED_LIBS=OFF");
'FRAMEWORK' = @("-DBUILD_FRAMEWORK=ON");
'VULKAN_LOADER' = @("-DVULKAN_HEADERS_INSTALL_DIR=$ExternalVulkanHeadersInstallDir", "-DUSE_MASM=OFF", "-DUSE_GAS=OFF")
'SPIRV_TOOLS' = @("-DSPIRV_SKIP_EXECUTABLES=ON", "-DSPIRV_SKIP_TESTS=ON")
'SPIRV_TOOLS' = @("-DSPIRV_SKIP_EXECUTABLES=ON", "-DSPIRV_SKIP_TESTS=ON", "-DSPIRV_WERROR=OFF")
'SPIRV_CROSS' = @("-DSPIRV_CROSS_ENABLE_TESTS=OFF")
'LAUNCHER_ONLY' = @("-DLAUNCHER_ONLY=ON")
'GLM' = @("-DCMAKE_POLICY_VERSION_MINIMUM=3.5")
}

$cMakeCacheVariableOverride = $cMakeOptions -join ' '
Expand All @@ -162,7 +145,7 @@ function Build([string]$configuration, [int]$VsVersion , [bool]$runBuild) {
"Windows" {
switch ($VsVersion) {
2022 {
$cMakeGenerator = "-G `"Visual Studio 17 2022`" -A $architecture"
$cMakeGenerator = "`"Visual Studio 17 2022`" -A $architecture"
}
Default {
throw 'This version of Visual Studio is not supported'
Expand All @@ -171,14 +154,10 @@ function Build([string]$configuration, [int]$VsVersion , [bool]$runBuild) {
$cMakeCacheVariableOverride += ' -DCMAKE_CONFIGURATION_TYPES=Debug;Release '
}
"Linux" {
$cMakeGenerator = "-G `"Unix Makefiles`""

# Set Linux build compiler
$env:CC = '/usr/bin/gcc-11'
$env:CXX = '/usr/bin/g++-11'
$cMakeGenerator = "Ninja"
}
"Darwin" {
$cMakeGenerator = "-G `"Xcode`""
$cMakeGenerator = "Xcode"
$cMakeCacheVariableOverride += ' ' + $submoduleCMakeOptions.FRAMEWORK -join ' '
}
Default {
Expand All @@ -201,7 +180,7 @@ function Build([string]$configuration, [int]$VsVersion , [bool]$runBuild) {
$cMakeCacheVariableOverride += ' ' + $submoduleCMakeOptions.GLM -join ' '
}

$cMakeArguments = " -S $repositoryRootPath -B $buildDirectoryPath $cMakeGenerator $cMakeCacheVariableOverride"
$cMakeArguments = " -S $repositoryRootPath -B $buildDirectoryPath -G $cMakeGenerator $cMakeCacheVariableOverride"

# CMake Generation process
Write-Host $cMakeArguments
Expand Down
12 changes: 4 additions & 8 deletions Scripts/PostBuild.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ param (
[string[]] $SystemName = 'Windows',

[Parameter(HelpMessage="Architecture type to build, default to x64")]
[ValidateSet('win-x64', 'arm64', 'osx-x64', 'osx-arm64')]
[ValidateSet('win-x64', 'arm64', 'osx-x64', 'osx-arm64', 'linux-x64')]
[string[]] $Architectures = 'win-x64',

[Parameter(HelpMessage="Configuration type to build, default to Debug")]
Expand All @@ -43,11 +43,7 @@ $ErrorActionPreference = "Stop"
$TargetFramework = 'net8.0'

[string]$RepoRoot = [IO.Path]::Combine($PSScriptRoot, "..")
[string]$OuputBuildDirectory = If($IsWindows) {
[IO.Path]::Combine($RepoRoot, "Result.Windows.x64.MultiConfig")
} Else {
[IO.Path]::Combine($RepoRoot, "Result.$SystemName.x64.$Configurations")
}
[string]$OuputBuildDirectory = [IO.Path]::Combine($RepoRoot, "../builds/RendererEngine")

if($LauncherOnly) {
Write-Host "Skipping resources copy..."
Expand Down Expand Up @@ -103,7 +99,7 @@ $ContentsToProcess = @(
}
}
"Linux" {
@{ From = "$OuputBuildDirectory\Tetragrama\$Configurations"; To = "$OuputBuildDirectory\Panzerfaust\$Configurations\$TargetFramework\Editor"}
@{ From = "$OuputBuildDirectory\Tetragrama\"; To = "$OuputBuildDirectory\Panzerfaust\$Configurations\$TargetFramework\Editor"}
}
Default {
throw 'This system is not supported'
Expand Down Expand Up @@ -133,4 +129,4 @@ foreach ($item in $ContentsToProcess) {
[string]$ToDirectory = $content.To
Write-Host "Copied $name --> $ToDirectory"
}
}
}
Loading
Loading