Skip to content

Commit 4d4f997

Browse files
authored
feat!: expand wdk-sys coverage to include hid-related headers (#260)
Signed-off-by: Melvin Wang <[email protected]>
1 parent 54b0fd4 commit 4d4f997

File tree

35 files changed

+503
-284
lines changed

35 files changed

+503
-284
lines changed

.github/workflows/build.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
targets: ${{ matrix.target_triple }}
7474

7575
- name: Run Cargo Build
76-
run: cargo +${{ matrix.rust_toolchain }} build --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }} --workspace
76+
run: cargo +${{ matrix.rust_toolchain }} build --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }} --workspace --all-features
7777

7878
- name: Install Cargo Make
7979
uses: taiki-e/install-action@v2

.github/workflows/code-formatting-check.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ on:
66
schedule: # Trigger a job on default branch at 4AM PST everyday
77
- cron: 0 11 * * *
88

9-
109
jobs:
1110
cargo-fmt:
1211
name: .rs Formatting Check

.github/workflows/codeql.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989

9090
- if: matrix.build-mode == 'manual'
9191
working-directory: ./examples
92-
run: cargo +${{ matrix.rust_toolchain }} make default --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }} --workspace
92+
run: cargo +${{ matrix.rust_toolchain }} make default --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }} --workspace --all-features
9393

9494
- name: Perform CodeQL Analysis
9595
uses: github/codeql-action/analyze@v3

.github/workflows/docs.yaml

+2-12
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,9 @@ jobs:
7272

7373
- name: Run Cargo Doc
7474
# proc-macro crates must be excluded to avoid cargo doc bug: https://github.com/rust-lang/cargo/issues/10368
75-
run: cargo +${{ matrix.rust_toolchain }} doc --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }} --workspace --exclude wdk-macros
76-
77-
- name: Run Cargo Doc (--features nightly)
78-
if: matrix.rust_toolchain == 'nightly'
79-
# proc-macro crates must be excluded to avoid cargo doc bug: https://github.com/rust-lang/cargo/issues/10368
80-
run: cargo +${{ matrix.rust_toolchain }} doc --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }} --workspace --exclude wdk-macros --features nightly
75+
run: cargo +${{ matrix.rust_toolchain }} doc --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }} --workspace --exclude wdk-macros --all-features
8176

8277
- name: Run Cargo Doc w/ proc-macro crates
8378
if: matrix.target_triple == 'x86_64-pc-windows-msvc'
8479
# cargo doc can only generate documentation for proc-macro crates when --target is not specified due to a cargo doc bug: https://github.com/rust-lang/cargo/issues/7677
85-
run: cargo +${{ matrix.rust_toolchain }} doc --locked --profile ${{ matrix.cargo_profile }}
86-
87-
- name: Run Cargo Doc w/ proc-macro crates (--features nightly)
88-
if: ${{ matrix.target_triple == 'x86_64-pc-windows-msvc' && matrix.rust_toolchain == 'nightly' }}
89-
# cargo doc can only generate documentation for proc-macro crates when --target is not specified due to a cargo doc bug: https://github.com/rust-lang/cargo/issues/7677
90-
run: cargo +${{ matrix.rust_toolchain }} doc --locked --profile ${{ matrix.cargo_profile }} --features nightly
80+
run: cargo +${{ matrix.rust_toolchain }} doc --locked --profile ${{ matrix.cargo_profile }} --all-features

.github/workflows/lint.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77

88
name: Lint
99

10+
env:
11+
RUSTFLAGS: >-
12+
-D warnings
13+
1014
jobs:
1115
clippy:
1216
name: Clippy
@@ -71,11 +75,7 @@ jobs:
7175
targets: ${{ matrix.target_triple }}
7276

7377
- name: Run Cargo Clippy
74-
run: cargo +${{ matrix.rust_toolchain }} clippy --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }} --all-targets -- -D warnings
75-
76-
- name: Run Cargo Clippy (--features nightly)
77-
if: matrix.rust_toolchain == 'nightly'
78-
run: cargo +${{ matrix.rust_toolchain }} clippy --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }} --all-targets --features nightly -- -D warnings
78+
run: cargo +${{ matrix.rust_toolchain }} clippy --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }} --all-targets --all-features
7979

8080
unused_deps:
8181
name: Detect Unused Cargo Dependencies

.github/workflows/test.yaml

+1-5
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,4 @@ jobs:
7373
7474

7575
- name: Run Cargo Test
76-
run: cargo +${{ matrix.rust_toolchain }} test --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }}
77-
78-
- name: Run Cargo Test (--features nightly)
79-
if: matrix.rust_toolchain == 'nightly'
80-
run: cargo +${{ matrix.rust_toolchain }} test --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }} --features nightly
76+
run: cargo +${{ matrix.rust_toolchain }} test --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }} --all-features

.vscode/settings.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
"./tests/umdf-driver-workspace/Cargo.toml",
2020
"./tests/wdk-macros-tests/Cargo.toml",
2121
"./tests/wdk-sys-tests/Cargo.toml",
22-
]
23-
}
22+
],
23+
"rust-analyzer.cargo.features": "all"
24+
}

CONTRIBUTING.md

+7-9
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,8 @@ The following tools should be installed as a part of the `windows-drivers-rs` de
9696
9797
### Generating Documentation
9898
99-
* To compile and open documentation: `cargo doc --locked --open`
100-
* To include nightly features: `cargo +nightly doc --locked --open --features nightly`
101-
* To open docs for non-host architecture: `cargo doc --locked --open --target <target-triple> --workspace --exclude wdk-macros`
99+
* To compile and open documentation: `cargo doc --locked --all-features --open`
100+
* To open docs for non-host architecture: `cargo doc --locked --all-features --open --target <target-triple> --workspace --exclude wdk-macros`
102101
* `--target` is incompatible with `proc-macro` crates due to a [cargo bug](https://github.com/rust-lang/cargo/issues/10368)
103102
104103
### Policy on using Nightly/Unstable Features
@@ -113,7 +112,7 @@ The crates in this repository are designed to work with `stable` rust. Some of t
113112
114113
### Build and Test
115114
116-
To **only build** the workspace: `cargo build`
115+
To **only build** the workspace: `cargo build --locked --all-features`
117116
118117
To **both** build and package the samples in the workspace: `cargo make --cwd .\crates\<driver-name>`
119118
@@ -123,13 +122,13 @@ To maintain the quality of code, tests and tools are required to pass before con
123122
124123
**_Functional Correctness:_**
125124
126-
* `cargo test --locked`
125+
* `cargo test --locked --all-features`
127126
* To test `nightly` features: `cargo +nightly test --locked --features nightly`
128127
129128
**_Static Analysis and Linting:_**
130129
131-
* `cargo clippy --locked --all-targets -- -D warnings`
132-
* To lint `nightly` features: `cargo +nightly clippy --locked --all-targets --features nightly -- -D warnings`
130+
* `cargo clippy --locked --all-features --all-targets -- -D warnings`
131+
* To lint `nightly` features: `cargo +nightly clippy --locked --all-features --all-targets --features nightly -- -D warnings`
133132
134133
**_Formatting:_**
135134
@@ -146,8 +145,7 @@ To maintain the quality of code, tests and tools are required to pass before con
146145
147146
**_Rust Documentation Build Test_**
148147
149-
* `cargo doc --locked`
150-
* To build docs for `nightly` features: `cargo +nightly doc --locked --features nightly`
148+
* `cargo doc --locked --all-features`
151149
152150
### A Note on Code-Style
153151

Cargo.lock

+12-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ wdk-sys = { path = "crates/wdk-sys", version = "0.3.0" }
3737

3838
# External Crates
3939
anyhow = "1.0.95"
40-
bindgen = "0.69.4"
40+
bindgen = "0.69.5"
4141
camino = "1.1.9"
4242
cargo_metadata = "0.18.1"
4343
cc = "1.2.10"

Makefile.toml

+3-4
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ additional_profiles = ["all-default-tasks"]
66

77
[env]
88
CARGO_MAKE_SKIP_SLOW_SECONDARY_FLOWS = false
9-
CARGO_MAKE_CLIPPY_ARGS = "--all-targets -- -D warnings"
10-
RUSTFLAGS = "-D warnings"
9+
CARGO_MAKE_CARGO_BUILD_TEST_FLAGS = "${CARGO_MAKE_CARGO_ALL_FEATURES}"
10+
CARGO_MAKE_CLIPPY_ARGS = "--all-targets --all-features"
1111
CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN = "stable"
12+
RUSTFLAGS = "-D warnings"
1213
RUSTDOCFLAGS = "-D warnings"
1314

1415
[tasks.wdk-pre-commit-flow]
@@ -71,12 +72,10 @@ alias = "pre-test"
7172

7273
[tasks.nightly-test]
7374
extend = "test"
74-
env = { CARGO_MAKE_CARGO_BUILD_TEST_FLAGS = "--features nightly" }
7575
toolchain = "nightly"
7676

7777
[tasks.post-nightly-test]
7878
extend = "post-test"
79-
env = { CARGO_MAKE_CARGO_BUILD_TEST_FLAGS = { unset = true } }
8079

8180
[tasks.nightly-clippy-flow]
8281
extend = "clippy-flow"

crates/wdk-build/src/bindgen.rs

+5-17
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ pub trait BuilderExt {
2020
///
2121
/// Implementation may return `wdk_build::ConfigError` if it fails to create
2222
/// a builder
23-
fn wdk_default(
24-
c_header_files: Vec<&str>,
25-
config: impl Borrow<Config>,
26-
) -> Result<Builder, ConfigError>;
23+
fn wdk_default(config: impl Borrow<Config>) -> Result<Builder, ConfigError>;
2724
}
2825

2926
#[derive(Debug)]
@@ -39,19 +36,10 @@ impl BuilderExt for Builder {
3936
///
4037
/// Will return `wdk_build::ConfigError` if any of the resolved include or
4138
/// library paths do not exist
42-
fn wdk_default(
43-
c_header_files: Vec<&str>,
44-
config: impl Borrow<Config>,
45-
) -> Result<Self, ConfigError> {
39+
fn wdk_default(config: impl Borrow<Config>) -> Result<Self, ConfigError> {
4640
let config = config.borrow();
4741

48-
let mut builder = Self::default();
49-
50-
for c_header in c_header_files {
51-
builder = builder.header(c_header);
52-
}
53-
54-
builder = builder
42+
let builder = Self::default()
5543
.use_core() // Can't use std for kernel code
5644
.derive_default(true) // allows for default initializing structs
5745
// CStr types are safer and easier to work with when interacting with string constants
@@ -60,7 +48,7 @@ impl BuilderExt for Builder {
6048
// Building in eWDK can pollute system search path when clang-sys tries to detect
6149
// c_search_paths
6250
.detect_include_paths(false)
63-
.clang_args(config.get_include_paths()?.iter().map(|include_path| {
51+
.clang_args(config.include_paths()?.map(|include_path| {
6452
format!(
6553
"--include-directory={}",
6654
include_path
@@ -70,7 +58,7 @@ impl BuilderExt for Builder {
7058
}))
7159
.clang_args(
7260
config
73-
.get_preprocessor_definitions_iter()
61+
.preprocessor_definitions()
7462
.map(|(key, value)| {
7563
format!(
7664
"--define-macro={key}{}",

0 commit comments

Comments
 (0)