mirror of
https://github.com/NohamR/Reclass.git
synced 2026-05-10 19:59:21 +00:00
ci: install WDK via NuGet for driver build in CI
Runner doesn't have WDK headers installed. Use NuGet to install Microsoft.Windows.WDK.x64 and pass paths via env vars. build_driver.bat now accepts WDK_INC_ROOT/WDK_LIB_ROOT overrides.
This commit is contained in:
@@ -1,36 +1,43 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
:: ── Auto-detect MSVC ──
|
||||
set "VSBASE=C:\Program Files\Microsoft Visual Studio\2022"
|
||||
set MSVC=
|
||||
for %%E in (Enterprise Professional Community BuildTools) do (
|
||||
if exist "!VSBASE!\%%E\VC\Tools\MSVC" (
|
||||
for /f "delims=" %%V in ('dir /b /ad /o-n "!VSBASE!\%%E\VC\Tools\MSVC" 2^>nul') do (
|
||||
if not defined MSVC set "MSVC=!VSBASE!\%%E\VC\Tools\MSVC\%%V"
|
||||
:: ── Auto-detect MSVC (override with MSVC env var) ──
|
||||
if not defined MSVC (
|
||||
set "VSBASE=C:\Program Files\Microsoft Visual Studio\2022"
|
||||
for %%E in (Enterprise Professional Community BuildTools) do (
|
||||
if exist "!VSBASE!\%%E\VC\Tools\MSVC" (
|
||||
for /f "delims=" %%V in ('dir /b /ad /o-n "!VSBASE!\%%E\VC\Tools\MSVC" 2^>nul') do (
|
||||
if not defined MSVC set "MSVC=!VSBASE!\%%E\VC\Tools\MSVC\%%V"
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
if not defined MSVC (
|
||||
echo ERROR: Could not find MSVC toolchain under !VSBASE!
|
||||
echo ERROR: Could not find MSVC toolchain
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
:: ── Auto-detect WDK ──
|
||||
set "WDK=C:\Program Files (x86)\Windows Kits\10"
|
||||
set WDKVER=
|
||||
for /f "delims=" %%V in ('dir /b /ad /o-n "!WDK!\Include" 2^>nul') do (
|
||||
if exist "!WDK!\Include\%%V\km\ntddk.h" (
|
||||
if not defined WDKVER set "WDKVER=%%V"
|
||||
:: ── Auto-detect WDK (override with WDK_INC_ROOT and WDK_LIB_ROOT env vars) ──
|
||||
if not defined WDK_INC_ROOT (
|
||||
set "WDK=C:\Program Files (x86)\Windows Kits\10"
|
||||
set WDKVER=
|
||||
for /f "delims=" %%V in ('dir /b /ad /o-n "!WDK!\Include" 2^>nul') do (
|
||||
if exist "!WDK!\Include\%%V\km\ntddk.h" (
|
||||
if not defined WDKVER set "WDKVER=%%V"
|
||||
)
|
||||
)
|
||||
)
|
||||
if not defined WDKVER (
|
||||
echo ERROR: Could not find WDK headers under !WDK!\Include
|
||||
exit /b 1
|
||||
if not defined WDKVER (
|
||||
echo ERROR: Could not find WDK headers under !WDK!\Include
|
||||
echo Set WDK_INC_ROOT and WDK_LIB_ROOT environment variables to override.
|
||||
exit /b 1
|
||||
)
|
||||
set "WDK_INC_ROOT=!WDK!\Include\!WDKVER!"
|
||||
set "WDK_LIB_ROOT=!WDK!\Lib\!WDKVER!"
|
||||
)
|
||||
|
||||
echo Using MSVC: %MSVC%
|
||||
echo Using WDK: %WDK% (%WDKVER%)
|
||||
echo Using MSVC: %MSVC%
|
||||
echo Using WDK inc: %WDK_INC_ROOT%
|
||||
echo Using WDK lib: %WDK_LIB_ROOT%
|
||||
|
||||
set "CL_EXE=%MSVC%\bin\Hostx64\x64\cl.exe"
|
||||
set "LINK_EXE=%MSVC%\bin\Hostx64\x64\link.exe"
|
||||
@@ -44,9 +51,9 @@ echo === Compiling rcxdrv.c ===
|
||||
"%CL_EXE%" /nologo /c /Zi /W4 /WX- /O2 /GS- ^
|
||||
/D "NDEBUG" /D "_AMD64_" /D "AMD64" /D "_WIN64" /D "KERNEL" ^
|
||||
/D "NTDDI_VERSION=0x0A000000" ^
|
||||
/I "%WDK%\Include\%WDKVER%\km" ^
|
||||
/I "%WDK%\Include\%WDKVER%\km\crt" ^
|
||||
/I "%WDK%\Include\%WDKVER%\shared" ^
|
||||
/I "%WDK_INC_ROOT%\km" ^
|
||||
/I "%WDK_INC_ROOT%\km\crt" ^
|
||||
/I "%WDK_INC_ROOT%\shared" ^
|
||||
/kernel ^
|
||||
/Fo"%OUTDIR%\rcxdrv.obj" ^
|
||||
"%SRCDIR%rcxdrv.c"
|
||||
@@ -66,9 +73,9 @@ echo === Linking rcxdrv.sys ===
|
||||
/PDBALTPATH:rcxdrv.pdb ^
|
||||
/PDB:"%OUTDIR%\rcxdrv.pdb" ^
|
||||
"%OUTDIR%\rcxdrv.obj" ^
|
||||
"%WDK%\Lib\%WDKVER%\km\x64\ntoskrnl.lib" ^
|
||||
"%WDK%\Lib\%WDKVER%\km\x64\hal.lib" ^
|
||||
"%WDK%\Lib\%WDKVER%\km\x64\BufferOverflowK.lib" ^
|
||||
"%WDK_LIB_ROOT%\km\x64\ntoskrnl.lib" ^
|
||||
"%WDK_LIB_ROOT%\km\x64\hal.lib" ^
|
||||
"%WDK_LIB_ROOT%\km\x64\BufferOverflowK.lib" ^
|
||||
"%MSVC%\lib\x64\libcmt.lib"
|
||||
if errorlevel 1 goto :fail
|
||||
|
||||
|
||||
Reference in New Issue
Block a user