-
Notifications
You must be signed in to change notification settings - Fork 86
244 lines (214 loc) · 9.23 KB
/
workflow.yml
File metadata and controls
244 lines (214 loc) · 9.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
name: CMake CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
include:
- os: ubuntu-latest
vulkan-install: |
# Download and install Vulkan SDK using the tar.gz method
VULKAN_VERSION=$(curl -s https://vulkan.lunarg.com/sdk/latest/linux.txt)
echo "Using Vulkan SDK version: $VULKAN_VERSION"
# Create a temporary directory for the SDK
mkdir -p vulkan-sdk
cd vulkan-sdk
# Download the SDK
curl -O "https://sdk.lunarg.com/sdk/download/$VULKAN_VERSION/linux/vulkansdk-linux-x86_64-$VULKAN_VERSION.tar.gz"
# Extract the SDK
tar -xzf vulkansdk-linux-x86_64-$VULKAN_VERSION.tar.gz
# Set up environment variables
echo "VULKAN_SDK=$PWD/$VULKAN_VERSION/x86_64" >> $GITHUB_ENV
echo "PATH=$PWD/$VULKAN_VERSION/x86_64/bin:$PATH" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$PWD/$VULKAN_VERSION/x86_64/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
echo "VK_LAYER_PATH=$PWD/$VULKAN_VERSION/x86_64/etc/vulkan/explicit_layer.d" >> $GITHUB_ENV
# Return to the original directory
cd ..
deps-install: |
# GitHub runners already have cmake, ninja-build, and clang installed
sudo apt-get update
sudo apt-get install -y \
libglfw3-dev \
libglm-dev \
libtinyobjloader-dev \
libstb-dev
test-cmd: |
# Check if some of the expected executables were built
if [ -f "00_base_code/00_base_code" ]; then
echo "00_base_code built successfully"
else
echo "00_base_code build failed"
exit 1
fi
if [ -f "15_hello_triangle/15_hello_triangle" ]; then
echo "15_hello_triangle built successfully"
else
echo "15_hello_triangle build failed"
exit 1
fi
if [ -f "31_compute_shader/31_compute_shader" ]; then
echo "31_compute_shader built successfully"
else
echo "31_compute_shader build failed"
exit 1
fi
- os: windows-latest
vulkan-install: |
# Install Vulkan SDK using Chocolatey (pre-installed on GitHub runners)
choco install vulkan-sdk -y
# Set environment variables
$vulkanPath = "C:\VulkanSDK\latest"
echo "VULKAN_SDK=$vulkanPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "$vulkanPath\Bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "CMAKE_PREFIX_PATH=$vulkanPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "Vulkan_INCLUDE_DIR=$vulkanPath\Include" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "Vulkan_LIBRARY=$vulkanPath\Lib\vulkan-1.lib" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
deps-install: |
vcpkg install glfw3:x64-windows glm:x64-windows tinyobjloader:x64-windows stb:x64-windows
echo "CMAKE_TOOLCHAIN_FILE=$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" >> $env:GITHUB_ENV
test-cmd: |
# Check if some of the expected executables were built
if (Test-Path "00_base_code/Release/00_base_code.exe") {
echo "00_base_code built successfully"
} else {
echo "00_base_code build failed"
exit 1
}
if (Test-Path "15_hello_triangle/Release/15_hello_triangle.exe") {
echo "15_hello_triangle built successfully"
} else {
echo "15_hello_triangle build failed"
exit 1
}
if (Test-Path "31_compute_shader/Release/31_compute_shader.exe") {
echo "31_compute_shader built successfully"
} else {
echo "31_compute_shader build failed"
exit 1
}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
# Cache vcpkg packages for Windows
- name: Cache vcpkg packages (Windows)
if: runner.os == 'Windows'
uses: actions/cache@v3
with:
path: |
${{ env.VCPKG_INSTALLATION_ROOT }}/installed
${{ env.VCPKG_INSTALLATION_ROOT }}/packages
${{ env.VCPKG_INSTALLATION_ROOT }}/buildtrees
key: ${{ runner.os }}-vcpkg-${{ hashFiles('**/CMakeLists.txt') }}-${{ hashFiles('**/*.cpp') }}
restore-keys: |
${{ runner.os }}-vcpkg-${{ hashFiles('**/CMakeLists.txt') }}-
${{ runner.os }}-vcpkg-
# Cache Vulkan SDK for Windows
- name: Cache Vulkan SDK (Windows)
if: runner.os == 'Windows'
uses: actions/cache@v3
with:
path: C:\VulkanSDK
key: ${{ runner.os }}-vulkan-sdk-${{ hashFiles('**/CMakeLists.txt') }}
restore-keys: |
${{ runner.os }}-vulkan-sdk-
# Cache apt packages for Ubuntu
- name: Cache apt packages (Ubuntu)
if: runner.os == 'Linux'
uses: actions/cache@v3
with:
path: /var/cache/apt/archives
key: ${{ runner.os }}-apt-${{ hashFiles('**/workflow.yml') }}
restore-keys: |
${{ runner.os }}-apt-
# Cache Vulkan SDK for Ubuntu
- name: Cache Vulkan SDK (Ubuntu)
if: runner.os == 'Linux'
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/vulkan-sdk
key: ${{ runner.os }}-vulkan-sdk-${{ hashFiles('**/CMakeLists.txt') }}-${{ hashFiles('**/*.cpp') }}
restore-keys: |
${{ runner.os }}-vulkan-sdk-${{ hashFiles('**/CMakeLists.txt') }}-
${{ runner.os }}-vulkan-sdk-
- name: Install dependencies
run: ${{ matrix.deps-install }}
- name: Install Vulkan SDK
run: ${{ matrix.vulkan-install }}
- name: Verify Vulkan Installation (Windows)
if: runner.os == 'Windows'
run: |
if (Test-Path $env:VULKAN_SDK) {
echo "Vulkan SDK found at: $env:VULKAN_SDK"
echo "Vulkan SDK installation verified"
} else {
echo "Vulkan SDK not found!"
exit 1
}
# Cache CMake build directory for Windows
- name: Cache build artifacts (Windows)
if: runner.os == 'Windows'
uses: actions/cache@v3
with:
path: ${{github.workspace}}/attachments/build
key: ${{ runner.os }}-build-${{ hashFiles('**/CMakeLists.txt') }}-${{ hashFiles('**/*.cpp') }}-${{ hashFiles('**/*.h') }}
restore-keys: |
${{ runner.os }}-build-${{ hashFiles('**/CMakeLists.txt') }}-
${{ runner.os }}-build-
- name: Configure CMake (Windows)
working-directory: ${{github.workspace}}/attachments
if: runner.os == 'Windows'
run: |
cmake -B build -DCMAKE_BUILD_TYPE=Release `
-DVulkan_INCLUDE_DIR="$env:Vulkan_INCLUDE_DIR" `
-DVulkan_LIBRARY="$env:Vulkan_LIBRARY" `
-DCMAKE_PREFIX_PATH="$env:VULKAN_SDK" `
-DCMAKE_TOOLCHAIN_FILE="$env:CMAKE_TOOLCHAIN_FILE"
# Display CMake cache to debug Vulkan detection
if (Test-Path "build/CMakeCache.txt") {
Write-Host "CMake cache contents:"
Get-Content "build/CMakeCache.txt" | Select-String -Pattern "Vulkan"
}
# Verify Vulkan Installation for Ubuntu
- name: Verify Vulkan Installation (Ubuntu)
if: runner.os == 'Linux'
run: |
if [ -d "$VULKAN_SDK" ]; then
echo "Vulkan SDK found at: $VULKAN_SDK"
echo "Vulkan SDK installation verified"
else
echo "Vulkan SDK not found!"
exit 1
fi
# Cache CMake build directory for Ubuntu
- name: Cache build artifacts (Ubuntu)
if: runner.os == 'Linux'
uses: actions/cache@v3
with:
path: ${{github.workspace}}/attachments/build
key: ${{ runner.os }}-build-${{ hashFiles('**/CMakeLists.txt') }}-${{ hashFiles('**/*.cpp') }}-${{ hashFiles('**/*.h') }}
restore-keys: |
${{ runner.os }}-build-${{ hashFiles('**/CMakeLists.txt') }}-
${{ runner.os }}-build-
- name: Configure CMake (Unix)
working-directory: ${{github.workspace}}/attachments
if: runner.os != 'Windows'
run: |
# Use Clang for better C++20 module support
export CC=clang
export CXX=clang++
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_SCAN_FOR_MODULES=ON \
-DCMAKE_CXX_FLAGS="-std=c++20"
- name: Build
working-directory: ${{github.workspace}}/attachments
run: cmake --build build --config Release
- name: Test Build Output
working-directory: ${{github.workspace}}/attachments/build
run: ${{ matrix.test-cmd }}