Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable CI workflows to use NuGet WDK packages #236

Open
wants to merge 59 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
36b1d1e
Initial commit: use nuget pkgs
svasista-ms Oct 3, 2024
7e467f6
Initial commit: use nuget pkgs
svasista-ms Oct 3, 2024
f04f22f
Merge branch 'microsoft:main' into port-pipeline
svasista-ms Oct 8, 2024
b641096
add NugetWDKContentRoot env variable detection to detect_wdk_content_…
svasista-ms Oct 8, 2024
6d024aa
Merge branch 'port-pipeline' of https://github.com/svasista-ms/window…
svasista-ms Oct 8, 2024
d901e20
Add steps to install Nuget, move signtool to WDK's bin dir and set Nu…
svasista-ms Oct 9, 2024
3038dc2
Add action to install Nuget
svasista-ms Oct 9, 2024
40441ad
Add action to install Nuget
svasista-ms Oct 9, 2024
80996e1
Add action to install Nuget
svasista-ms Oct 9, 2024
ffc24b3
Add action to install Nuget
svasista-ms Oct 9, 2024
e86b142
Add action to install Nuget
svasista-ms Oct 9, 2024
3922faf
Fix condition to run Nuget installation
svasista-ms Oct 9, 2024
03f6633
Fix WDK version in the matrix
svasista-ms Oct 9, 2024
7343913
Fix NuGet command
svasista-ms Oct 9, 2024
13fd747
Add command to set NugetWdkContentRoot ENV VAR
svasista-ms Oct 9, 2024
9d1698d
Add command to set NugetWdkContentRoot ENV VAR
svasista-ms Oct 9, 2024
52e0ac7
Add command to set NugetWdkContentRoot ENV VAR
svasista-ms Oct 9, 2024
5e29f19
Add command to set NugetWdkContentRoot ENV VAR
svasista-ms Oct 9, 2024
1046cbf
Add command to set NugetWdkContentRoot ENV VAR
svasista-ms Oct 9, 2024
3b39c40
Add command to set NugetWdkContentRoot ENV VAR
svasista-ms Oct 9, 2024
dbc2f27
Replace x64 with ARM64 contents
svasista-ms Oct 9, 2024
edcbec9
Replace x64 with ARM64 contents
svasista-ms Oct 9, 2024
c0eeeb8
List contents of WDK Root Dir
svasista-ms Oct 10, 2024
9b9bb08
List contents of WDK Root Dir
svasista-ms Oct 10, 2024
4c5cb6e
Add print stmts for debugging
svasista-ms Oct 10, 2024
2e28af7
Add print stmts for debugging
svasista-ms Oct 10, 2024
860b337
Add print stmts for debugging
svasista-ms Oct 10, 2024
02e3fbd
Reduce matrix options for faster workflow exec
svasista-ms Oct 10, 2024
abd946e
Fix wdk tool root for nuget package - tools instead of Tools
svasista-ms Oct 10, 2024
a656057
Replace ARM64 with x64 to match the host arch
svasista-ms Oct 10, 2024
7692e01
Add command to move ARM64 headers to NuGet's x64 root
svasista-ms Oct 10, 2024
70c7b6b
Add command to move ARM64 headers to NuGet's x64 root
svasista-ms Oct 10, 2024
a7a2fe8
Add debug print to copy to package function
svasista-ms Oct 10, 2024
3c51e27
Latest WDK, LLVM 17.0.6, stable, dev, x86_64-pc-windows-msvc
svasista-ms Oct 10, 2024
17e02da
Latest WDK, LLVM 17.0.6, stable, dev, x86_64-pc-windows-msvc
svasista-ms Oct 10, 2024
72e518d
Move certmgr to WDK bin directories
svasista-ms Oct 11, 2024
efcb4db
Move MakeCert to respective WDK bin directories
svasista-ms Oct 11, 2024
2e3024f
Move nuget-install-wdk to separate script
svasista-ms Oct 11, 2024
98df970
Move nuget-install-wdk to separate script
svasista-ms Oct 11, 2024
30f4fa6
Move nuget-install-wdk to separate script
svasista-ms Oct 11, 2024
e156edd
Enable WDK NI in the matrix
svasista-ms Oct 11, 2024
bf6203c
Remove debug print stmts, Enable target triple, Use Tools/ instead of…
svasista-ms Oct 11, 2024
d3c0fad
Enable all profiles, toolchains, targets in the matrix; complete matr…
svasista-ms Oct 11, 2024
4df4330
Enable other workflows
svasista-ms Oct 11, 2024
a421cd7
Merge branch 'microsoft:main' into port-pipeline
svasista-ms Oct 11, 2024
b8fdb0d
Enable Latest WDK (uses NuGet) in all workflows
svasista-ms Oct 11, 2024
41a7b7e
Revert to error handling using '?' for canonicalize and strip_extende…
svasista-ms Oct 14, 2024
ccdb96a
Merge branch 'main' into port-pipeline
svasista-ms Oct 16, 2024
f632131
Merge branch 'main' of https://github.com/microsoft/windows-drivers-r…
svasista-ms Oct 16, 2024
d2e3a61
Remove NugetWdkContentRoot env var, add logic in nuget-install-wdk.ps…
svasista-ms Oct 16, 2024
beedcb0
Merge branch 'port-pipeline' of https://github.com/svasista-ms/window…
svasista-ms Oct 16, 2024
37b4bd6
Update Install WDK (NuGet) step in other workflows
svasista-ms Oct 16, 2024
f4087df
Fix Install WDK (NuGet) script's condition in accordance to the power…
svasista-ms Oct 16, 2024
a559f6d
Fix Install WDK (NuGet) script's condition in codeql.yml; Fix is_none…
svasista-ms Oct 16, 2024
a350aa5
change output directory of NuGet restore to C:\WDK
svasista-ms Oct 16, 2024
5868673
fix packagesConfigPath in nuget-install-wdk.ps1
svasista-ms Oct 16, 2024
a422a4c
use is_none_or() for clippy::nominal_bool
svasista-ms Oct 22, 2024
0256275
remove unnecessary hashes around raw string literal
svasista-ms Oct 22, 2024
058b784
Merge branch 'main' into port-pipeline
NateD-MSFT Nov 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 121 additions & 0 deletions .github/scripts/nuget-install-wdk.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
param (
[string]$wdkVersion
)

# Extract the first three parts of the version
$majorVersionNum = ($wdkVersion -split '\.')[0..2] -join '.'

Write-Host "Installing WDK version $wdkVersion"
Write-Host "Major version number: $majorVersionNum"

# Update the packages.config file with the version passed as parameter
$packagesConfigPath = ".\packages.config"

if (Test-Path $packagesConfigPath) {
[xml]$packagesConfig = Get-Content $packagesConfigPath
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather than updating a version thats hardcoded into a packages.config (that is only used in CI), can you just use nuget install in the action step?


foreach ($package in $packagesConfig.packages.package) {
if ($package.id -like "Microsoft.Windows.*") {
$package.version = $wdkVersion
}
}

$packagesConfig.Save($packagesConfigPath)
Write-Host "Updated packages.config with version $wdkVersion"
} else {
Write-Error "packages.config file not found"
}

# Install WDK using NuGet
try {
nuget restore .\packages.config -PackagesDirectory C:\WDK
Write-Host "WDK installed at C:\WDK"
} catch {
Write-Error "Failed to restore packages using NuGet. Error: $_"
exit 1
}

$folders = @(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is there all this manual copying of folders after the nuget packages are restored? this seems very brittle

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The setup_path function sets the bin and tools root W.R.T standard WDK's directory structure. However, with NuGet I noticed that some bins and headers were placed in a different path. So, this script moves them under the root that setup_path is using.

pub fn setup_path() -> Result<impl IntoIterator<Item = String>, ConfigError> {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function actually uses detect_wdk_content_root, so as long as that's detecting nuget properly, then we're all set.

see #236 (comment) for more details, but the tl;dr is that the nuget WDK's use in c drivers works by setting the include and bin paths via modifying the vcxproj. as stated in my linked comment, since there is no path forward to use the same solution that nuget uses in c drivers (ie. vcxproj is not supported by our rust tooling), we should rely on the env vars used by ewdk

"C:\WDK\Microsoft.Windows.WDK.x64.$wdkVersion",
"C:\WDK\Microsoft.Windows.SDK.CPP.x64.$wdkVersion",
"C:\WDK\Microsoft.Windows.SDK.CPP.arm64.$wdkVersion",
"C:\WDK\Microsoft.Windows.WDK.ARM64.$wdkVersion",
"C:\WDK\Microsoft.Windows.SDK.CPP.$wdkVersion"
)
foreach ($folder in $folders) {
if (-Not (Test-Path $folder)) {
Write-Error "Required folder $folder is missing."
exit 1
}
}
function Copy-File {
param (
[string]$sourcePath,
[string]$destinationPath,
[string]$fileName
)

if (Test-Path $sourcePath) {
Copy-Item -Path $sourcePath -Destination $destinationPath -Force
Write-Host "Copied $fileName to $destinationPath"
} else {
Write-Error "$fileName not found at $sourcePath"
}
}

# Copying signtool to WDK bin folder
$signtoolx64 = "C:\WDK\Microsoft.Windows.SDK.CPP.$wdkVersion\c\bin\$majorVersionNum.0\x64\signtool.exe"
$signtoolX86 = "C:\WDK\Microsoft.Windows.SDK.CPP.$wdkVersion\c\bin\$majorVersionNum.0\x86\signtool.exe"
$destinationx64 = "C:\WDK\Microsoft.Windows.WDK.x64.$wdkVersion\c\bin\$majorVersionNum.0\x64"
$destinationX86 = "C:\WDK\Microsoft.Windows.WDK.x64.$wdkVersion\c\bin\$majorVersionNum.0\x86"

Copy-File -sourcePath $signtoolX64 -destinationPath $destinationX64 -fileName "signtool.exe"
Copy-File -sourcePath $signtoolX86 -destinationPath $destinationX86 -fileName "signtool.exe"

# Copying certmgr to WDK bin folder
$certmgrx86 = "C:\WDK\Microsoft.Windows.SDK.CPP.$wdkVersion\c\bin\$majorVersionNum.0\x86\certmgr.exe"
$certmgrX64 = "C:\WDK\Microsoft.Windows.SDK.CPP.$wdkVersion\c\bin\$majorVersionNum.0\x64\certmgr.exe"
$certmgrARM64 = "C:\WDK\Microsoft.Windows.SDK.CPP.$wdkVersion\c\bin\$majorVersionNum.0\arm64\certmgr.exe"
$destinationx86 = "C:\WDK\Microsoft.Windows.WDK.x64.$wdkVersion\c\bin\$majorVersionNum.0\x86"
$destinationx64 = "C:\WDK\Microsoft.Windows.WDK.x64.$wdkVersion\c\bin\$majorVersionNum.0\x64"
$destinationARM64 = "C:\WDK\Microsoft.Windows.WDK.x64.$wdkVersion\c\bin\$majorVersionNum.0\ARM64"

Copy-File -sourcePath $certmgrx86 -destinationPath $destinationx86 -fileName "certmgr.exe"
Copy-File -sourcePath $certmgrX64 -destinationPath $destinationx64 -fileName "certmgr.exe"
Copy-File -sourcePath $certmgrARM64 -destinationPath $destinationARM64 -fileName "certmgr.exe"

# Copying makecert to WDK bin folder
$makecertx86 = "C:\WDK\Microsoft.Windows.SDK.CPP.$wdkVersion\c\bin\$majorVersionNum.0\x86\MakeCert.exe"
$makecertX64 = "C:\WDK\Microsoft.Windows.SDK.CPP.$wdkVersion\c\bin\$majorVersionNum.0\x64\MakeCert.exe"
$makecertARM64 = "C:\WDK\Microsoft.Windows.SDK.CPP.$wdkVersion\c\bin\$majorVersionNum.0\arm64\MakeCert.exe"
$destinationx86 = "C:\WDK\Microsoft.Windows.WDK.x64.$wdkVersion\c\bin\$majorVersionNum.0\x86"
$destinationx64 = "C:\WDK\Microsoft.Windows.WDK.x64.$wdkVersion\c\bin\$majorVersionNum.0\x64"
$destinationARM64 = "C:\WDK\Microsoft.Windows.WDK.x64.$wdkVersion\c\bin\$majorVersionNum.0\ARM64"

Copy-File -sourcePath $makecertx86 -destinationPath $destinationx86 -fileName "MakeCert.exe"
Copy-File -sourcePath $makecertX64 -destinationPath $destinationx64 -fileName "MakeCert.exe"
Copy-File -sourcePath $makecertARM64 -destinationPath $destinationARM64 -fileName "MakeCert.exe"

function Copy-Folder {
param (
[string]$sourceFolder,
[string]$destinationFolder
)

if (Test-Path $sourceFolder) {
Copy-Item -Path $sourceFolder -Destination $destinationFolder -Recurse -Force
Write-Host "Copied $sourceFolder to $destinationFolder"
} else {
Write-Error "Source folder $sourceFolder not found"
}
}

# Copying km, um, kmdf, umdf ARM64 headers to x64 folders
Copy-Folder -sourceFolder "C:\WDK\Microsoft.Windows.WDK.ARM64.$wdkVersion\c\Lib\$majorVersionNum.0\km\arm64" -destinationFolder "C:\WDK\Microsoft.Windows.WDK.x64.$wdkVersion\c\Lib\$majorVersionNum.0\km"
Copy-Folder -sourceFolder "C:\WDK\Microsoft.Windows.WDK.ARM64.$wdkVersion\c\Lib\$majorVersionNum.0\um\arm64" -destinationFolder "C:\WDK\Microsoft.Windows.WDK.x64.$wdkVersion\c\Lib\$majorVersionNum.0\um"
Copy-Folder -sourceFolder "C:\WDK\Microsoft.Windows.WDK.ARM64.$wdkVersion\c\Lib\wdf\kmdf\ARM64" -destinationFolder "C:\WDK\Microsoft.Windows.WDK.x64.$wdkVersion\c\Lib\wdf\kmdf"
Copy-Folder -sourceFolder "C:\WDK\Microsoft.Windows.WDK.ARM64.$wdkVersion\c\Lib\wdf\umdf\ARM64" -destinationFolder "C:\WDK\Microsoft.Windows.WDK.x64.$wdkVersion\c\Lib\wdf\umdf"

# Set WDKContentRoot environment variable
$NugetWdkContentRoot = "C:\WDK\Microsoft.Windows.WDK.x64.$wdkVersion\c"
Write-Output "WDKContentRoot=$NugetWdkContentRoot" >> $env:GITHUB_ENV
16 changes: 16 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ jobs:
matrix:
wdk:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than special casing the NI WDK, I think you should explicityly add another matrix dimension for WDK source. Then you can exclude the WDK versions from nuget that aren't available via the exclude feature. It would look something like:

matrix:
  wdk_source: [nuget, winget]
  wdk_version: 
  - 10.0.22621 # NI WDK
  - 10.0.26100 #GE WDK
  exclude:
      # 10.0.22621 not available on nuget
      - wdk_source: nuget
        wdk_version: 10.0.22621

This way, your later steps can switch on if: matrix.wdk_source == nuget and similar. The Nuget and Winget specific steps should be able to eaisly reconstruct the full install version string from just the wdk_version

- Microsoft.WindowsWDK.10.0.22621 # NI WDK
# Use versions numbers for NuGet WDK packages
# - 10.0.26100.1882
# - 10.0.26100.1591
Comment on lines +24 to +25
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are just QFE versions right? I think either have all of the QFE versions enabled, or remove the comment

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also why not use the latest QFE here, if there is only going to be one

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the best thing to do here is actually leave off the QFE version and get the latest QFE for a given build number

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW the varying QFEs here do refer to meaningfully different builds of the WDK now that we've moved to a CD model. It is probably fine to just use the latest GE CD kit for the matrix rather than run each one.

Copy link
Collaborator

@wmmc88 wmmc88 Dec 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So for a given build number, a user should always be using the latest QFE, right?

FWIW the varying QFEs here do refer to meaningfully different builds of the WDK now that we've moved to a CD model. It is probably fine to just use the latest GE CD kit for the matrix rather than run each one.

Is this WRT to GE only, or do you think its always fine to just run on the latest QFE for every build number(including vNext wdk)? my intuition here is to have the matrix always run:

  • the latest QFE for every build number
  • both winget and nuget since they use meaningfully different ways of exposing where its contents are (ie. regkey for winget and vcxproj for nuget, but per my other comment, i think we should piggyback off the ewdks' env var)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that prior to Ge there was no meaningful difference between QFEs. Kits almost exclusively shipped once per release. I think there was a special case in one release, but the concept of "multiple kits with the same build number but different QFEs, with different content" is new to Ge and CD.

- 10.0.26100.1

llvm:
- 17.0.6
Expand Down Expand Up @@ -57,6 +61,7 @@ jobs:
clang --version

- name: Install WDK (${{ matrix.wdk }})
if: matrix.wdk == 'Microsoft.WindowsWDK.10.0.22621'
run: |
if ((Get-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals).Id -eq '${{ matrix.wdk }}') {
Write-Host "${{ matrix.wdk }} is already installed. Attempting to update..."
Expand All @@ -65,6 +70,17 @@ jobs:
Write-Host "Installing ${{ matrix.wdk }}..."
Install-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals -Mode Silent -Force
}

- name: Install ${{ matrix.wdk }} (NuGet)
if: startsWith(matrix.wdk, '10.0.')
run: |
$wdk = '${{ matrix.wdk }}'
if ($wdk -match '^10\.0\.\d{5}\.\d{1,4}$') {
./.github/scripts/nuget-install-wdk.ps1 -wdkVersion $wdk
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needing to run this ps script seems a little hacky. Is there a reason you can't just nuget install the required packages in this run block?

} else {
Write-Host "WDK version $wdk does not match the required format 10.0.{5 digit number}.{1 to 4 digit number}"
exit 1
}

- name: Install Rust Toolchain (${{ matrix.rust_toolchain }})
uses: dtolnay/rust-toolchain@master
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
matrix:
wdk:
- Microsoft.WindowsWDK.10.0.22621 # NI WDK
- 10.0.26100.1

llvm:
- 17.0.6
Expand Down Expand Up @@ -59,6 +60,7 @@ jobs:
clang --version

- name: Install WDK (${{ matrix.wdk }})
if: matrix.wdk == 'Microsoft.WindowsWDK.10.0.22621'
run: |
if ((Get-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals).Id -eq '${{ matrix.wdk }}') {
Write-Host "${{ matrix.wdk }} is already installed. Attempting to update..."
Expand All @@ -68,6 +70,17 @@ jobs:
Install-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals -Mode Silent -Force
}

- name: Install ${{ matrix.wdk }} (NuGet)
if: startsWith(matrix.wdk, '10.0.')
run: |
$wdk = '${{ matrix.wdk }}'
if ($wdk -match '^10\.0\.\d{5}\.\d{1,4}$') {
./.github/scripts/nuget-install-wdk.ps1 -wdkVersion $wdk
} else {
Write-Host "WDK version $wdk does not match the required format 10.0.{5 digit number}.{1 to 4 digit number}"
exit 1
}

- name: Install Rust Toolchain (${{ matrix.rust_toolchain }})
uses: dtolnay/rust-toolchain@master
with:
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
matrix:
wdk:
- Microsoft.WindowsWDK.10.0.22621 # NI WDK
- 10.0.26100.1

llvm:
- 17.0.6
Expand Down Expand Up @@ -55,6 +56,7 @@ jobs:
clang --version

- name: Install WDK (${{ matrix.wdk }})
if: matrix.wdk == 'Microsoft.WindowsWDK.10.0.22621'
run: |
if ((Get-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals).Id -eq '${{ matrix.wdk }}') {
Write-Host "${{ matrix.wdk }} is already installed. Attempting to update..."
Expand All @@ -64,6 +66,17 @@ jobs:
Install-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals -Mode Silent -Force
}

- name: Install ${{ matrix.wdk }} (NuGet)
if: startsWith(matrix.wdk, '10.0.')
run: |
$wdk = '${{ matrix.wdk }}'
if ($wdk -match '^10\.0\.\d{5}\.\d{1,4}$') {
./.github/scripts/nuget-install-wdk.ps1 -wdkVersion $wdk
} else {
Write-Host "WDK version $wdk does not match the required format 10.0.{5 digit number}.{1 to 4 digit number}"
exit 1
}

- name: Install Rust Toolchain (${{ matrix.rust_toolchain }})
uses: dtolnay/rust-toolchain@master
with:
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
matrix:
wdk:
- Microsoft.WindowsWDK.10.0.22621 # NI WDK
- 10.0.26100.1

llvm:
- 17.0.6
Expand Down Expand Up @@ -54,6 +55,7 @@ jobs:
clang --version

- name: Install WDK (${{ matrix.wdk }})
if: matrix.wdk == 'Microsoft.WindowsWDK.10.0.22621'
run: |
if ((Get-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals).Id -eq '${{ matrix.wdk }}') {
Write-Host "${{ matrix.wdk }} is already installed. Attempting to update..."
Expand All @@ -63,6 +65,17 @@ jobs:
Install-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals -Mode Silent -Force
}

- name: Install ${{ matrix.wdk }} (NuGet)
if: startsWith(matrix.wdk, '10.0.')
run: |
$wdk = '${{ matrix.wdk }}'
if ($wdk -match '^10\.0\.\d{5}\.\d{1,4}$') {
./.github/scripts/nuget-install-wdk.ps1 -wdkVersion $wdk
} else {
Write-Host "WDK version $wdk does not match the required format 10.0.{5 digit number}.{1 to 4 digit number}"
exit 1
}

- name: Install Rust Toolchain (${{ matrix.rust_toolchain }})
uses: dtolnay/rust-toolchain@master
with:
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/local-development-makefile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
matrix:
wdk:
- Microsoft.WindowsWDK.10.0.22621 # NI WDK
- 10.0.26100.1

llvm:
- 17.0.6
Expand Down Expand Up @@ -46,6 +47,7 @@ jobs:
clang --version

- name: Install WDK (${{ matrix.wdk }})
if: matrix.wdk == 'Microsoft.WindowsWDK.10.0.22621'
run: |
if ((Get-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals).Id -eq '${{ matrix.wdk }}') {
Write-Host "${{ matrix.wdk }} is already installed. Attempting to update..."
Expand All @@ -55,6 +57,16 @@ jobs:
Install-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals -Mode Silent -Force
}

- name: Install ${{ matrix.wdk }} (NuGet)
if: startsWith(matrix.wdk, '10.0.')
run: |
$wdk = '${{ matrix.wdk }}'
if ($wdk -match '^10\.0\.\d{5}\.\d{1,4}$') {
./.github/scripts/nuget-install-wdk.ps1 -wdkVersion $wdk
} else {
Write-Host "WDK version $wdk does not match the required format 10.0.{5 digit number}.{1 to 4 digit number}"
exit 1
}
- name: Install Nightly Rust Toolchain (${{ matrix.target_triple }})
uses: dtolnay/rust-toolchain@nightly
with:
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
matrix:
wdk:
- Microsoft.WindowsWDK.10.0.22621 # NI WDK
- 10.0.26100.1

llvm:
- 17.0.6
Expand Down Expand Up @@ -52,6 +53,7 @@ jobs:
clang --version

- name: Install WDK (${{ matrix.wdk }})
if: matrix.wdk == 'Microsoft.WindowsWDK.10.0.22621'
run: |
if ((Get-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals).Id -eq '${{ matrix.wdk }}') {
Write-Host "${{ matrix.wdk }} is already installed. Attempting to update..."
Expand All @@ -61,6 +63,17 @@ jobs:
Install-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals -Mode Silent -Force
}

- name: Install ${{ matrix.wdk }} (NuGet)
if: startsWith(matrix.wdk, '10.0.')
run: |
$wdk = '${{ matrix.wdk }}'
if ($wdk -match '^10\.0\.\d{5}\.\d{1,4}$') {
./.github/scripts/nuget-install-wdk.ps1 -wdkVersion $wdk
} else {
Write-Host "WDK version $wdk does not match the required format 10.0.{5 digit number}.{1 to 4 digit number}"
exit 1
}

- name: Install Rust Toolchain (${{ matrix.rust_toolchain }})
uses: dtolnay/rust-toolchain@master
with:
Expand Down
3 changes: 3 additions & 0 deletions crates/wdk-build/src/cargo_make.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,14 +516,17 @@ pub fn setup_path() -> Result<impl IntoIterator<Item = String>, ConfigError> {
let Some(wdk_content_root) = detect_wdk_content_root() else {
return Err(ConfigError::WdkContentRootDetectionError);
};

let version = get_latest_windows_sdk_version(&wdk_content_root.join("Lib"))?;

let host_arch = CpuArchitecture::try_from_cargo_str(env::consts::ARCH)
.expect("The rust standard library should always set env::consts::ARCH");

let wdk_bin_root = wdk_content_root
.join(format!("bin/{version}"))
.canonicalize()?
.strip_extended_length_path_prefix()?;

let host_windows_sdk_ver_bin_path = match host_arch {
CpuArchitecture::Amd64 => wdk_bin_root
.join(host_arch.as_windows_str())
Expand Down
8 changes: 8 additions & 0 deletions packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.SDK.CPP" version="10.0.26100.1591" targetFramework="native" />
<package id="Microsoft.Windows.SDK.CPP.x64" version="10.0.26100.1591" targetFramework="native" />
<package id="Microsoft.Windows.SDK.CPP.arm64" version="10.0.26100.1591" targetFramework="native" />
<package id="Microsoft.Windows.WDK.x64" version="10.0.26100.1591" targetFramework="native" />
<package id="Microsoft.Windows.WDK.arm64" version="10.0.26100.1591" targetFramework="native" />
</packages>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: newline at end of file is missing

15 changes: 1 addition & 14 deletions tests/mixed-package-kmdf-workspace/crates/driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,7 @@ use wdk::println;
#[cfg(not(test))]
use wdk_alloc::WdkAllocator;
use wdk_sys::{
call_unsafe_wdf_function_binding,
ntddk::DbgPrint,
DRIVER_OBJECT,
NTSTATUS,
PCUNICODE_STRING,
ULONG,
UNICODE_STRING,
WCHAR,
WDFDEVICE,
WDFDEVICE_INIT,
WDFDRIVER,
WDF_DRIVER_CONFIG,
WDF_NO_HANDLE,
WDF_NO_OBJECT_ATTRIBUTES,
call_unsafe_wdf_function_binding, ntddk::DbgPrint, DRIVER_OBJECT, NTSTATUS, PCUNICODE_STRING, PDRIVER_OBJECT, ULONG, UNICODE_STRING, WCHAR, WDFDEVICE, WDFDEVICE_INIT, WDFDRIVER, WDF_DRIVER_CONFIG, WDF_NO_HANDLE, WDF_NO_OBJECT_ATTRIBUTES
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker, but I am curious how this reformat wasn't caught sooner by CI/other pipeline checkins.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this change actually needs to be reverted? I suspect that whats going on is that:

  • cargo fmt check is only run at repo root. AFAIU, it traverses files it sees based on cargo-metadata (ie. it only looks in the workspace)
  • the mixed-package-kmdf-workspace is actually its own cargo workspace, so that cargo fmt has no idea it exists

There are some gaps in the top-level examples and tests folders where certain pipelines are not fully covering them. spent some time figuring out what gaps there are (mostly due to changes related to #186 ) and will be adding the rundown to github in a pr

};

#[cfg(not(test))]
Expand Down