Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0db3c50
feat: enhance error handling with IoError and IoErrorMetadata for imp…
wmmc88 Aug 25, 2025
e3838aa
fix: update output file paths in binding generation functions for imp…
wmmc88 Aug 25, 2025
8e19e70
refactor: simplify include path validation by consolidating logic int…
wmmc88 Aug 26, 2025
13efe5e
test: add unit tests for validate_and_add_include_path function in Co…
wmmc88 Aug 26, 2025
8391aec
fmt
wmmc88 Aug 26, 2025
7346dfd
fix: add verbose flag to Cargo Clippy command for improved output cla…
wmmc88 Aug 26, 2025
0e535f1
ci: update Clippy workflow to explicitly deny warnings
wmmc88 Aug 27, 2025
6653d8a
Merge branch 'main' into io-error-metadata
wmmc88 Sep 9, 2025
51aeab8
Merge remote-tracking branch 'upstream/main' into io-error-metadata
wmmc88 Sep 12, 2025
3476cd9
refactor: rename `validate_and_add_include_path` to `validate_and_add…
wmmc88 Sep 12, 2025
3360c6a
refactor: remove unused `HeaderNotFound` variant from `ConfigError` enum
wmmc88 Sep 12, 2025
429931a
refactor: conditional compilation of wdk-sys bindings
wmmc88 Aug 28, 2025
fe98e3a
refactor: simplify API subset handling and improve task management in…
wmmc88 Sep 15, 2025
ec3987e
Merge remote-tracking branch 'upstream/main' into io-error-metadata
wmmc88 Sep 15, 2025
70c4643
Merge remote-tracking branch 'upstream/main' into io-error-metadata
wmmc88 Sep 22, 2025
507ab3c
fix: update bindgen header contents to include all enabled API subsets
wmmc88 Sep 23, 2025
77cdbf6
address cr comments
wmmc88 Oct 3, 2025
856bdf0
fix typos
wmmc88 Oct 3, 2025
24c78a8
fix: clarify comment on path validation in `windows_extended_length_p…
wmmc88 Oct 3, 2025
bb65598
fix: improve error handling and update function signatures in WDF gen…
wmmc88 Oct 3, 2025
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
115 changes: 84 additions & 31 deletions crates/wdk-build/src/cargo_make.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ use crate::{
utils::{detect_wdk_content_root, detect_windows_sdk_version, get_wdk_version_number},
ConfigError,
CpuArchitecture,
IoError,
IoErrorMetadata,
};

/// The filename of the main makefile for Rust Windows drivers.
Expand Down Expand Up @@ -520,22 +522,38 @@ pub fn setup_path() -> Result<impl IntoIterator<Item = String>, ConfigError> {

let wdk_bin_root = get_wdk_bin_root(&wdk_content_root, &sdk_version);

let host_windows_sdk_ver_bin_path = absolute(wdk_bin_root.join(host_arch.as_windows_str()))?
.to_str()
.expect("WDK bin path should be valid UTF-8")
.to_string();

let x86_windows_sdk_ver_bin_path = absolute(wdk_bin_root.join("x86"))?
.to_str()
.expect("WDK x86 bin path should be valid UTF-8")
.to_string();
let host_windows_sdk_ver_bin_path = {
let path = wdk_bin_root.join(host_arch.as_windows_str());
absolute(&path).map_err(|source| IoError {
metadata: IoErrorMetadata::SinglePath { path },
source,
})
}?
.to_str()
.expect("WDK bin path should be valid UTF-8")
.to_string();

let x86_windows_sdk_ver_bin_path = {
let path = wdk_bin_root.join("x86");
absolute(&path).map_err(|source| IoError {
metadata: IoErrorMetadata::SinglePath { path },
source,
})
}?
.to_str()
.expect("WDK x86 bin path should be valid UTF-8")
.to_string();

if let Ok(sdk_bin_path) = env::var("WindowsSdkBinPath") {
let sdk_bin_path = absolute(
PathBuf::from(sdk_bin_path)
let sdk_bin_path = {
let path = PathBuf::from(sdk_bin_path)
.join(&sdk_version)
.join(host_arch.as_windows_str()),
)?
.join(host_arch.as_windows_str());
absolute(&path).map_err(|source| IoError {
metadata: IoErrorMetadata::SinglePath { path },
source,
})
}?
.to_str()
.expect("WindowsSdkBinPath should be valid UTF-8")
.to_string();
Expand All @@ -548,11 +566,16 @@ pub fn setup_path() -> Result<impl IntoIterator<Item = String>, ConfigError> {
);

let wdk_tool_root = get_wdk_tools_root(&wdk_content_root, sdk_version);
let host_windows_sdk_version_tool_path =
absolute(wdk_tool_root.join(host_arch.as_windows_str()))?
.to_str()
.expect("WDK tool path should be valid UTF-8")
.to_string();
let host_windows_sdk_version_tool_path = {
let path = wdk_tool_root.join(host_arch.as_windows_str());
absolute(&path).map_err(|source| IoError {
metadata: IoErrorMetadata::SinglePath { path },
source,
})
}?
.to_str()
.expect("WDK tool path should be valid UTF-8")
.to_string();
prepend_to_semicolon_delimited_env_var(PATH_ENV_VAR, host_windows_sdk_version_tool_path);

Ok([PATH_ENV_VAR].map(ToString::to_string))
Expand Down Expand Up @@ -719,15 +742,26 @@ pub fn copy_to_driver_package_folder<P: AsRef<Path>>(path_to_copy: P) -> Result<
let package_folder_path: PathBuf =
get_wdk_build_output_directory().join(format!("{}_package", get_current_package_name()));
if !package_folder_path.exists() {
std::fs::create_dir(&package_folder_path)?;
std::fs::create_dir(&package_folder_path).map_err(|source| IoError {
metadata: IoErrorMetadata::SinglePath {
path: package_folder_path.clone(),
},
source,
})?;
}

let destination_path = package_folder_path.join(
path_to_copy
.file_name()
.expect("path_to_copy should always end with a valid file or directory name"),
);
std::fs::copy(path_to_copy, destination_path)?;
std::fs::copy(path_to_copy, &destination_path).map_err(|source| IoError {
metadata: IoErrorMetadata::SrcDestPaths {
from_path: path_to_copy.to_path_buf(),
to_path: destination_path,
},
source,
})?;

Ok(())
}
Expand Down Expand Up @@ -838,7 +872,8 @@ fn load_wdk_build_makefile<S: AsRef<str> + AsRef<Utf8Path> + AsRef<Path> + fmt::
.manifest_path
.parent()
.expect("The parsed manifest_path should have a valid parent directory")
.join(&makefile_name);
.join(&makefile_name)
.into_std_path_buf();

let cargo_make_workspace_working_directory =
env::var(CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY_ENV_VAR).unwrap_or_else(|_| {
Expand All @@ -852,18 +887,36 @@ fn load_wdk_build_makefile<S: AsRef<str> + AsRef<Utf8Path> + AsRef<Path> + fmt::
// Only create a new symlink if the existing one is not already pointing to the
// correct file
if !destination_path.exists() {
return Ok(std::os::windows::fs::symlink_file(
rust_driver_makefile_toml_path,
destination_path,
)?);
std::os::windows::fs::symlink_file(&rust_driver_makefile_toml_path, &destination_path)
.map_err(|source| IoError {
metadata: IoErrorMetadata::SrcDestPaths {
from_path: rust_driver_makefile_toml_path.clone(),
to_path: destination_path,
},
source,
})?;
} else if !destination_path.is_symlink()
|| std::fs::read_link(&destination_path)? != rust_driver_makefile_toml_path
|| std::fs::read_link(&destination_path).map_err(|source| IoError {
metadata: IoErrorMetadata::SinglePath {
path: destination_path.clone(),
},
source,
})? != rust_driver_makefile_toml_path
{
std::fs::remove_file(&destination_path)?;
return Ok(std::os::windows::fs::symlink_file(
rust_driver_makefile_toml_path,
destination_path,
)?);
std::fs::remove_file(&destination_path).map_err(|source| IoError {
metadata: IoErrorMetadata::SinglePath {
path: destination_path.clone(),
},
source,
})?;
std::os::windows::fs::symlink_file(&rust_driver_makefile_toml_path, &destination_path)
.map_err(|source| IoError {
metadata: IoErrorMetadata::SrcDestPaths {
from_path: rust_driver_makefile_toml_path.clone(),
to_path: destination_path.clone(),
},
source,
})?;
}

// Symlink is already up to date
Expand Down
Loading
Loading