Fix Mac build. #47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [ "main", "master" ] | |
| pull_request: | |
| branches: [ "main", "master" ] | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| name: ${{ matrix.name }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: Windows | |
| os: windows-latest | |
| cmake_gen: "" | |
| # Windows defaults to MSVC, which is what we want. | |
| # CMakeLists.txt handles MSVC specific flags. | |
| cmake_extra_args: "" | |
| install_swiftshader: true | |
| - name: Linux | |
| os: ubuntu-latest | |
| cmake_gen: "-G Ninja" | |
| # Installing Clang 21 as per user's environment | |
| cmake_extra_args: "-DCMAKE_C_COMPILER=clang-21 -DCMAKE_CXX_COMPILER=clang++-21" | |
| install_swiftshader: false | |
| - name: macOS | |
| os: macos-14 # Apple Silicon (M1/M2) | |
| cmake_gen: "-G Ninja" | |
| # Explicitly using Homebrew Clang 17 | |
| cmake_extra_args: "-DCMAKE_C_COMPILER=$(brew --prefix llvm@17)/bin/clang -DCMAKE_CXX_COMPILER=$(brew --prefix llvm@17)/bin/clang++" | |
| install_swiftshader: false | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| lfs: false | |
| submodules: recursive | |
| # Temporarily disabled LFS due to budget exhaustion | |
| # - name: Create LFS file list | |
| # run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id | |
| # - name: Restore LFS cache | |
| # uses: actions/cache@v4 | |
| # id: lfs-cache | |
| # with: | |
| # path: .git/lfs | |
| # key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }} | |
| # - name: Git LFS Pull | |
| # if: steps.lfs-cache.outputs.cache-hit != 'true' | |
| # run: git lfs pull | |
| - name: Setup Vulkan SDK | |
| uses: jakoch/install-vulkan-sdk-action@v1 | |
| with: | |
| vulkan_version: 1.4.335.0 | |
| cache: true | |
| install_swiftshader: ${{ matrix.install_swiftshader }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Install Dependencies (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| wget https://apt.llvm.org/llvm.sh | |
| chmod +x llvm.sh | |
| sudo ./llvm.sh 21 | |
| sudo apt-get install -y ninja-build libx11-dev libxrandr-dev libxi-dev libxcursor-dev libxinerama-dev mesa-vulkan-drivers libc++-21-dev libc++abi-21-dev | |
| - name: Install Dependencies (macOS) | |
| if: runner.os == 'macOS' | |
| run: | | |
| brew install ninja llvm@17 | |
| - name: Configure CMake | |
| run: | | |
| cmake -S . -B build ${{ matrix.cmake_gen }} ${{ matrix.cmake_extra_args }} -DCMAKE_BUILD_TYPE=Debug | |
| - name: Build | |
| run: cmake --build build --config Debug | |
| - name: Configure Environment (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| $swiftShaderDll = "C:\hostedtoolcache\windows\swiftshader\5.0.0.1\x64\vk_swiftshader.dll" | |
| $targetDll = "build\Debug\vulkan-1.dll" | |
| if (Test-Path $swiftShaderDll) { | |
| Copy-Item $swiftShaderDll $targetDll -Force | |
| echo "Copied SwiftShader to $targetDll to bypass elevated loader restrictions." | |
| } else { | |
| echo "::error::SwiftShader DLL not found at $swiftShaderDll" | |
| } | |
| - name: Configure Environment (macOS) | |
| if: runner.os == 'macOS' | |
| run: | | |
| # Disable Metal Argument Buffers to prevent crash on Paravirt GPU | |
| echo "MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS=0" >> $GITHUB_ENV | |
| # Disable MTLHeap usage to prevent OOM on Paravirt GPU | |
| echo "MVK_CONFIG_USE_MTLHEAP=0" >> $GITHUB_ENV | |
| # Enable debug logging for MoltenVK | |
| echo "MVK_CONFIG_LOG_LEVEL=3" >> $GITHUB_ENV | |
| # Fix for Paravirt stability/OOM | |
| echo "MVK_CONFIG_SYNCHRONOUS_QUEUE_SUBMITS=1" >> $GITHUB_ENV | |
| echo "MVK_CONFIG_USE_COMMAND_POOLING=0" >> $GITHUB_ENV | |
| # Check common locations for MoltenVK ICD | |
| if [ -f "$VULKAN_SDK/share/vulkan/icd.d/MoltenVK_icd.json" ]; then | |
| echo "Found MoltenVK at share/..." | |
| echo "VK_ICD_FILENAMES=$VULKAN_SDK/share/vulkan/icd.d/MoltenVK_icd.json" >> $GITHUB_ENV | |
| elif [ -f "$VULKAN_SDK/etc/vulkan/icd.d/MoltenVK_icd.json" ]; then | |
| echo "Found MoltenVK at etc/..." | |
| echo "VK_ICD_FILENAMES=$VULKAN_SDK/etc/vulkan/icd.d/MoltenVK_icd.json" >> $GITHUB_ENV | |
| else | |
| echo "::warning::MoltenVK ICD not found in standard locations." | |
| # Fallback to verify directory contents | |
| ls -R "$VULKAN_SDK" || true | |
| fi | |
| # Also set VK_LAYER_PATH just in case | |
| if [ -d "$VULKAN_SDK/share/vulkan/explicit_layer.d" ]; then | |
| echo "VK_LAYER_PATH=$VULKAN_SDK/share/vulkan/explicit_layer.d" >> $GITHUB_ENV | |
| elif [ -d "$VULKAN_SDK/etc/vulkan/explicit_layer.d" ]; then | |
| echo "VK_LAYER_PATH=$VULKAN_SDK/etc/vulkan/explicit_layer.d" >> $GITHUB_ENV | |
| fi | |
| - name: Test | |
| run: ctest --test-dir build -C Debug --verbose |