|
| 1 | +name: OpenXR Engine CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths: |
| 6 | + - 'attachments/openxr_engine/**' |
| 7 | + - 'attachments/simple_engine/**' |
| 8 | + - '.github/workflows/openxr_engine_ci.yml' |
| 9 | + pull_request: |
| 10 | + paths: |
| 11 | + - 'attachments/openxr_engine/**' |
| 12 | + - 'attachments/simple_engine/**' |
| 13 | + - '.github/workflows/openxr_engine_ci.yml' |
| 14 | + workflow_dispatch: |
| 15 | + |
| 16 | +jobs: |
| 17 | + desktop: |
| 18 | + name: Build (${{ matrix.os }}) |
| 19 | + runs-on: ${{ matrix.os }} |
| 20 | + strategy: |
| 21 | + fail-fast: false |
| 22 | + matrix: |
| 23 | + os: [ubuntu-latest, windows-latest] |
| 24 | + |
| 25 | + defaults: |
| 26 | + run: |
| 27 | + working-directory: attachments/openxr_engine |
| 28 | + |
| 29 | + steps: |
| 30 | + - name: Checkout |
| 31 | + uses: actions/checkout@v4 |
| 32 | + |
| 33 | + - name: Install Clang + Ninja + ccache (Linux) |
| 34 | + if: runner.os == 'Linux' |
| 35 | + shell: bash |
| 36 | + run: | |
| 37 | + set -euo pipefail |
| 38 | + sudo apt-get update |
| 39 | + sudo apt-get install -y clang ninja-build ccache libopenxr-dev |
| 40 | + |
| 41 | + - name: Select Clang toolchain (Linux) |
| 42 | + if: runner.os == 'Linux' |
| 43 | + shell: bash |
| 44 | + run: | |
| 45 | + set -euo pipefail |
| 46 | + echo "CC=clang" >> "$GITHUB_ENV" |
| 47 | + echo "CXX=clang++" >> "$GITHUB_ENV" |
| 48 | + |
| 49 | + - name: Set up MSVC dev environment |
| 50 | + if: runner.os == 'Windows' |
| 51 | + uses: ilammy/msvc-dev-cmd@v1 |
| 52 | + |
| 53 | + - name: Set up Ninja + sccache |
| 54 | + if: runner.os == 'Windows' |
| 55 | + shell: pwsh |
| 56 | + run: | |
| 57 | + choco install -y ninja sccache |
| 58 | + $chocoBin = "C:\ProgramData\chocolatey\bin" |
| 59 | + if (Test-Path $chocoBin) { |
| 60 | + $chocoBin | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append |
| 61 | + } |
| 62 | + "SCCACHE_DIR=$env:LOCALAPPDATA\Mozilla\sccache" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
| 63 | + |
| 64 | + - name: ccache (Linux) |
| 65 | + if: runner.os == 'Linux' |
| 66 | + uses: actions/cache@v4 |
| 67 | + with: |
| 68 | + path: ~/.cache/ccache |
| 69 | + key: ${{ runner.os }}-openxr-ccache-${{ github.sha }} |
| 70 | + restore-keys: ${{ runner.os }}-openxr-ccache- |
| 71 | + |
| 72 | + - name: sccache (Windows) |
| 73 | + if: runner.os == 'Windows' |
| 74 | + uses: actions/cache@v4 |
| 75 | + with: |
| 76 | + path: ${{ env.SCCACHE_DIR }} |
| 77 | + key: ${{ runner.os }}-openxr-sccache-${{ github.sha }} |
| 78 | + restore-keys: ${{ runner.os }}-openxr-sccache- |
| 79 | + |
| 80 | + - name: Cache Vulkan SDK (Windows) |
| 81 | + if: runner.os == 'Windows' |
| 82 | + id: cache-vulkan-windows |
| 83 | + uses: actions/cache@v4 |
| 84 | + with: |
| 85 | + path: C:\VulkanSDK |
| 86 | + key: ${{ runner.os }}-vulkan-sdk |
| 87 | + |
| 88 | + - name: Install Vulkan SDK (Windows) |
| 89 | + if: runner.os == 'Windows' |
| 90 | + shell: pwsh |
| 91 | + run: | |
| 92 | + $ErrorActionPreference = 'Stop' |
| 93 | + if ("${{ steps.cache-vulkan-windows.outputs.cache-hit }}" -ne "true") { |
| 94 | + choco install -y aria2 |
| 95 | + $installer = Join-Path $env:TEMP "vulkan-sdk.exe" |
| 96 | + aria2c --split=8 --max-connection-per-server=8 --min-split-size=1M --dir="$env:TEMP" --out="vulkan-sdk.exe" "https://sdk.lunarg.com/sdk/download/latest/windows/vulkan-sdk.exe" |
| 97 | + Start-Process -FilePath $installer -ArgumentList "--accept-licenses --default-answer --confirm-command install" -Wait -NoNewWindow |
| 98 | + } |
| 99 | + $vulkanPath = Get-ChildItem "C:\VulkanSDK" | Sort-Object -Property Name -Descending | Select-Object -First 1 -ExpandProperty FullName |
| 100 | + "VULKAN_SDK=$vulkanPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
| 101 | + "$vulkanPath\Bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append |
| 102 | + "CMAKE_PREFIX_PATH=$vulkanPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
| 103 | + |
| 104 | + - name: Install Vulkan SDK (Linux) |
| 105 | + if: runner.os == 'Linux' |
| 106 | + shell: bash |
| 107 | + run: | |
| 108 | + set -euo pipefail |
| 109 | + sudo apt-get update |
| 110 | + sudo apt-get install -y curl xz-utils |
| 111 | + VULKAN_VERSION=$(curl -s https://vulkan.lunarg.com/sdk/latest/linux.txt) |
| 112 | + SDK_TGZ="${RUNNER_TEMP}/vulkansdk-linux.tar.xz" |
| 113 | + curl -L -o "$SDK_TGZ" "https://sdk.lunarg.com/sdk/download/$VULKAN_VERSION/linux/vulkansdk-linux-x86_64-$VULKAN_VERSION.tar.xz" |
| 114 | + mkdir -p "${RUNNER_TEMP}/VulkanSDK" |
| 115 | + tar -xJf "$SDK_TGZ" -C "${RUNNER_TEMP}/VulkanSDK" |
| 116 | + VULKAN_SDK_PATH=$(find "${RUNNER_TEMP}/VulkanSDK" -maxdepth 1 -type d -name '1.*' | head -n 1) |
| 117 | + SDK_SYSROOT="$VULKAN_SDK_PATH/x86_64" |
| 118 | + echo "VULKAN_SDK=$VULKAN_SDK_PATH" >> "$GITHUB_ENV" |
| 119 | + echo "VULKAN_SDK_SYSROOT=$SDK_SYSROOT" >> "$GITHUB_ENV" |
| 120 | + echo "$SDK_SYSROOT/bin" >> "$GITHUB_PATH" |
| 121 | + echo "CMAKE_PREFIX_PATH=$SDK_SYSROOT" >> "$GITHUB_ENV" |
| 122 | + echo "Vulkan_INCLUDE_DIR=$SDK_SYSROOT/include" >> "$GITHUB_ENV" |
| 123 | + |
| 124 | + - name: Bootstrap vcpkg (Windows) |
| 125 | + if: runner.os == 'Windows' |
| 126 | + shell: pwsh |
| 127 | + run: | |
| 128 | + $vcpkgRoot = Join-Path $env:RUNNER_TEMP "vcpkg" |
| 129 | + if (-not (Test-Path $vcpkgRoot)) { |
| 130 | + git clone https://github.com/microsoft/vcpkg $vcpkgRoot |
| 131 | + } |
| 132 | + Push-Location $vcpkgRoot |
| 133 | + .\bootstrap-vcpkg.bat |
| 134 | + Pop-Location |
| 135 | + "VCPKG_INSTALLATION_ROOT=$vcpkgRoot" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
| 136 | + "CMAKE_TOOLCHAIN_FILE=$vcpkgRoot\scripts\buildsystems\vcpkg.cmake" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
| 137 | + |
| 138 | + - name: Install dependencies (Windows) |
| 139 | + if: runner.os == 'Windows' |
| 140 | + shell: cmd |
| 141 | + run: | |
| 142 | + call install_dependencies_windows.bat |
| 143 | + |
| 144 | + - name: Install dependencies (Linux) |
| 145 | + if: runner.os == 'Linux' |
| 146 | + shell: bash |
| 147 | + run: | |
| 148 | + bash install_dependencies_linux.sh |
| 149 | + |
| 150 | + - name: Configure (Windows) |
| 151 | + if: runner.os == 'Windows' |
| 152 | + run: | |
| 153 | + cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="$env:CMAKE_TOOLCHAIN_FILE" -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_C_COMPILER_LAUNCHER=sccache |
| 154 | + |
| 155 | + - name: Configure (Linux) |
| 156 | + if: runner.os == 'Linux' |
| 157 | + run: | |
| 158 | + cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_PREFIX_PATH="/home/runner/.local;${{ env.VULKAN_SDK_SYSROOT }}" |
| 159 | + |
| 160 | + - name: Build |
| 161 | + run: cmake --build build --target OpenXREngine --parallel 4 |
0 commit comments