Skip to content

Commit 2c46e19

Browse files
authored
Merge pull request #3 from humbletim/windows-2022-test
improved Windows 2022 SDK detection and fallback support
2 parents 83fd8db + e87fcf2 commit 2c46e19

File tree

4 files changed

+56
-7
lines changed

4 files changed

+56
-7
lines changed

.github/workflows/ci.yml

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,45 @@
11
name: test vsdevenv-shell
22
on:
33
push:
4+
workflow_dispatch:
5+
inputs:
6+
extra_tests:
7+
description: 'Enable additional CI settings'
8+
required: false
9+
default: false
410
jobs:
511
test-vsdevenv-shell:
6-
runs-on: windows-latest
12+
strategy:
13+
matrix:
14+
os: [ windows-2019, windows-2022, ubuntu-latest, macOS-latest ]
15+
runs-on: ${{ matrix.os }}
716
steps:
17+
- name: set VISUAL_STUDIO_GENERATOR
18+
if: ${{ runner.os == 'Windows' }}
19+
shell: bash
20+
run: |
21+
if grep 2019 /c/imagedata.json ; then
22+
echo "VISUAL_STUDIO_GENERATOR=Visual Studio 16 2019" | tee -a $GITHUB_ENV
23+
else #if grep 2019 /c/imagedata.json ;
24+
echo "VISUAL_STUDIO_GENERATOR=Visual Studio 17 2022" | tee -a $GITHUB_ENV
25+
fi
826
- uses: actions/checkout@v2
927
- uses: ./
1028

29+
- name: Setup tmate session
30+
if: ${{ contains(github.event.inputs.extra_tests, format('tmate-{0}', runner.os)) }}
31+
uses: mxschmitt/[email protected]
32+
with:
33+
limit-access-to-actor: true
34+
1135
- name: an earlier build step
1236
shell: bash
1337
run: |
1438
echo "clean job environment (no dev tools)"
1539
echo "$(env | wc -l) environment variables defined"
1640
1741
- name: specific step (executed within vsdevcmd.bat environment)
42+
continue-on-error: ${{ runner.os != 'Windows' }}
1843
shell: vsdevenv x64 bash {0}
1944
run: |
2045
echo "$(env | wc -l) environment variables defined"
@@ -32,22 +57,27 @@ jobs:
3257
run: echo test 1 2 3
3358

3459
- name: Verify MSVC wrapper -- bash
60+
continue-on-error: ${{ runner.os != 'Windows' }}
3561
shell: vsdevenv x64 bash {0}
3662
run: cl
3763

3864
- name: Verify MSVC wrapper -- cmd
65+
continue-on-error: ${{ runner.os != 'Windows' }}
3966
shell: vsdevenv x86 cmd {0}
4067
run: cl
4168

4269
- name: Verify MSVC wrapper -- powershell
70+
continue-on-error: ${{ runner.os != 'Windows' }}
4371
shell: vsdevenv arm64 powershell {0}
4472
run: cl
4573

4674
- name: Verify MSVC wrapper -- pwsh
75+
continue-on-error: ${{ runner.os != 'Windows' }}
4776
shell: vsdevenv arm64 pwsh {0}
4877
run: cl
4978

5079
- name: cmake test -- vsdevenv x64 cmd
80+
continue-on-error: ${{ runner.os != 'Windows' }}
5181
shell: vsdevenv x64 cmd {0}
5282
run: |
5383
cmake -G "NMake Makefiles" -B tests\build-x64 -S tests -DCMAKE_BUILD_TYPE=Release -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=. || exit /b %errorlevel%
@@ -56,14 +86,16 @@ jobs:
5686
tests\build-x64\helloworld.exe 1 2 3 4
5787
5888
- name: cmake test -- vsdevenv x64 bash -A x64
89+
continue-on-error: ${{ runner.os != 'Windows' }}
5990
shell: vsdevenv x64 bash {0}
6091
run: |
61-
cmake -A x64 -G "Visual Studio 16 2019" -B tests/build-Ax64 -S tests -DCMAKE_BUILD_TYPE=Release -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=.
92+
cmake -A x64 -G "$VISUAL_STUDIO_GENERATOR" -B tests/build-Ax64 -S tests -DCMAKE_BUILD_TYPE=Release -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=.
6293
cmake --build tests/build-Ax64 --config release
6394
ls -l tests/build-Ax64/helloworld.exe
6495
./tests/build-Ax64/helloworld.exe 1 2 3 4
6596
6697
- name: cmake test -- vsdevenv x86 powershell
98+
continue-on-error: ${{ runner.os != 'Windows' }}
6799
shell: vsdevenv x86 powershell {0}
68100
run: |
69101
cmake -G "NMake Makefiles" -B tests\build-x86 -S tests -DCMAKE_BUILD_TYPE=Release -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=.
@@ -72,9 +104,10 @@ jobs:
72104
tests\build-x86\helloworld.exe 1 2 3 4
73105
74106
- name: cmake test -- vsdevenv x86 cmd -A Win32
107+
continue-on-error: ${{ runner.os != 'Windows' }}
75108
shell: vsdevenv x86 cmd {0}
76109
run: |
77-
cmake -A Win32 -G "Visual Studio 16 2019" -B tests\build-Ax86 -S tests -DCMAKE_BUILD_TYPE=Release -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=. || exit /b %errorlevel%
110+
cmake -A Win32 -G "$VISUAL_STUDIO_GENERATOR" -B tests\build-Ax86 -S tests -DCMAKE_BUILD_TYPE=Release -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=. || exit /b %errorlevel%
78111
cmake --build tests\build-Ax86 --config release || exit /b %errorlevel%
79112
dir tests\build-Ax86\helloworld.exe
80113
tests\build-Ax86\helloworld.exe 1 2 3 4

action.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,22 @@ runs:
1010
shell: bash
1111
run: |
1212
if [[ $RUNNER_OS == 'Windows' ]] ; then
13-
echo $GITHUB_ACTION_PATH/bin >> $GITHUB_PATH
13+
echo $GITHUB_ACTION_PATH/bin | tee -a $GITHUB_PATH
1414
else
15-
echo "NOTE: skipping vsdevenv-shell integration (RUNNER_OS is $RUNNER_OS, not Windows)"
15+
echo "NOTE: emulating vsdevenv-shell integration (since RUNNER_OS is $RUNNER_OS, not Windows)"
16+
echo $GITHUB_ACTION_PATH/bin | tee -a $GITHUB_PATH
17+
cat<<-'EOF' > $GITHUB_ACTION_PATH/bin/vsdevenv
18+
#!/bin/bash
19+
set -e
20+
shift # x86
21+
subshell=$1
22+
shift # subshell
23+
case $subshell in
24+
bash) bash --noprofile --norc -e -o pipefail "$1" ;;
25+
pwsh|powershell) pwsh -command "\$ErrorActionPreference = 'stop' ; get-content '$1' | Invoke-Expression ; if ((Test-Path -LiteralPath variable:\\LASTEXITCODE)) { exit \$LASTEXITCODE }" ;;
26+
*) echo "skipping subshell=$subshell on $RUNNER_OS" ; exit 0 ;;
27+
esac
28+
EOF
29+
chmod a+x $GITHUB_ACTION_PATH/bin/vsdevenv
30+
cat $GITHUB_ACTION_PATH/bin/vsdevenv
1631
fi

bin/vsdevenv.cmd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
@echo off
22
@setlocal
33
@FOR /F "tokens=*" %%g IN ('"bash %~dp0\..\utils\findvsdevcmd.sh"') do (SET vsdevcmd=%%g)
4-
echo [vsdevcmd] arch=%1 shell=%2 script=%3 vsdevcmd=%vsdevcmd%
4+
echo [vsdevcmd] arch=%1 shell=%2 script=%3 vsdevcmd=%vsdevcmd%
5+
if "%vsdevcmd%" == "" ( echo "ERROR: could not locate vsdevcmd.bat" & exit /b 200 )
56
@call %vsdevcmd% -no_logo -arch=%1 -host_arch=amd64
67
@FOR /F "tokens=*" %%g IN ('"bash %~dp0\..\utils\findmlexepath.sh"') do (SET msvc_mlpath=%%g)
78
@REM echo [vsdevcmd] arch=%1 shell=%2 script=%3 msvc_mlpath=%msvc_mlpath%

utils/findvsdevcmd.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/bin/bash
2-
cygpath -ms /c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio/*/*/Common7/Tools/vsdevcmd.bat|sort -r|head -1
2+
cygpath -ms /c/Program\ File*/Microsoft\ Visual\ Studio/*/*/Common7/Tools/vsdevcmd.bat|sort -r|head -1

0 commit comments

Comments
 (0)