Skip to content

Chore/cleanup

Chore/cleanup #131

name: CMake Multi-Platform
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
BUILD_TYPE: Release
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: Windows
os: windows-latest
target: windows
- name: Linux
os: ubuntu-latest
target: linux
- name: Web (WASM)
os: ubuntu-22.04
target: web
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
# ------------------------------------------------------------------------
# Linux Dependencies
# ------------------------------------------------------------------------
- name: Install dependencies (Linux)
if: matrix.target == 'linux'
run: sudo apt update && sudo apt install -y cmake g++ make xorg-dev libgl1-mesa-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev xvfb
# ------------------------------------------------------------------------
# Web / Emscripten Dependencies
# ------------------------------------------------------------------------
- name: Setup Emscripten (Web)
if: matrix.target == 'web'
uses: mymindstorm/setup-emsdk@v14
with:
version: latest
actions-cache-folder: 'emsdk-cache'
# ------------------------------------------------------------------------
# Desktop Builds (Windows & Linux)
# ------------------------------------------------------------------------
- name: Configure CMake (Desktop)
if: matrix.target != 'web'
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DWEIRD_ENGINE_BUILD_EXAMPLES=ON -DWEIRD_TEST_HOOKS=ON
- name: Build (Desktop)
if: matrix.target != 'web'
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- name: Test (Linux)
if: matrix.target == 'linux'
working-directory: ${{github.workspace}}/build/examples/sample-scenes
env:
WEIRD_AUTO_QUIT_SECONDS: 3
WEIRD_SCREENSHOT_FRAME: 10
run: xvfb-run -a ./WeirdSamples
- name: Upload Test Artifacts (Desktop)
if: matrix.target != 'web' && always()
uses: actions/upload-artifact@v4
with:
name: test-artifacts-${{ matrix.target }}
path: |
${{github.workspace}}/build/examples/sample-scenes/log.txt
${{github.workspace}}/build/examples/sample-scenes/screenshot_*.bmp
${{github.workspace}}/build/examples/sample-scenes/Release/log.txt
${{github.workspace}}/build/examples/sample-scenes/Release/screenshot_*.bmp
# ------------------------------------------------------------------------
# Web Build (Emscripten / WASM)
# ------------------------------------------------------------------------
- name: Build WeirdSamples for Web
if: matrix.target == 'web'
run: |
mkdir build && cd build
emcmake cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DWEIRD_ENGINE_BUILD_EXAMPLES=ON \
-DCMAKE_C_FLAGS="-pthread" \
-DCMAKE_CXX_FLAGS="-pthread" \
-DCMAKE_EXECUTABLE_SUFFIX=".html" \
-DCMAKE_EXE_LINKER_FLAGS="-pthread -sPTHREAD_POOL_SIZE=4 -sINITIAL_MEMORY=33554432 -sMAX_WEBGL_VERSION=2 -sMIN_WEBGL_VERSION=2 --preload-file ${{github.workspace}}/examples/sample-scenes/assets@/assets --preload-file ${{github.workspace}}/src/weird-renderer/fonts@/fonts --preload-file ${{github.workspace}}/src/weird-renderer/shaders@/shaders"
emmake make WeirdSamples
- name: Prepare Web Artifact
if: matrix.target == 'web'
run: |
mkdir -p game_export
# Copy generated index files or fallback to target name
if ls build/examples/sample-scenes/index.* 1> /dev/null 2>&1; then
cp build/examples/sample-scenes/index.* game_export/
else
cp build/examples/sample-scenes/WeirdSamples.* game_export/
cp game_export/WeirdSamples.html game_export/index.html
fi
cp -r build/examples/sample-scenes/assets game_export/
cp -r build/examples/sample-scenes/fonts game_export/
cp -r build/examples/sample-scenes/shaders game_export/
- name: Upload Web Artifact
if: matrix.target == 'web'
uses: actions/upload-artifact@v4
with:
name: weird-engine-web-sample
path: game_export/