Skip to content

Commit

Permalink
Add x86 to CpuArchitecture
Browse files Browse the repository at this point in the history
  • Loading branch information
김희성 committed Dec 13, 2024
1 parent 10a8e37 commit dac89ed
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/wdk-build/rust-driver-makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
7 changes: 7 additions & 0 deletions crates/wdk-build/src/cargo_make.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,13 @@ pub fn setup_path() -> Result<impl IntoIterator<Item = String>, 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()?
Expand Down
9 changes: 9 additions & 0 deletions crates/wdk-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 => {
Expand Down Expand Up @@ -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",
}
Expand All @@ -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,
Expand Down

0 comments on commit dac89ed

Please sign in to comment.