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

test clippy pipeline #38

Closed
wants to merge 4 commits into from
Closed
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
5 changes: 3 additions & 2 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ jobs:
clippy:
name: Clippy
runs-on: windows-latest
permissions:
checks: write
permissions: write-all
# permissions:
# checks: write
strategy:
matrix:
wdk:
Expand Down
124 changes: 124 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extend = "./rust-driver-makefile.toml"
38 changes: 37 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# windows-drivers-rs


This repo is a collection of Rust crates that enable developers to develop Windows Drivers in Rust. It is the intention to support both WDM and WDF driver development models. This repo contains the following crates:

* [wdk-build](./crates/wdk-build): A library to configure a Cargo build script for binding generation and downstream linking of the WDK (Windows Driver Kit). While this crate is written to be flexible with different WDK releases and different WDF version, it is currently only tested for NI eWDK, KMDF 1.33, UMDF 2.33, and WDM Drivers. There may be missing linker options for older DDKs.
Expand Down Expand Up @@ -147,7 +146,44 @@ The crates in this repository are available from [`crates.io`](https://crates.io

A `DriverCertificate.cer` file will be generated, and a signed driver package will be available at `target/<Cargo profile>/package`

## Cargo Make

[`cargo-make`](https://github.com/sagiegurari/cargo-make) is used to facilitate builds using `windows-drivers-rs`, including for executing post-build driver packaging steps.

To execute the default action (build and package driver):

`cargo make default`

When executing the default task, just `cargo make` make also works since the `default` task is implied.

### Argument Forwarding

`windows-drivers-rs` extends `cargo make` to forward specific arguements to the underlying `cargo` commands. In order to specify arguments to forward, they must be provided **after explicitly specifying the `cargo-make` task name** (ie. omitting the name for the `default` task is not supported).

#### Examples

For a specific target:

`cargo make default --target <TARGET TRIPLE>`

For release builds:

`cargo make default --release` or `cargo make default --profile release`

To specify specific features:

`cargo make default --feature <FEATURES>`

To specify a specific rust toolchain:

`cargo make default +<TOOLCHAIN>`

To display help and see the full list of supported CLI args to forward to Cargo:

`cargo make help`

## Crates.io Release Policy

Releases to crates.io are not made after every change merged to main. Releases will only be made when requested by the community, or when the `windows-drivers-rs` team believes there is sufficient value in pushing a release.

## Trademark Notice
Expand Down
2 changes: 2 additions & 0 deletions crates/wdk-build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ categories = ["development-tools::build-utils", "development-tools::ffi"]
bindgen.workspace = true
serde.workspace = true
serde_json.workspace = true
clap = { version = "4.4.7", features = ["derive"] }
clap-cargo = "0.13.0"
thiserror = "1.0.48"
windows = { version = "0.51.1", features = [
"Win32_Foundation",
Expand Down
22 changes: 17 additions & 5 deletions crates/wdk-build/src/bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,22 @@ impl BuilderExt for Builder {
.expect("Non Unicode paths are not supported")
)
}))
.clang_arg(format!(
"--define-macro={}",
.clang_args(
match config.cpu_architecture {
CPUArchitecture::AMD64 => "_AMD64_",
CPUArchitecture::ARM64 => "_ARM64EC_",
// Definitions sourced from `Program Files\Windows
// Kits\10\build\10.0.22621.0\WindowsDriver.x64.props`
CPUArchitecture::AMD64 => {
vec!["_WIN64", "_AMD64_", "AMD64"]
}
// Definitions sourced from `Program Files\Windows
// Kits\10\build\10.0.22621.0\WindowsDriver.arm64.props`
CPUArchitecture::ARM64 => {
vec!["_ARM64_", "ARM64", "_USE_DECLSPECS_FOR_SAL=1", "STD_CALL"]
}
}
))
.iter()
.map(|preprocessor_definition| format!("--define-macro={preprocessor_definition}")),
)
.clang_args(
match config.driver_config {
// FIXME: Add support for KMDF_MINIMUM_VERSION_REQUIRED and
Expand Down Expand Up @@ -100,6 +109,9 @@ impl BuilderExt for Builder {
// below and if there are any non-blocklisted function definitions, it will throw a
// -WDeprecated warning
.clang_arg("--warn-=no-deprecated-declarations")
// Windows SDK & DDK contain unnecessary token pasting (ex. &##_variable: `&` and
// `_variable` are seperate tokens already, and don't need `##` to concatenate them)
.clang_arg("--warn-=no-invalid-token-paste")
.clang_arg("-fms-extensions")
.blocklist_item("ExAllocatePoolWithTag") // Deprecated
.blocklist_item("ExAllocatePoolWithQuotaTag") // Deprecated
Expand Down
Loading
Loading