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 46 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
86 changes: 86 additions & 0 deletions .github/scripts/nuget-install-wdk.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
nuget restore .\packages.config -PackagesDirectory C:\WDK
Write-Host "WDK installed at C:\WDK"
$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.10.0.26100.1591",
"C:\WDK\Microsoft.Windows.SDK.CPP.x64.10.0.26100.1591",
"C:\WDK\Microsoft.Windows.SDK.CPP.arm64.10.0.26100.1591",
"C:\WDK\Microsoft.Windows.WDK.ARM64.10.0.26100.1591",
"C:\WDK\Microsoft.Windows.SDK.CPP.10.0.26100.1591"
)
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.10.0.26100.1591\c\bin\10.0.26100.0\x64\signtool.exe"
$signtoolX86 = "C:\WDK\Microsoft.Windows.SDK.CPP.10.0.26100.1591\c\bin\10.0.26100.0\x86\signtool.exe"
$destinationx64 = "C:\WDK\Microsoft.Windows.WDK.x64.10.0.26100.1591\c\bin\10.0.26100.0\x64"
$destinationX86 = "C:\WDK\Microsoft.Windows.WDK.x64.10.0.26100.1591\c\bin\10.0.26100.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.10.0.26100.1591\c\bin\10.0.26100.0\x86\certmgr.exe"
$certmgrX64 = "C:\WDK\Microsoft.Windows.SDK.CPP.10.0.26100.1591\c\bin\10.0.26100.0\x64\certmgr.exe"
$certmgrARM64 = "C:\WDK\Microsoft.Windows.SDK.CPP.10.0.26100.1591\c\bin\10.0.26100.0\arm64\certmgr.exe"
$destinationx86 = "C:\WDK\Microsoft.Windows.WDK.x64.10.0.26100.1591\c\bin\10.0.26100.0\x86"
$destinationx64 = "C:\WDK\Microsoft.Windows.WDK.x64.10.0.26100.1591\c\bin\10.0.26100.0\x64"
$destinationARM64 = "C:\WDK\Microsoft.Windows.WDK.x64.10.0.26100.1591\c\bin\10.0.26100.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.10.0.26100.1591\c\bin\10.0.26100.0\x86\MakeCert.exe"
$makecertX64 = "C:\WDK\Microsoft.Windows.SDK.CPP.10.0.26100.1591\c\bin\10.0.26100.0\x64\MakeCert.exe"
$makecertARM64 = "C:\WDK\Microsoft.Windows.SDK.CPP.10.0.26100.1591\c\bin\10.0.26100.0\arm64\MakeCert.exe"
$destinationx86 = "C:\WDK\Microsoft.Windows.WDK.x64.10.0.26100.1591\c\bin\10.0.26100.0\x86"
$destinationx64 = "C:\WDK\Microsoft.Windows.WDK.x64.10.0.26100.1591\c\bin\10.0.26100.0\x64"
$destinationARM64 = "C:\WDK\Microsoft.Windows.WDK.x64.10.0.26100.1591\c\bin\10.0.26100.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.10.0.26100.1591\c\Lib\10.0.26100.0\km\arm64" -destinationFolder "C:\WDK\Microsoft.Windows.WDK.x64.10.0.26100.1591\c\Lib\10.0.26100.0\km"
Copy-Folder -sourceFolder "C:\WDK\Microsoft.Windows.WDK.ARM64.10.0.26100.1591\c\Lib\10.0.26100.0\um\arm64" -destinationFolder "C:\WDK\Microsoft.Windows.WDK.x64.10.0.26100.1591\c\Lib\10.0.26100.0\um"
Copy-Folder -sourceFolder "C:\WDK\Microsoft.Windows.WDK.ARM64.10.0.26100.1591\c\Lib\wdf\kmdf\ARM64" -destinationFolder "C:\WDK\Microsoft.Windows.WDK.x64.10.0.26100.1591\c\Lib\wdf\kmdf"
Copy-Folder -sourceFolder "C:\WDK\Microsoft.Windows.WDK.ARM64.10.0.26100.1591\c\Lib\wdf\umdf\ARM64" -destinationFolder "C:\WDK\Microsoft.Windows.WDK.x64.10.0.26100.1591\c\Lib\wdf\umdf"

# Set NugetWdkContentRoot environment variable
$NugetWdkContentRoot = "C:\WDK\Microsoft.Windows.WDK.x64.10.0.26100.1591\c"
Write-Output "NugetWdkContentRoot=$NugetWdkContentRoot" >> $env:GITHUB_ENV
7 changes: 7 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ 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
- Microsoft.Windows.WDK # Latest WDK
Copy link
Collaborator

Choose a reason for hiding this comment

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

Even with nuget, we want to be able to test specific versions of the kit


llvm:
- 17.0.6
Expand Down Expand Up @@ -57,6 +58,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 +67,11 @@ jobs:
Write-Host "Installing ${{ matrix.wdk }}..."
Install-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals -Mode Silent -Force
}

- name: Install ${{ matrix.wdk }} (NuGet)
if: matrix.wdk == 'Microsoft.Windows.WDK'
run: |
./.github/scripts/nuget-install-wdk.ps1

- name: Install Rust Toolchain (${{ matrix.rust_toolchain }})
uses: dtolnay/rust-toolchain@master
Expand Down
7 changes: 7 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
- Microsoft.Windows.WDK # Latest WDK

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,11 @@ jobs:
Install-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals -Mode Silent -Force
}

- name: Install ${{ matrix.wdk }} (NuGet)
if: matrix.wdk == 'Microsoft.Windows.WDK'
run: |
./.github/scripts/nuget-install-wdk.ps1

- name: Install Rust Toolchain (${{ matrix.rust_toolchain }})
uses: dtolnay/rust-toolchain@master
with:
Expand Down
7 changes: 7 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
- Microsoft.Windows.WDK # Latest WDK

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,11 @@ jobs:
Install-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals -Mode Silent -Force
}

- name: Install ${{ matrix.wdk }} (NuGet)
if: matrix.wdk == 'Microsoft.Windows.WDK'
run: |
./.github/scripts/nuget-install-wdk.ps1

- name: Install Rust Toolchain (${{ matrix.rust_toolchain }})
uses: dtolnay/rust-toolchain@master
with:
Expand Down
7 changes: 7 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
- Microsoft.Windows.WDK # Latest WDK

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,11 @@ jobs:
Install-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals -Mode Silent -Force
}

- name: Install ${{ matrix.wdk }} (NuGet)
if: matrix.wdk == 'Microsoft.Windows.WDK'
run: |
./.github/scripts/nuget-install-wdk.ps1

- name: Install Rust Toolchain (${{ matrix.rust_toolchain }})
uses: dtolnay/rust-toolchain@master
with:
Expand Down
7 changes: 7 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
- Microsoft.Windows.WDK # Latest WDK

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,11 @@ jobs:
Install-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals -Mode Silent -Force
}

- name: Install ${{ matrix.wdk }} (NuGet)
if: matrix.wdk == 'Microsoft.Windows.WDK'
run: |
./.github/scripts/nuget-install-wdk.ps1

- name: Install Nightly Rust Toolchain (${{ matrix.target_triple }})
uses: dtolnay/rust-toolchain@nightly
with:
Expand Down
7 changes: 7 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
- Microsoft.Windows.WDK # Latest WDK

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,11 @@ jobs:
Install-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals -Mode Silent -Force
}

- name: Install ${{ matrix.wdk }} (NuGet)
if: matrix.wdk == 'Microsoft.Windows.WDK'
run: |
./.github/scripts/nuget-install-wdk.ps1

- name: Install Rust Toolchain (${{ matrix.rust_toolchain }})
uses: dtolnay/rust-toolchain@master
with:
Expand Down
9 changes: 7 additions & 2 deletions crates/wdk-build/src/cargo_make.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,14 +516,19 @@ 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()?;
.canonicalize()
wmmc88 marked this conversation as resolved.
Show resolved Hide resolved
.expect("Failed to canonicalize path")
.strip_extended_length_path_prefix()
.expect("Failed to 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
13 changes: 13 additions & 0 deletions crates/wdk-build/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,19 @@ pub fn detect_wdk_content_root() -> Option<PathBuf> {
);
}

// If NugetWdkContentRoot is present in environment, use it
if let Ok(wdk_content_root) = env::var("NugetWdkContentRoot") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we should be doing custom handling here for nuget since NugetWdkContentRoot doesn't exist normally for the Kit. How does building with nuget generally work in a non-rust environment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I understand. The C samples use the Build-SampleSet.ps1 script. Adding the NugetWdkContentRoot was one of the ways to point to the NuGet pkg root. I'm not fully aware of how msbuild works with NuGet pkgs and how SxS WDK installations work.

Copy link
Collaborator

@wmmc88 wmmc88 Oct 14, 2024

Choose a reason for hiding this comment

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

I very much do not want to add new scaffolding to windows-drivers-rs when existing mechanisms exist. In order to make sure this doesn't diverge from the original kit, I think you need to find out how C/C++ WDK handles pointing to the WDKContentRoot when using the new nuget install methods. For eWDK, we check for the env vars that eWDK prompts set. For installed WDK, we look for the reg keys that the WDK installer sets. For nuget, we should use whatever mechanism DDX has for nuget for root discovery. @NateD-MSFT do you have insight/contacts for this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll spin up a thread with the WDK team to ask.

let path = Path::new(wdk_content_root.as_str());
if path.is_dir() {
return Some(path.to_path_buf());
}
eprintln!(
"NugetWdkContentRoot was detected to be {}, but does not exist or is not a valid \
directory.",
path.display()
);
}

// If MicrosoftKitRoot environment variable is set, use it to set WDKContentRoot
if let Ok(microsoft_kit_root) = env::var("MicrosoftKitRoot") {
let path = Path::new(microsoft_kit_root.as_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
Loading