@@ -13,38 +13,40 @@ jobs:
1313 steps :
1414 - uses : actions/checkout@v4
1515
16- - name : Check Formatting
16+ - name : Find vcvars64.bat
1717 run : |
1818 $vcvars64 = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere" -latest -find VC\Auxiliary\Build\vcvars64.bat
1919 if (!$vcvars64) { exit 1 }
2020 Write-Host "Using vcvars64: ${vcvars64}"
21+ Add-Content $env:GITHUB_ENV "vcvars64=$vcvars64"
2122
22- # We need environment variables from running a batch file, but are running pwsh, so they would all be lost when cmd exits. We
23- # circumvent this problem by launching a fresh pwsh process after the batch file runs so execution continues with them set.
24- cmd "/k" '"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" & pwsh'
25-
26- & .\find_clang_format.cmd
27- if ($LASTEXITCODE -ne 0) {
28- exit $LASTEXITCODE
29- }
30-
31- & git clang-format origin/master --binary "$env:CLANG_FORMAT" --style file -- cppwinrt/*.h cppwinrt/*.cpp fast_fwd/*.h fast_fwd/*.cpp prebuild/*.h prebuild/*.cpp scratch/*.h scratch/*.cpp strings/*.h strings/*.cpp test/*.h test/*.cpp vsix/*.h vsix/*.cpp
32-
33- if ($LASTEXITCODE -ne 0) {
34- Write-Host ::error ERROR: This branch contains changes that have not been formatted with `'clang-format`'
35- Write-Host NOTE: To resolve this issue, you can run `'clang-format`' in the following ways:
36- Write-Host * Run ``build_test_all.cmd`` which will run `'clang-format`' on _all_ source files. This script is
37- Write-Host simpler to run, however there`'s a chance it may touch additional files you never changed due to you having
38- Write-Host a mis-matched version of `'clang-format`'. This may require you to manually revert changes made by
39- Write-Host `'clang-format`' to the locations where you made no code changes.
40- Write-Host
41- Write-Host For more information, please see https://github.com/microsoft/cppwinrt?tab=readme-ov-file#formatting
42- Write-Host
43- Write-Host NOTE: As an additional note, given that different versions of `'clang-format`' may have different behaviors, this
44- Write-Host may be a false positive. If you believe that to be the case ^`(e.g. none of the above resulted in modifications
45- Write-Host to the code you have changed^`), please note this in your PR.
46- exit 1
47- }
23+ - name : Check Formatting
24+ shell : cmd
25+ run : |
26+ call "%vcvars64%"
27+
28+ call .\find_clang_format.cmd
29+ if %ERRORLEVEL% neq 0 (
30+ exit /b %ERRORLEVEL%
31+ )
32+
33+ git clang-format origin/master --binary "%CLANG_FORMAT%" --style file -- cppwinrt/*.h cppwinrt/*.cpp fast_fwd/*.h fast_fwd/*.cpp prebuild/*.h prebuild/*.cpp scratch/*.h scratch/*.cpp strings/*.h strings/*.cpp test/*.h test/*.cpp vsix/*.h vsix/*.cpp
34+
35+ if %ERRORLEVEL% neq 0 (
36+ echo ::error ERROR: This branch contains changes that have not been formatted with 'clang-format'
37+ echo NOTE: To resolve this issue, you can run 'clang-format' in the following ways:
38+ echo * Run build_test_all.cmd which will run 'clang-format' on _all_ source files. This script is
39+ echo simpler to run, however there's a chance it may touch additional files you never changed due to you having
40+ echo a mis-matched version of 'clang-format'. This may require you to manually revert changes made by
41+ echo 'clang-format' to the locations where you made no code changes.
42+ echo.
43+ echo For more information, please see https://github.com/microsoft/cppwinrt?tab=readme-ov-file#formatting
44+ echo.
45+ echo NOTE: As an additional note, given that different versions of 'clang-format' may have different behaviors, this
46+ echo may be a false positive. If you believe that to be the case ^(e.g. none of the above resulted in modifications
47+ echo to the code you have changed^), please note this in your PR.
48+ exit /b 1
49+ )
4850
4951 test-msvc-cppwinrt-build :
5052 name : ' ${{ matrix.compiler }}: Build (${{ matrix.arch }}, ${{ matrix.config }})'
0 commit comments