-
Notifications
You must be signed in to change notification settings - Fork 239
404 lines (355 loc) · 15.5 KB
/
ci.yml
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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
name: CI Tests
on:
pull_request:
push:
branches:
- master
jobs:
test-msvc-cppwinrt-build:
name: '${{ matrix.compiler }}: Build (${{ matrix.arch }}, ${{ matrix.config }})'
strategy:
matrix:
compiler: [MSVC, clang-cl]
arch: [x86, x64, arm64]
config: [Debug, Release]
exclude:
- arch: arm64
config: Debug
- compiler: clang-cl
arch: arm64
- compiler: clang-cl
config: Release
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- id: setup-llvm
name: Set up LLVM (MSVC)
uses: ./.github/actions/setup-llvm-msvc
if: matrix.compiler == 'clang-cl'
- name: Download nuget
run: |
mkdir ".\.nuget"
Invoke-WebRequest "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -OutFile ".\.nuget\nuget.exe"
- name: Find VsDevCmd.bat
run: |
$VSDevCmd = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere" -latest -find Common7\tools\VSDevCmd.bat
if (!$VSDevCmd) { exit 1 }
echo "Using VSDevCmd: ${VSDevCmd}"
Add-Content $env:GITHUB_ENV "VSDevCmd=$VSDevCmd"
- name: Prepare build flags
run: |
$target_configuration = "${{ matrix.config }}"
$target_platform = "${{ matrix.arch }}"
$target_version = "1.2.3.4"
$props = "Configuration=$target_configuration,Platform=$target_platform,CppWinRTBuildVersion=$target_version"
if ("${{ matrix.compiler }}" -eq "clang-cl") {
$props += ",Clang=1,PlatformToolset=LLVM_v143,LLVMInstallDir=${{ steps.setup-llvm.outputs.llvm-path }}"
}
Add-Content $env:GITHUB_ENV "msbuild_config_props=/p:$props"
- name: Restore nuget packages
run: |
cmd /c "$env:VSDevCmd" "&" nuget restore cppwinrt.sln
- name: Build fast_fwd
run: |
cmd /c "$env:VSDevCmd" "&" msbuild /m /clp:ForceConsoleColor "$env:msbuild_config_props" cppwinrt.sln /t:fast_fwd
- name: Build x86 prebuild tool
if: matrix.arch == 'arm64'
run: |
cmd /c "$env:VSDevCmd" "&" msbuild /m /clp:ForceConsoleColor "$env:msbuild_config_props" /p:Platform=x86 cppwinrt.sln /t:cppwinrt
- name: Build cppwinrt
run: |
cmd /c "$env:VSDevCmd" "&" msbuild /m /clp:ForceConsoleColor "$env:msbuild_config_props" cppwinrt.sln /t:cppwinrt
- name: Upload built executables
uses: actions/upload-artifact@v4
with:
name: msvc-build-${{ matrix.compiler}}-${{ matrix.arch }}-${{ matrix.config }}-bin
path: |
_build/${{ matrix.arch }}/${{ matrix.config }}/*.exe
_build/${{ matrix.arch }}/${{ matrix.config }}/*.dll
_build/${{ matrix.arch }}/${{ matrix.config }}/*.winmd
_build/${{ matrix.arch }}/${{ matrix.config }}/*.lib
_build/${{ matrix.arch }}/${{ matrix.config }}/*.pdb
- name: Run cppwinrt to build projection
if: matrix.arch != 'arm64'
run: |
$target_configuration = "${{ matrix.config }}"
$target_platform = "${{ matrix.arch }}"
& "_build\$target_platform\$target_configuration\cppwinrt.exe" -in local -out _build\$target_platform\$target_configuration -verbose
test-msvc-cppwinrt-test:
name: '${{ matrix.compiler }}: Test [${{ matrix.test_exe }}] (${{ matrix.arch }}, ${{ matrix.config }})'
needs: test-msvc-cppwinrt-build
strategy:
fail-fast: false
matrix:
compiler: [MSVC, clang-cl]
arch: [x86, x64, arm64]
config: [Debug, Release]
test_exe: [test, test_cpp20, test_cpp20_no_sourcelocation, test_fast, test_slow, test_old, test_module_lock_custom, test_module_lock_none]
exclude:
- arch: arm64
config: Debug
- compiler: clang-cl
arch: arm64
- compiler: clang-cl
config: Release
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- id: setup-llvm
name: Set up LLVM (MSVC)
uses: ./.github/actions/setup-llvm-msvc
if: matrix.compiler == 'clang-cl'
- name: Fetch cppwinrt executables
if: matrix.arch != 'arm64'
uses: actions/download-artifact@v4
with:
name: msvc-build-${{ matrix.compiler}}-${{ matrix.arch }}-${{ matrix.config }}-bin
path: _build/${{ matrix.arch }}/${{ matrix.config }}/
- name: Fetch x86 cppwinrt executables (arm64 only)
if: matrix.arch == 'arm64'
uses: actions/download-artifact@v4
with:
name: msvc-build-${{ matrix.compiler}}-x86-Release-bin
path: _build/x86/Release/
- name: Download nuget
run: |
mkdir ".\.nuget"
Invoke-WebRequest "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -OutFile ".\.nuget\nuget.exe"
- name: Find VsDevCmd.bat
run: |
$VSDevCmd = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere" -latest -find Common7\tools\VSDevCmd.bat
if (!$VSDevCmd) { exit 1 }
echo "Using VSDevCmd: ${VSDevCmd}"
Add-Content $env:GITHUB_ENV "VSDevCmd=$VSDevCmd"
- name: Prepare build flags
run: |
$target_configuration = "${{ matrix.config }}"
$target_platform = "${{ matrix.arch }}"
$target_version = "1.2.3.4"
$props = "Configuration=$target_configuration,Platform=$target_platform,CppWinRTBuildVersion=$target_version"
if ("${{ matrix.compiler }}" -eq "clang-cl") {
$props += ",Clang=1,PlatformToolset=LLVM_v143,LLVMInstallDir=${{ steps.setup-llvm.outputs.llvm-path }}"
}
Add-Content $env:GITHUB_ENV "msbuild_config_props=/p:$props"
- name: Restore nuget packages
run: |
cmd /c "$env:VSDevCmd" "&" nuget restore cppwinrt.sln
- name: Remove cppwinrt dependency from all test projects
run: |
# HACK: We already have a built exe, so we want to avoid rebuilding cppwinrt
mv cppwinrt.sln cppwinrt.sln.orig
Get-Content cppwinrt.sln.orig |
Where-Object { -not $_.Contains("{D613FB39-5035-4043-91E2-BAB323908AF4} = {D613FB39-5035-4043-91E2-BAB323908AF4}") } |
Set-Content cppwinrt.sln
- name: Patch catch.hpp to make it build with ANSI colour
run: |
# HACK: Remove <unistd.h> include and the isatty call in catch.hpp to make ANSI colour build work
mv test/catch.hpp test/catch.hpp.orig
Get-Content test/catch.hpp.orig |
Where-Object { -not $_.Contains("#include <unistd.h>") } |
ForEach-Object {
$_.Replace("isatty(STDOUT_FILENO)", "false")
} |
Set-Content test/catch.hpp
- name: Run cppwinrt to build projection
run: |
$target_configuration = "${{ matrix.config }}"
$target_platform = "${{ matrix.arch }}"
$cppwinrt_path = "_build\$target_platform\$target_configuration\cppwinrt.exe"
if ($target_platform -eq "arm64") {
$cppwinrt_path = "_build\x86\Release\cppwinrt.exe"
}
& $cppwinrt_path -in local -out _build\$target_platform\$target_configuration -verbose
- name: Build test '${{ matrix.test_exe }}'
run: |
$test_proj = "${{ matrix.test_exe }}"
if ($test_proj -eq "test_old") {
$test_proj = "old_tests\test_old"
}
cmd /c "$env:VSDevCmd" "&" msbuild /m /clp:ForceConsoleColor /p:TestsUseAnsiColor=1 "$env:msbuild_config_props" cppwinrt.sln /t:test\$test_proj
- name: Run tests in '${{ matrix.test_exe }}' one by one
if: matrix.compiler == 'clang-cl'
run: |
$target_configuration = "${{ matrix.config }}"
$target_platform = "${{ matrix.arch }}"
$test_exe = "${{ matrix.test_exe }}"
$test_path = "_build\$target_platform\$target_configuration\$test_exe.exe"
if (!(Test-Path $test_path)) {
echo "::error::Test $test_exe is missing."
exit 1
}
$test_names = @( & $test_path --list-test-names-only )
$failed_tests = 0
foreach ($test_name in $test_names) {
echo "::group::Running test $test_name"
$escaped = $test_name.Replace("\", "\\").Replace(",", "\,").Replace("[", "\[")
& $test_path --use-colour yes --warn NoTests "$escaped"
echo "::endgroup::"
if ($LastExitCode -ne 0) {
$failed_tests += 1
# Add a newline in case test exited abnormally without newline
echo ""
echo "::error::Test $test_exe/'$test_name' failed with exit code $LastExitCode!"
}
}
if ($failed_tests -eq 0) {
echo "All tests in $test_exe passed."
} else {
echo "$failed_tests failed in $test_exe."
exit 1
}
- name: Run test '${{ matrix.test_exe }}'
if: matrix.arch != 'arm64'
run: |
$target_configuration = "${{ matrix.config }}"
$target_platform = "${{ matrix.arch }}"
$test_exe = "${{ matrix.test_exe }}"
$test_path = "_build\$target_platform\$target_configuration\$test_exe.exe"
if (!(Test-Path $test_path)) {
echo "::error::Test $test_exe is missing."
exit 1
}
& $test_path --use-colour yes
- name: Upload arm64 test executables
if: matrix.arch == 'arm64'
uses: actions/upload-artifact@v4
with:
name: msvc-tests-${{ matrix.test_exe }}-${{ matrix.compiler }}-${{ matrix.arch }}-${{ matrix.config }}-bin
path: |
_build/${{ matrix.arch }}/${{ matrix.config }}/*.exe
_build/${{ matrix.arch }}/${{ matrix.config }}/*.dll
_build/${{ matrix.arch }}/${{ matrix.config }}/*.winmd
_build/${{ matrix.arch }}/${{ matrix.config }}/*.lib
_build/${{ matrix.arch }}/${{ matrix.config }}/*.pdb
build-linux-cross-cppwinrt:
name: 'cross: Cross-build from Linux'
strategy:
matrix:
arch: [i686, x86_64]
runs-on: ubuntu-22.04
env:
CMAKE_COLOR_DIAGNOSTICS: 1
CLICOLOR_FORCE: 1
steps:
- uses: actions/checkout@v4
- name: Install cross compiler
run: |
arch=${{ matrix.arch }}
sudo apt-get install g++-mingw-w64-${arch/_/-}
sudo update-alternatives --set "${{ matrix.arch }}-w64-mingw32-gcc" "/usr/bin/${{ matrix.arch }}-w64-mingw32-gcc-posix"
sudo update-alternatives --set "${{ matrix.arch }}-w64-mingw32-g++" "/usr/bin/${{ matrix.arch }}-w64-mingw32-g++-posix"
- name: Cross-build cppwinrt
run: |
cmake -S . -B build/cross_x64/ --toolchain cross-mingw-toolchain.cmake \
-DCMAKE_SYSTEM_PROCESSOR=${{ matrix.arch }} \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_CXX_FLAGS="-static" \
-DCMAKE_INSTALL_PREFIX=$PWD/install/
cmake --build build/cross_x64/ --target install -j2
- name: Upload cppwinrt.exe
uses: actions/upload-artifact@v4
with:
name: cross-build-${{ matrix.arch }}-bin
path: install/bin/cppwinrt.exe
build-msvc-natvis:
name: 'Build natvis'
strategy:
matrix:
arch: [x86, x64, arm64]
config: [Release]
Deployment: [Component, Standalone]
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Download nuget
run: |
mkdir ".\.nuget"
Invoke-WebRequest "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -OutFile ".\.nuget\nuget.exe"
- name: Find VsDevCmd.bat
run: |
$VSDevCmd = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere" -latest -find Common7\tools\VSDevCmd.bat
if (!$VSDevCmd) { exit 1 }
echo "Using VSDevCmd: ${VSDevCmd}"
Add-Content $env:GITHUB_ENV "VSDevCmd=$VSDevCmd"
- name: Prepare build flags
run: |
$target_configuration = "${{ matrix.config }}"
$target_platform = "${{ matrix.arch }}"
$target_version = "1.2.3.4"
Add-Content $env:GITHUB_ENV "msbuild_config_props=/p:Configuration=$target_configuration,Platform=$target_platform,CppWinRTBuildVersion=$target_version"
- name: Restore nuget packages
run: |
cmd /c "$env:VSDevCmd" "&" nuget restore natvis\cppwinrtvisualizer.sln
- name: Build natvis
run: |
cmd /c "$env:VSDevCmd" "&" msbuild /m /clp:ForceConsoleColor "$env:msbuild_config_props" /p:Deployment=${{ matrix.Deployment }} natvis\cppwinrtvisualizer.sln
build-msvc-nuget-test:
name: 'Build nuget test (${{ matrix.arch }})'
needs: test-msvc-cppwinrt-build
strategy:
matrix:
compiler:
- MSVC
arch: [x86, x64]
config: [Release]
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Fetch cppwinrt executables
uses: actions/download-artifact@v4
with:
name: msvc-build-${{ matrix.compiler}}-${{ matrix.arch }}-${{ matrix.config }}-bin
path: _build/${{ matrix.arch }}/${{ matrix.config }}/
- name: Download nuget
run: |
mkdir ".\.nuget"
Invoke-WebRequest "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -OutFile ".\.nuget\nuget.exe"
- name: Find VsDevCmd.bat
run: |
$VSDevCmd = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere" -latest -find Common7\tools\VSDevCmd.bat
if (!$VSDevCmd) { exit 1 }
echo "Using VSDevCmd: ${VSDevCmd}"
Add-Content $env:GITHUB_ENV "VSDevCmd=$VSDevCmd"
- name: Prepare build flags
run: |
$target_configuration = "${{ matrix.config }}"
$target_platform = "${{ matrix.arch }}"
$target_version = "1.2.3.4"
Add-Content $env:GITHUB_ENV "msbuild_config_props=/p:Configuration=$target_configuration,Platform=$target_platform,CppWinRTBuildVersion=$target_version"
- name: Restore nuget packages
run: |
cmd /c "$env:VSDevCmd" "&" nuget restore test\nuget\NugetTest.sln
- name: Run cppwinrt to build projection
run: |
$target_configuration = "${{ matrix.config }}"
$target_platform = "${{ matrix.arch }}"
& "_build\$target_platform\$target_configuration\cppwinrt.exe" -in local -out _build\$target_platform\$target_configuration -verbose
- name: Run nuget test
run: |
cmd /c "$env:VSDevCmd" "&" msbuild /m /clp:ForceConsoleColor "$env:msbuild_config_props" test\nuget\NugetTest.sln
if ($LastExitCode -ne 0) {
echo "::warning::nuget test failed"
}
# FIXME: This build was failing from the start
exit 0
build-nuget:
name: Build nuget package with MSVC
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Package
run: |
$VSDevCmd = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere" -latest -find Common7\tools\VSDevCmd.bat
if (!$VSDevCmd) { exit 1 }
echo "Using VSDevCmd: ${VSDevCmd}"
cmd /c "${VSDevCmd}" "&" nuget.exe restore cppwinrt.sln
cmd /c "${VSDevCmd}" "&" build_nuget.cmd
if (!(Test-Path "*.nupkg")) {
echo "::error::Output nuget package not found!"
exit 1
}
- name: Upload nuget package artifact
uses: actions/upload-artifact@v4
with:
name: package
path: "*.nupkg"