77
88jobs :
99 test-msvc-cppwinrt-build :
10- name : ' MSVC : Build'
10+ name : ' ${{ matrix.compiler }} : Build (${{ matrix.arch }}, ${{ matrix.config }}) '
1111 strategy :
1212 matrix :
13+ compiler : [MSVC, clang-cl]
1314 arch : [x86, x64, arm64]
1415 config : [Debug, Release]
1516 exclude :
1617 - arch : arm64
1718 config : Debug
19+ - compiler : clang-cl
20+ arch : arm64
21+ - compiler : clang-cl
22+ config : Release
1823 runs-on : windows-latest
1924 steps :
2025 - uses : actions/checkout@v3
2126
27+ - name : Install LLVM 15
28+ if : matrix.compiler == 'clang-cl'
29+ run : |
30+ Invoke-WebRequest "https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.2/LLVM-15.0.2-win64.exe" -OutFile LLVM-installer.exe
31+ .\LLVM-installer.exe /S "/D=$pwd\LLVM" | Out-Null
32+ rm LLVM-installer.exe
33+ if (!(Test-Path "$pwd\LLVM\bin\clang-cl.exe")) { exit 1 }
34+ Add-Content $env:GITHUB_PATH "$pwd\LLVM\bin"
35+
36+ - name : Set up LLVM build tools for msbuild
37+ if : matrix.compiler == 'clang-cl'
38+ # Not using the LLVM tools that comes with MSVC.
39+ run : |
40+ Invoke-WebRequest "https://github.com/zufuliu/llvm-utils/releases/download/v22.09/LLVM_VS2017.zip" -OutFile LLVM_VS2017.zip
41+ 7z x -y "LLVM_VS2017.zip" | Out-Null
42+ cmd /c "LLVM_VS2017\install.bat" 1
43+
2244 - name : Download nuget
2345 run : |
2446 mkdir ".\.nuget"
@@ -36,20 +58,24 @@ jobs:
3658 $target_configuration = "${{ matrix.config }}"
3759 $target_platform = "${{ matrix.arch }}"
3860 $target_version = "1.2.3.4"
39- Add-Content $env:GITHUB_ENV "msbuild_config_props=/p:Configuration=$target_configuration,Platform=$target_platform,CppWinRTBuildVersion=$target_version"
61+ $props = "Configuration=$target_configuration,Platform=$target_platform,CppWinRTBuildVersion=$target_version"
62+ if ("${{ matrix.compiler }}" -eq "clang-cl") {
63+ $props += ",Clang=1,PlatformToolset=LLVM_v143,LLVMInstallDir=$pwd\LLVM"
64+ }
65+ Add-Content $env:GITHUB_ENV "msbuild_config_props=/p:$props"
4066
4167 - name : Restore nuget packages
4268 run : |
4369 cmd /c "$env:VSDevCmd" "&" nuget restore cppwinrt.sln
4470
4571 - name : Build fast_fwd
4672 run : |
47- cmd /c "$env:VSDevCmd" "&" msbuild /m "$env:msbuild_config_props" cppwinrt.sln /t:fast_fwd
73+ cmd /c "$env:VSDevCmd" "&" msbuild /m /clp:ForceConsoleColor "$env:msbuild_config_props" cppwinrt.sln /t:fast_fwd
4874
4975 - name : Build cppwinrt
5076 if : matrix.arch != 'arm64'
5177 run : |
52- cmd /c "$env:VSDevCmd" "&" msbuild /m "$env:msbuild_config_props" cppwinrt.sln /t:cppwinrt
78+ cmd /c "$env:VSDevCmd" "&" msbuild /m /clp:ForceConsoleColor "$env:msbuild_config_props" cppwinrt.sln /t:cppwinrt
5379
5480 - name : Upload built executables
5581 if : matrix.arch != 'arm64'
@@ -71,18 +97,39 @@ jobs:
7197 & "_build\$target_platform\$target_configuration\cppwinrt.exe" -in local -out _build\$target_platform\$target_configuration -verbose
7298
7399 test-msvc-cppwinrt-test :
74- name : ' MSVC: Tests '
100+ name : ' ${{ matrix.compiler }}: Test [${{ matrix.test_exe }}] (${{ matrix.arch }}, ${{ matrix.config }}) '
75101 needs : test-msvc-cppwinrt-build
76102 strategy :
77103 fail-fast : false
78104 matrix :
105+ compiler : [MSVC, clang-cl]
79106 arch : [x86, x64]
80107 config : [Debug, Release]
81108 test_exe : [test, test_cpp20, test_win7, test_fast, test_slow, test_old, test_module_lock_custom, test_module_lock_none]
109+ exclude :
110+ - compiler : clang-cl
111+ config : Release
82112 runs-on : windows-latest
83113 steps :
84114 - uses : actions/checkout@v3
85115
116+ - name : Install LLVM 15
117+ if : matrix.compiler == 'clang-cl'
118+ run : |
119+ Invoke-WebRequest "https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.2/LLVM-15.0.2-win64.exe" -OutFile LLVM-installer.exe
120+ .\LLVM-installer.exe /S "/D=$pwd\LLVM" | Out-Null
121+ rm LLVM-installer.exe
122+ if (!(Test-Path "$pwd\LLVM\bin\clang-cl.exe")) { exit 1 }
123+ Add-Content $env:GITHUB_PATH "$pwd\LLVM\bin"
124+
125+ - name : Set up LLVM build tools for msbuild
126+ if : matrix.compiler == 'clang-cl'
127+ run : |
128+ # Not using the LLVM tools that comes with MSVC.
129+ Invoke-WebRequest "https://github.com/zufuliu/llvm-utils/releases/download/v22.09/LLVM_VS2017.zip" -OutFile LLVM_VS2017.zip
130+ 7z x -y "LLVM_VS2017.zip" | Out-Null
131+ cmd /c "LLVM_VS2017\install.bat" 1
132+
86133 - name : Fetch cppwinrt executables
87134 uses : actions/download-artifact@v3
88135 with :
@@ -106,7 +153,11 @@ jobs:
106153 $target_configuration = "${{ matrix.config }}"
107154 $target_platform = "${{ matrix.arch }}"
108155 $target_version = "1.2.3.4"
109- Add-Content $env:GITHUB_ENV "msbuild_config_props=/p:Configuration=$target_configuration,Platform=$target_platform,CppWinRTBuildVersion=$target_version"
156+ $props = "Configuration=$target_configuration,Platform=$target_platform,CppWinRTBuildVersion=$target_version"
157+ if ("${{ matrix.compiler }}" -eq "clang-cl") {
158+ $props += ",Clang=1,PlatformToolset=LLVM_v143,LLVMInstallDir=$pwd\LLVM"
159+ }
160+ Add-Content $env:GITHUB_ENV "msbuild_config_props=/p:$props"
110161
111162 - name : Restore nuget packages
112163 run : |
@@ -144,7 +195,39 @@ jobs:
144195 $test_proj = "old_tests\test_old"
145196 }
146197
147- cmd /c "$env:VSDevCmd" "&" msbuild /m /p:TestsUseAnsiColor=1 "$env:msbuild_config_props" cppwinrt.sln /t:test\$test_proj
198+ cmd /c "$env:VSDevCmd" "&" msbuild /m /clp:ForceConsoleColor /p:TestsUseAnsiColor=1 "$env:msbuild_config_props" cppwinrt.sln /t:test\$test_proj
199+
200+ - name : Run tests in '${{ matrix.test_exe }}' one by one
201+ if : matrix.compiler == 'clang-cl'
202+ run : |
203+ $target_configuration = "${{ matrix.config }}"
204+ $target_platform = "${{ matrix.arch }}"
205+ $test_exe = "${{ matrix.test_exe }}"
206+ $test_path = "_build\$target_platform\$target_configuration\$test_exe.exe"
207+ if (!(Test-Path $test_path)) {
208+ echo "::error::Test $test_exe is missing."
209+ exit 1
210+ }
211+ $test_names = @( & $test_path --list-test-names-only )
212+ $failed_tests = 0
213+ foreach ($test_name in $test_names) {
214+ echo "::group::Running test $test_name"
215+ $escaped = $test_name.Replace("\", "\\").Replace(",", "\,").Replace("[", "\[")
216+ & $test_path --use-colour yes --warn NoTests "$escaped"
217+ echo "::endgroup::"
218+ if ($LastExitCode -ne 0) {
219+ $failed_tests += 1
220+ # Add a newline in case test exited abnormally without newline
221+ echo ""
222+ echo "::error::Test $test_exe/'$test_name' failed with exit code $LastExitCode!"
223+ }
224+ }
225+ if ($failed_tests -eq 0) {
226+ echo "All tests in $test_exe passed."
227+ } else {
228+ echo "$failed_tests failed in $test_exe."
229+ exit 1
230+ }
148231
149232 - name : Run test '${{ matrix.test_exe }}'
150233 run : |
@@ -194,7 +277,7 @@ jobs:
194277
195278 - name : Build natvis
196279 run : |
197- cmd /c "$env:VSDevCmd" "&" msbuild /m "$env:msbuild_config_props" /p:Deployment=${{ matrix.Deployment }} natvis\cppwinrtvisualizer.sln
280+ cmd /c "$env:VSDevCmd" "&" msbuild /m /clp:ForceConsoleColor "$env:msbuild_config_props" /p:Deployment=${{ matrix.Deployment }} natvis\cppwinrtvisualizer.sln
198281
199282 build-msvc-nuget-test :
200283 name : ' Build nuget test'
@@ -244,7 +327,7 @@ jobs:
244327
245328 - name : Run nuget test
246329 run : |
247- cmd /c "$env:VSDevCmd" "&" msbuild /m "$env:msbuild_config_props" test\nuget\NugetTest.sln
330+ cmd /c "$env:VSDevCmd" "&" msbuild /m /clp:ForceConsoleColor "$env:msbuild_config_props" test\nuget\NugetTest.sln
248331 if ($LastExitCode -ne 0) {
249332 echo "::warning::nuget test failed"
250333 }
0 commit comments