Skip to content

Commit 4865fec

Browse files
committed
ci: use setup-msvc-dev action instead of a hard-coded vcvars path
The windows-cmake job set up the MSVC environment by calling a hard-coded "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" in its NMake, clang-cl and Meson steps. The hosted windows-latest image no longer has Visual Studio installed under that "Enterprise" path, so those steps started failing with "The system cannot find the path specified." Set up the developer environment once per job with the TheMrMilchmann/setup-msvc-dev action -- it locates the installed toolchain (no hard-coded path or edition) and exports the environment for the following steps -- and drop all the hard-coded vcvars64.bat calls. Because that environment now applies to the whole job, force gcc for the MinGW configure steps; otherwise CMake's "MinGW Makefiles" generator picks up cl. Assisted-by: claude-code:claude-opus-4-8
1 parent 4957824 commit 4865fec

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

.github/workflows/builds.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ jobs:
193193
choco install ninja
194194
pip3 install meson
195195
refreshenv
196+
- name: Set up MSVC developer environment
197+
uses: TheMrMilchmann/setup-msvc-dev@v4
198+
with:
199+
arch: x64
196200
- name: Configure CMake MSVC
197201
shell: cmd
198202
run: |
@@ -235,13 +239,11 @@ jobs:
235239
- name: Configure CMake NMake MSVC
236240
shell: cmd
237241
run: |
238-
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
239242
cmake -G"NMake Makefiles" -B build\nmake -S hidapisrc -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHIDAPI_WITH_TESTS=ON -DHIDAPI_BUILD_PP_DATA_DUMP=ON -DHIDAPI_ENABLE_ASAN=ON -DCMAKE_INSTALL_PREFIX=install\nmake -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=%MSVC_COMPILE_FLAGS%"
240243
- name: Build CMake NMake MSVC
241244
working-directory: build\nmake
242245
shell: cmd
243246
run: |
244-
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
245247
nmake install
246248
- name: Check artifacts CMake NMake MSVC
247249
uses: andstor/file-existence-action@v2
@@ -254,7 +256,6 @@ jobs:
254256
- name: Check CMake NMake MSVC Export Package
255257
shell: cmd
256258
run: |
257-
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
258259
cmake ^
259260
-G"NMake Makefiles" ^
260261
-B build\nmake_test ^
@@ -271,13 +272,11 @@ jobs:
271272
- name: Configure CMake NMake ClangCL
272273
shell: cmd
273274
run: |
274-
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
275275
cmake -G"NMake Makefiles" -B build\clang_cl -S hidapisrc -D CMAKE_C_COMPILER=clang-cl -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHIDAPI_WITH_TESTS=ON -DHIDAPI_BUILD_PP_DATA_DUMP=ON -DHIDAPI_ENABLE_ASAN=OFF -DCMAKE_INSTALL_PREFIX=install\clang_cl -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=%MSVC_COMPILE_FLAGS%"
276276
- name: Build CMake NMake ClangCL
277277
working-directory: build\clang_cl
278278
shell: cmd
279279
run: |
280-
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
281280
nmake install
282281
- name: Check artifacts CMake NMake ClangCL
283282
uses: andstor/file-existence-action@v2
@@ -290,7 +289,6 @@ jobs:
290289
- name: Check CMake NMake ClangCL Export Package
291290
shell: cmd
292291
run: |
293-
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
294292
cmake ^
295293
-G"NMake Makefiles" ^
296294
-B build\clang_cl_test ^
@@ -306,10 +304,12 @@ jobs:
306304
working-directory: build/clang_cl
307305
run: ctest -C RelWithDebInfo --no-compress-output --output-on-failure
308306

307+
# MinGW must use gcc; the job-wide MSVC environment set up above would
308+
# otherwise make CMake's "MinGW Makefiles" generator pick up cl.
309309
- name: Configure CMake MinGW
310310
shell: cmd
311311
run: |
312-
cmake -G"MinGW Makefiles" -B build\mingw -S hidapisrc -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHIDAPI_WITH_TESTS=ON -DHIDAPI_BUILD_PP_DATA_DUMP=ON -DCMAKE_INSTALL_PREFIX=install\mingw -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=%GNU_COMPILE_FLAGS%"
312+
cmake -G"MinGW Makefiles" -DCMAKE_C_COMPILER=gcc -B build\mingw -S hidapisrc -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHIDAPI_WITH_TESTS=ON -DHIDAPI_BUILD_PP_DATA_DUMP=ON -DCMAKE_INSTALL_PREFIX=install\mingw -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=%GNU_COMPILE_FLAGS%"
313313
- name: Build CMake MinGW
314314
working-directory: build\mingw
315315
run: cmake --build . --target install
@@ -326,6 +326,7 @@ jobs:
326326
run: |
327327
cmake ^
328328
-G"MinGW Makefiles" ^
329+
-DCMAKE_C_COMPILER=gcc ^
329330
-B build\mingw_test ^
330331
-S hidapisrc\hidtest ^
331332
-Dhidapi_ROOT=install\mingw ^
@@ -340,7 +341,6 @@ jobs:
340341
- name: Check Meson build
341342
shell: cmd
342343
run: |
343-
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
344344
meson setup build_meson hidapisrc
345345
cd build_meson
346346
ninja

0 commit comments

Comments
 (0)