diff --git a/crates/wdk-build/rust-driver-makefile.toml b/crates/wdk-build/rust-driver-makefile.toml index 903af810..5db860a9 100644 --- a/crates/wdk-build/rust-driver-makefile.toml +++ b/crates/wdk-build/rust-driver-makefile.toml @@ -271,7 +271,7 @@ std::fs::copy(&source_file, &destination_file).expect(&format!( [tasks.stampinf] private = true dependencies = ["setup-wdk-config-env-vars", "copy-inx-to-output"] -env = { "WDK_BUILD_STAMPINF_WDF_FLAGS" = { source = "${WDK_BUILD_METADATA-DRIVER_MODEL-DRIVER_TYPE}", default_value = "", mapping = { "KMDF" = "-k ${WDK_BUILD_METADATA-DRIVER_MODEL-KMDF_VERSION_MAJOR}.${WDK_BUILD_METADATA-DRIVER_MODEL-TARGET_KMDF_VERSION_MINOR}", "UMDF" = "-u ${WDK_BUILD_METADATA-DRIVER_MODEL-UMDF_VERSION_MAJOR}.${WDK_BUILD_METADATA-DRIVER_MODEL-TARGET_UMDF_VERSION_MINOR}.0" } }, "WDK_BUILD_STAMPINF_ARCH" = { source = "${CARGO_MAKE_CRATE_TARGET_TRIPLE}", default_value = "UNKNOWN", mapping = { "x86_64-pc-windows-msvc" = "amd64", "aarch64-pc-windows-msvc" = "arm64" } } } +env = { "WDK_BUILD_STAMPINF_WDF_FLAGS" = { source = "${WDK_BUILD_METADATA-DRIVER_MODEL-DRIVER_TYPE}", default_value = "", mapping = { "KMDF" = "-k ${WDK_BUILD_METADATA-DRIVER_MODEL-KMDF_VERSION_MAJOR}.${WDK_BUILD_METADATA-DRIVER_MODEL-TARGET_KMDF_VERSION_MINOR}", "UMDF" = "-u ${WDK_BUILD_METADATA-DRIVER_MODEL-UMDF_VERSION_MAJOR}.${WDK_BUILD_METADATA-DRIVER_MODEL-TARGET_UMDF_VERSION_MINOR}.0" } }, "WDK_BUILD_STAMPINF_ARCH" = { source = "${CARGO_MAKE_CRATE_TARGET_TRIPLE}", default_value = "UNKNOWN", mapping = { "i686-pc-windows-msvc" = "x86", "x86_64-pc-windows-msvc" = "amd64", "aarch64-pc-windows-msvc" = "arm64" } } } command = "stampinf" args = [ "-f", @@ -396,7 +396,7 @@ wdk_build::cargo_make::copy_to_driver_package_folder( [tasks.inf2cat] private = true dependencies = ["copy-driver-binary-to-package", "copy-inf-to-package"] -env = { "WDK_BUILD_INF2CAT_OS" = { source = "${CARGO_MAKE_CRATE_TARGET_TRIPLE}", default_value = "UNKNOWN", mapping = { "x86_64-pc-windows-msvc" = "10_x64", "aarch64-pc-windows-msvc" = "Server10_arm64" } } } +env = { "WDK_BUILD_INF2CAT_OS" = { source = "${CARGO_MAKE_CRATE_TARGET_TRIPLE}", default_value = "UNKNOWN", mapping = { "i686-pc-windows-msvc" = "10_x86", "x86_64-pc-windows-msvc" = "10_x64", "aarch64-pc-windows-msvc" = "Server10_arm64" } } } command = "inf2cat" args = [ "/driver:${WDK_BUILD_OUTPUT_DIRECTORY}/${CARGO_MAKE_CRATE_FS_NAME}_package", diff --git a/crates/wdk-build/src/cargo_make.rs b/crates/wdk-build/src/cargo_make.rs index 26be9942..c5410f3a 100644 --- a/crates/wdk-build/src/cargo_make.rs +++ b/crates/wdk-build/src/cargo_make.rs @@ -525,6 +525,13 @@ pub fn setup_path() -> Result, ConfigError> { .canonicalize()? .strip_extended_length_path_prefix()?; let host_windows_sdk_ver_bin_path = match host_arch { + CpuArchitecture::X86 => wdk_bin_root + .join(host_arch.as_windows_str()) + .canonicalize()? + .strip_extended_length_path_prefix()? + .to_str() + .expect("x86 host_windows_sdk_ver_bin_path should only contain valid UTF8") + .to_string(), CpuArchitecture::Amd64 => wdk_bin_root .join(host_arch.as_windows_str()) .canonicalize()? diff --git a/crates/wdk-build/src/lib.rs b/crates/wdk-build/src/lib.rs index db2e8aa8..f96cf57b 100644 --- a/crates/wdk-build/src/lib.rs +++ b/crates/wdk-build/src/lib.rs @@ -80,6 +80,8 @@ enum DeserializableDriverConfig { /// The CPU architecture that's configured to be compiled for #[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)] pub enum CpuArchitecture { + /// Intel CPU architecture. Also known as i386 or i586 or i686. + X86, /// AMD64 CPU architecture. Also known as x64 or x86-64. Amd64, /// ARM64 CPU architecture. Also known as aarch64. @@ -520,6 +522,11 @@ impl Config { // .into_iter() // .map(|(key, value)| (key.to_string(), value.map(|v| v.to_string()))) match self.cpu_architecture { + // Definitions sourced from `Program Files\Windows + // Kits\10\build\10.0.22621.0\WindowsDriver.win32.props` + CpuArchitecture::X86 => { + vec![("_X86_", None), ("i386", None), ("STD_CALL", None)] + } // Definitions sourced from `Program Files\Windows // Kits\10\build\10.0.22621.0\WindowsDriver.x64.props` CpuArchitecture::Amd64 => { @@ -833,6 +840,7 @@ impl CpuArchitecture { #[must_use] pub const fn as_windows_str(&self) -> &str { match self { + Self::X86 => "x86", Self::Amd64 => "x64", Self::Arm64 => "ARM64", } @@ -846,6 +854,7 @@ impl CpuArchitecture { // Specifically not using the [`std::convert::TryFrom`] trait to be more // explicit in function name, since only arch strings from cargo are handled. match cargo_str.as_ref() { + "x86" => Some(Self::X86), "x86_64" => Some(Self::Amd64), "aarch64" => Some(Self::Arm64), _ => None,