diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index 89fe326..cb31033 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -1,11 +1,13 @@ -name: libusbK builds with nuget WDK +name: libusbK builds with pre-installed WDK on: [push, pull_request] jobs: + build-project: name: Build (${{ matrix.platform }}) - runs-on: windows-2022 + runs-on: windows-2022 # WDK 10.0.26100.16 pre-installed + strategy: fail-fast: false matrix: @@ -15,62 +17,94 @@ jobs: - name: Checkout Repository uses: actions/checkout@v6 - - name: Setup MSBuild Configuration + - name: Setup MSBuild uses: microsoft/setup-msbuild@v3 - - name: Setup NuGet Environment - uses: NuGet/setup-nuget@v3 - - # Pulls down the driver compilation environment directly into the workspace - - name: Restore WDK Packages - shell: powershell - working-directory: libusbK + # Locate the pre-installed WDK and expose key tool paths as env vars + - name: Locate pre-installed WDK + shell: pwsh run: | - nuget install Microsoft.Windows.WDK.x64 -Version "10.0.26100.2454" -OutputDirectory packages + $reg = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots" -ErrorAction Stop + $kitRoot = $reg.KitsRoot10 + Write-Output "WDK root: $kitRoot" + + # Find the highest build number under bin\ + $wdkBin = Get-ChildItem "$kitRoot\bin" -Directory | + Where-Object { $_.Name -match '^\d+\.\d+\.\d+\.\d+$' } | + Sort-Object Name -Descending | + Select-Object -First 1 -ExpandProperty FullName + + Write-Output "WDK bin: $wdkBin" - # Dynamically maps the restored NuGet WDK paths structurally into the compiler framework + $inf2cat = "$wdkBin\x86\Inf2Cat.exe" + $signtool = "$wdkBin\x64\signtool.exe" + $stampinf = "$wdkBin\x64\stampinf.exe" + + # Verify tools exist + foreach ($tool in $inf2cat, $signtool, $stampinf) { + if (Test-Path $tool) { Write-Output "Found: $tool" } + else { Write-Warning "NOT found: $tool" } + } + + # Expose to subsequent steps + echo "WDK_BIN=$wdkBin" >> $env:GITHUB_ENV + echo "INF2CAT=$inf2cat" >> $env:GITHUB_ENV + echo "SIGNTOOL=$signtool" >> $env:GITHUB_ENV + echo "STAMPINF=$stampinf" >> $env:GITHUB_ENV + + # Inject WDK include path via Directory.Build.props so MSBuild can + # find ntddk.h without a full WDK Visual Studio extension install - name: Configure WDK Include Intercepts - shell: powershell + shell: pwsh run: | + $reg = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots" + $kitRoot = $reg.KitsRoot10 + + $wdkVer = Get-ChildItem "$kitRoot\bin" -Directory | + Where-Object { $_.Name -match '^\d+\.\d+\.\d+\.\d+$' } | + Sort-Object Name -Descending | + Select-Object -First 1 -ExpandProperty Name + $PropsContent = @" Windows10 - 10.0.26100.0 + $wdkVer true - - - `$(SolutionDir)packages\Microsoft.Windows.WDK.x64.10.0.26100.2454\build\native\include;`$(AdditionalIncludeDirectories) - - "@ - $PropsContent | Out-File -FilePath "libusbK\Directory.Build.props" -Encoding utf8 - Write-Output "Successfully generated structural Directory.Build.props file." + $PropsContent | Out-File -FilePath "libusbK\Directory.Build.props" -Encoding utf8BOM + Write-Output "Generated Directory.Build.props with TargetPlatformVersion=$wdkVer" - # Build User-space Libraries (x86, x64, ARM64) - # This step will inherently pick up the TargetPlatformVersion from the props file safely + # Build user-space library (all platforms) - name: Build User Libraries shell: cmd working-directory: libusbK run: | echo === Building User Space Libs === - msbuild src\lib\libusbK_lib.vcxproj /p:Configuration=Release /p:Platform=${{ matrix.platform }} /m + msbuild src\lib\libusbK_lib.vcxproj ^ + /p:Configuration=Release ^ + /p:Platform=${{ matrix.platform }} ^ + /m /nologo /v:minimal - # Build Kernel Drivers (x64, ARM64 Only) - # The Directory.Build.props file guarantees 'ntddk.h' resolves natively inside the global workspace + # Build kernel driver (x64 and ARM64 only) - name: Build Kernel Drivers if: matrix.platform != 'Win32' shell: cmd working-directory: libusbK run: | echo === Building Driver (.sys) === - msbuild src\sys\libusbK_sys.vcxproj /p:Configuration=Release /p:Platform=${{ matrix.platform }} /p:DriverTargetPlatform="Desktop" /p:ApiValidatorAnalyze=false /p:InfVerif=false /m + msbuild src\sys\libusbK_sys.vcxproj ^ + /p:Configuration=Release ^ + /p:Platform=${{ matrix.platform }} ^ + /p:DriverTargetPlatform=Desktop ^ + /p:ApiValidatorAnalyze=false ^ + /p:InfVerif=false ^ + /m /nologo /v:minimal - # Collect and Securely Export Output Binaries - name: Collect and Upload Artifacts - uses: actions/upload-artifact@v7 + uses: actions/upload-artifact@v4 with: name: libusbK-windows-2022-${{ matrix.platform }}-Output path: |