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

Add x86 to CpuArchitecture #255

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
- release

target_triple:
- i686-pc-windows-msvc
- x86_64-pc-windows-msvc
- aarch64-pc-windows-msvc

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
- release

target_triple:
- i686-pc-windows-msvc
- x86_64-pc-windows-msvc
- aarch64-pc-windows-msvc

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
- release

target_triple:
- i686-pc-windows-msvc
- x86_64-pc-windows-msvc
- aarch64-pc-windows-msvc

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
- release

target_triple:
- i686-pc-windows-msvc
- x86_64-pc-windows-msvc
- aarch64-pc-windows-msvc

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/local-development-makefile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
- 17.0.6

target_triple:
- i686-pc-windows-msvc
- x86_64-pc-windows-msvc
# - aarch64-pc-windows-msvc FIXME: find a way to validate the local makefile on aarch64

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
- release

target_triple:
- i686-pc-windows-msvc
- x86_64-pc-windows-msvc
# - aarch64-pc-windows-msvc FIXME: Add support for executing ARM64 tests. Maybe use target specific test runner in emulator: https://doc.rust-lang.org/cargo/reference/config.html#target

Expand Down
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