Skip to content
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
131 changes: 60 additions & 71 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,61 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
build-unix:
runs-on: ${{ matrix.os }}
strategy:
matrix:
type: [Debug, Release]
os:
[
ubuntu-22.04,
ubuntu-22.04-arm,
windows-latest,
macos-15-intel,
macos-15,
]
os: [ubuntu-22.04, ubuntu-22.04-arm, macos-15-intel, macos-15]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Nix
uses: cachix/install-nix-action@v31

- name: Install devenv
uses: cachix/cachix-action@v16
with:
name: devenv

- run: nix profile install nixpkgs#devenv

- name: Build with devenv
shell: devenv shell bash -- -e {0}
run: |
cmake -B build -S . -G Ninja \
-DCMAKE_BUILD_TYPE=${{ matrix.type }} \
-DPLUME_BUILD_EXAMPLES=ON
cmake --build build --target plume
cmake --build build --target plume_triangle
cmake --build build --target plume_cube

- name: Upload Linux Build
if: runner.os == 'Linux'
uses: actions/upload-artifact@v4
with:
name: plume-linux-${{ matrix.type }}-${{ matrix.os }}
path: |
build/bin/plume_triangle
build/bin/plume_cube

- name: Upload macOS Build
if: runner.os == 'macOS'
uses: actions/upload-artifact@v4
with:
name: plume-macos-${{ matrix.type }}-${{ matrix.os }}
path: |
build/bin/plume_triangle
build/bin/plume_cube

build-windows:
runs-on: windows-latest
strategy:
matrix:
type: [Debug, Release]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -31,90 +73,37 @@ jobs:
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ runner.os }}-plume-ccache-${{ matrix.type }}
key: windows-plume-ccache-${{ matrix.type }}

- name: Install Windows Dependencies
if: runner.os == 'Windows'
run: |
choco install ninja
vcpkg install sdl2 --triplet x64-windows-static

Remove-Item -Path "C:\ProgramData\Chocolatey\bin\ccache.exe" -Force -ErrorAction SilentlyContinue
"C:\vcpkg\installed\x64-windows-static\bin" >> $env:GITHUB_PATH

- name: Install Linux Dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y ninja-build libsdl2-dev libgtk-3-dev

# Install SDL2
echo ::group::install SDL2
wget https://www.libsdl.org/release/SDL2-2.26.1.tar.gz
tar -xzf SDL2-2.26.1.tar.gz
cd SDL2-2.26.1
./configure
make -j 10
sudo make install
sudo cp -av /usr/local/lib/libSDL* /lib/x86_64-linux-gnu/
echo ::endgroup::

# Enable ccache
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"

- name: Install macOS Dependencies
if: runner.os == 'macOS'
run: |
brew install ninja sdl2

- name: Configure Developer Command Prompt
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1

- name: Build Plume (Unix)
if: runner.os != 'Windows'
run: |-
# enable ccache
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"

cmake -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DPLUME_BUILD_EXAMPLES=ON -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_MAKE_PROGRAM=ninja -G Ninja -S . -B cmake-build
cmake --build cmake-build --config ${{ matrix.type }} --target plume
cmake --build cmake-build --config ${{ matrix.type }} --target plume_triangle

- name: Build Plume (Windows)
if: runner.os == 'Windows'
run: |-
- name: Build Plume
run: |
# enable ccache
set $env:PATH="$env:USERPROFILE/.cargo/bin;$env:PATH"
$cpuCores = (Get-CimInstance -ClassName Win32_Processor).NumberOfLogicalProcessors

# remove LLVM from PATH so it doesn't overshadow the one provided by VS
$env:PATH = ($env:PATH -split ';' | Where-Object { $_ -ne 'C:\Program Files\LLVM\bin' }) -join ';'

cmake -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DPLUME_BUILD_EXAMPLES=ON -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER=clang-cl -DCMAKE_MAKE_PROGRAM=ninja -G Ninja -S . -B cmake-build
cmake --build cmake-build --config ${{ matrix.type }} --target plume -j $cpuCores
cmake --build cmake-build --config ${{ matrix.type }} --target plume_triangle -j $cpuCores
cmake -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DPLUME_BUILD_EXAMPLES=ON -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER=clang-cl -DCMAKE_MAKE_PROGRAM=ninja -G Ninja -S . -B build
cmake --build build --config ${{ matrix.type }} --target plume -j $cpuCores
cmake --build build --config ${{ matrix.type }} --target plume_triangle -j $cpuCores
cmake --build build --config ${{ matrix.type }} --target plume_cube -j $cpuCores

- name: Upload Windows Build
if: runner.os == 'Windows'
uses: actions/upload-artifact@v4
with:
name: plume-windows-${{ matrix.type }}
path: |
cmake-build/bin/plume_triangle.exe

- name: Upload Linux Build
if: runner.os == 'Linux'
uses: actions/upload-artifact@v4
with:
name: plume-linux-${{ matrix.type }}-${{ matrix.os }}
path: |
cmake-build/bin/plume_triangle

- name: Upload macOS Build
if: runner.os == 'macOS'
uses: actions/upload-artifact@v4
with:
name: plume-macos-${{ matrix.type }}-${{ matrix.os }}
path: |
cmake-build/bin/plume_triangle
build/bin/plume_triangle.exe
build/bin/plume_cube.exe
135 changes: 135 additions & 0 deletions devenv.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
{
pkgs,
lib,
inputs,
...
}:
{
# https://devenv.sh/basics/

# https://devenv.sh/packages/
packages =
(with pkgs; [
# Common development tools
cmake
ninja
pkg-config
git

# Graphics development dependencies
vulkan-headers
vulkan-loader
vulkan-tools
spirv-tools
spirv-headers
glslang

# Shader compilers
shaderc
directx-shader-compiler

# Vulkan validation
vulkan-validation-layers

# Math library for examples
glm
])
# macOS specific packages
++ lib.optionals pkgs.stdenv.isDarwin [
pkgs.moltenvk
]
# SDL2 from pinned nixpkgs
++ [ inputs.nixpkgs-sdl2.legacyPackages.${pkgs.system}.SDL2 ]
++ lib.optionals pkgs.stdenv.isLinux (with pkgs; [
# Linux specific packages
clang
clang-tools
lldb
libGL
libxkbcommon
wayland
wayland-protocols
mesa
xorg.libX11
xorg.libXrandr
xorg.libXi
])
# Note: On macOS, we use the system SDK via Xcode, so we don't need
# to include Darwin frameworks from nixpkgs here.
;

# Environment variables
env = {
# CMake build type for development
CMAKE_BUILD_TYPE = "Debug";

# Help CMake find SDL2 and GLM (using pinned SDL2)
SDL2_ROOT = "${inputs.nixpkgs-sdl2.legacyPackages.${pkgs.system}.SDL2}";
CMAKE_PREFIX_PATH = "${inputs.nixpkgs-sdl2.legacyPackages.${pkgs.system}.SDL2}:${pkgs.glm}";
} // lib.optionalAttrs pkgs.stdenv.isLinux {
# Vulkan environment for Linux
VK_LAYER_PATH = "${pkgs.vulkan-validation-layers}/share/vulkan/explicit_layer.d";
VK_INSTANCE_LAYERS = "VK_LAYER_KHRONOS_validation";
} // lib.optionalAttrs pkgs.stdenv.isDarwin {
# Vulkan environment for macOS (MoltenVK from nixpkgs)
VK_ICD_FILENAMES = "${pkgs.moltenvk}/share/vulkan/icd.d/MoltenVK_icd.json";
VK_LAYER_PATH = "${pkgs.vulkan-validation-layers}/share/vulkan/explicit_layer.d";
};

# https://devenv.sh/scripts/
scripts = {
configure.exec = ''
echo "Configuring build with CMake..."
cmake -B build -S . -G Ninja -DCMAKE_BUILD_TYPE=Debug -DPLUME_BUILD_EXAMPLES=ON
'';

build.exec = ''
echo "Building project..."
cmake --build build
'';

clean.exec = ''
echo "Cleaning build directory..."
rm -rf build
'';

run-triangle.exec = ''
echo "Running triangle example..."
${if pkgs.stdenv.isDarwin then ''
export VK_ICD_FILENAMES="${pkgs.moltenvk}/share/vulkan/icd.d/MoltenVK_icd.json"
export VK_LAYER_PATH="${pkgs.vulkan-validation-layers}/share/vulkan/explicit_layer.d"
export DYLD_LIBRARY_PATH="${pkgs.vulkan-loader}/lib:''${DYLD_LIBRARY_PATH:-}"
'' else ""}
./build/bin/plume_triangle
'';

run-cube.exec = ''
echo "Running cube example..."
${if pkgs.stdenv.isDarwin then ''
export VK_ICD_FILENAMES="${pkgs.moltenvk}/share/vulkan/icd.d/MoltenVK_icd.json"
export VK_LAYER_PATH="${pkgs.vulkan-validation-layers}/share/vulkan/explicit_layer.d"
export DYLD_LIBRARY_PATH="${pkgs.vulkan-loader}/lib:''${DYLD_LIBRARY_PATH:-}"
'' else ""}
./build/bin/plume_cube
'';
};

# https://devenv.sh/languages/
# On macOS we use Xcode's clang via enterShell PATH override
languages = lib.optionalAttrs pkgs.stdenv.isLinux {
c.enable = true;
cplusplus.enable = true;
};

# On macOS, use Xcode toolchain instead of Nix's
enterShell = lib.optionalString pkgs.stdenv.isDarwin ''
export DEVELOPER_DIR="$(/usr/bin/readlink /var/db/xcode_select_link)"
export SDKROOT="$DEVELOPER_DIR/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"

# Use system clang instead of Nix's clang-wrapper
export PATH="$DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin:$DEVELOPER_DIR/usr/bin:$PATH"

# Use system xcrun instead of Nix's xcbuild version (avoids Metal compiler warnings)
export PATH="${pkgs.runCommand "xcrun-wrapper" {} "mkdir -p $out/bin && ln -s /usr/bin/xcrun $out/bin/xcrun"}/bin:$PATH"
'';
}
5 changes: 5 additions & 0 deletions devenv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
inputs:
nixpkgs:
url: github:cachix/devenv-nixpkgs/rolling
nixpkgs-sdl2:
url: github:NixOS/nixpkgs/nixos-24.05