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

feat: expand wdk-sys coverage to include spb-related headers #263

Draft
wants to merge 25 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
88ff017
add _KERNEL_MODE flag to clang parsing
wmmc88 Sep 28, 2023
07f1222
add initial pass of hid apis
wmmc88 Sep 28, 2023
c52b2f3
fix merge conflict
wmmc88 Sep 23, 2024
0915e18
Merge remote-tracking branch 'upstream/main' into hid
wmmc88 Oct 7, 2024
b14bdf3
Merge remote-tracking branch 'upstream/main' into hid
wmmc88 Oct 7, 2024
a1a4bf1
refactor wdk_default to not require header files on disk
wmmc88 Oct 15, 2024
af52971
Merge remote-tracking branch 'upstream/main' into hid
wmmc88 Nov 9, 2024
5a93995
refactor to have a single header for bindgen to process
wmmc88 Jan 10, 2025
951c26f
cargo fmt
wmmc88 Jan 10, 2025
9909386
add missing EOL
wmmc88 Jan 10, 2025
38d4b5f
refactor implementation so that apis are always available to `wdk_bui…
wmmc88 Jan 16, 2025
6b6b080
update workflows to use --all-features flag for Cargo commands
wmmc88 Jan 16, 2025
bf2acfb
Merge remote-tracking branch 'upstream/main' into hid
wmmc88 Jan 16, 2025
e777268
resolve clippy errors
wmmc88 Jan 22, 2025
f4f3a40
enable all-features for local cargo make flow
wmmc88 Jan 22, 2025
1e93870
fix rustdoc lint
wmmc88 Jan 22, 2025
826a4bc
refactor!: rename get_include_paths, get_library_paths, and get_prep…
wmmc88 Jan 22, 2025
5783dbf
Merge remote-tracking branch 'upstream/main' into hid
wmmc88 Jan 22, 2025
8e4e4bb
fix formatting
wmmc88 Jan 22, 2025
c02f27a
fix rustdoc error
wmmc88 Jan 22, 2025
5e50505
remove double inclusion of --all-features when invoking cargo make in CI
wmmc88 Jan 22, 2025
7cf3623
address pr comments
wmmc88 Jan 23, 2025
90a52c2
remove redundant -D warnings
wmmc88 Jan 23, 2025
852532a
fix link
wmmc88 Jan 26, 2025
0de1a1a
feat: expand `wdk-sys` coverage to include spb-related headers
wmmc88 Jan 13, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
targets: ${{ matrix.target_triple }}

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

- name: Install Cargo Make
uses: taiki-e/install-action@v2
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/code-formatting-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
schedule: # Trigger a job on default branch at 4AM PST everyday
- cron: 0 11 * * *


jobs:
cargo-fmt:
name: .rs Formatting Check
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:

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

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
Expand Down
14 changes: 2 additions & 12 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,9 @@ jobs:

- name: Run Cargo Doc
# proc-macro crates must be excluded to avoid cargo doc bug: https://github.com/rust-lang/cargo/issues/10368
run: cargo +${{ matrix.rust_toolchain }} doc --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }} --workspace --exclude wdk-macros

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

- name: Run Cargo Doc w/ proc-macro crates
if: matrix.target_triple == 'x86_64-pc-windows-msvc'
# 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
run: cargo +${{ matrix.rust_toolchain }} doc --locked --profile ${{ matrix.cargo_profile }}

- name: Run Cargo Doc w/ proc-macro crates (--features nightly)
if: ${{ matrix.target_triple == 'x86_64-pc-windows-msvc' && matrix.rust_toolchain == 'nightly' }}
# 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
run: cargo +${{ matrix.rust_toolchain }} doc --locked --profile ${{ matrix.cargo_profile }} --features nightly
run: cargo +${{ matrix.rust_toolchain }} doc --locked --profile ${{ matrix.cargo_profile }} --all-features
10 changes: 5 additions & 5 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:

name: Lint

env:
RUSTFLAGS: >-
-D warnings

jobs:
clippy:
name: Clippy
Expand Down Expand Up @@ -71,11 +75,7 @@ jobs:
targets: ${{ matrix.target_triple }}

- name: Run Cargo Clippy
run: cargo +${{ matrix.rust_toolchain }} clippy --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }} --all-targets -- -D warnings

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

unused_deps:
name: Detect Unused Cargo Dependencies
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,4 @@ jobs:
tool: [email protected]

- name: Run Cargo Test
run: cargo +${{ matrix.rust_toolchain }} test --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }}

- name: Run Cargo Test (--features nightly)
if: matrix.rust_toolchain == 'nightly'
run: cargo +${{ matrix.rust_toolchain }} test --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }} --features nightly
run: cargo +${{ matrix.rust_toolchain }} test --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }} --all-features
8 changes: 5 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"rust-analyzer.rustfmt.extraArgs": [
"+nightly"
"+nightly",
"--all"
],
"rust-analyzer.rustfmt.rangeFormatting.enable": true,
"evenBetterToml.formatter.crlf": true,
Expand All @@ -19,5 +20,6 @@
"./tests/umdf-driver-workspace/Cargo.toml",
"./tests/wdk-macros-tests/Cargo.toml",
"./tests/wdk-sys-tests/Cargo.toml",
]
}
],
"rust-analyzer.cargo.features": "all"
}
16 changes: 7 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@ The following tools should be installed as a part of the `windows-drivers-rs` de

### Generating Documentation

* To compile and open documentation: `cargo doc --locked --open`
* To include nightly features: `cargo +nightly doc --locked --open --features nightly`
* To open docs for non-host architecture: `cargo doc --locked --open --target <target-triple> --workspace --exclude wdk-macros`
* To compile and open documentation: `cargo doc --locked --all-features --open`
* To open docs for non-host architecture: `cargo doc --locked --all-features --open --target <target-triple> --workspace --exclude wdk-macros`
* `--target` is incompatible with `proc-macro` crates due to a [cargo bug](https://github.com/rust-lang/cargo/issues/10368)

### Policy on using Nightly/Unstable Features
Expand All @@ -113,7 +112,7 @@ The crates in this repository are designed to work with `stable` rust. Some of t

### Build and Test

To **only build** the workspace: `cargo build`
To **only build** the workspace: `cargo build --locked --all-features`

To **both** build and package the samples in the workspace: `cargo make --cwd .\crates\<driver-name>`

Expand All @@ -123,13 +122,13 @@ To maintain the quality of code, tests and tools are required to pass before con

**_Functional Correctness:_**

* `cargo test --locked`
* `cargo test --locked --all-features`
* To test `nightly` features: `cargo +nightly test --locked --features nightly`

**_Static Analysis and Linting:_**

* `cargo clippy --locked --all-targets -- -D warnings`
* To lint `nightly` features: `cargo +nightly clippy --locked --all-targets --features nightly -- -D warnings`
* `cargo clippy --locked --all-features --all-targets -- -D warnings`
* To lint `nightly` features: `cargo +nightly clippy --locked --all-features --all-targets --features nightly -- -D warnings`

**_Formatting:_**

Expand All @@ -146,8 +145,7 @@ To maintain the quality of code, tests and tools are required to pass before con

**_Rust Documentation Build Test_**

* `cargo doc --locked`
* To build docs for `nightly` features: `cargo +nightly doc --locked --features nightly`
* `cargo doc --locked --all-features`

### A Note on Code-Style

Expand Down
23 changes: 12 additions & 11 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ wdk-sys = { path = "crates/wdk-sys", version = "0.3.0" }

# External Crates
anyhow = "1.0.95"
bindgen = "0.69.4"
bindgen = "0.69.5"
camino = "1.1.9"
cargo_metadata = "0.18.1"
cc = "1.2.9"
Expand Down
7 changes: 3 additions & 4 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ additional_profiles = ["all-default-tasks"]

[env]
CARGO_MAKE_SKIP_SLOW_SECONDARY_FLOWS = false
CARGO_MAKE_CLIPPY_ARGS = "--all-targets -- -D warnings"
RUSTFLAGS = "-D warnings"
CARGO_MAKE_CARGO_BUILD_TEST_FLAGS = "${CARGO_MAKE_CARGO_ALL_FEATURES}"
CARGO_MAKE_CLIPPY_ARGS = "--all-targets --all-features"
CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN = "stable"
RUSTFLAGS = "-D warnings"
RUSTDOCFLAGS = "-D warnings"

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

[tasks.nightly-test]
extend = "test"
env = { CARGO_MAKE_CARGO_BUILD_TEST_FLAGS = "--features nightly" }
toolchain = "nightly"

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

[tasks.nightly-clippy-flow]
extend = "clippy-flow"
Expand Down
22 changes: 5 additions & 17 deletions crates/wdk-build/src/bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ pub trait BuilderExt {
///
/// Implementation may return `wdk_build::ConfigError` if it fails to create
/// a builder
fn wdk_default(
c_header_files: Vec<&str>,
config: impl Borrow<Config>,
) -> Result<Builder, ConfigError>;
fn wdk_default(config: impl Borrow<Config>) -> Result<Builder, ConfigError>;
}

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

let mut builder = Self::default();

for c_header in c_header_files {
builder = builder.header(c_header);
}

builder = builder
let builder = Self::default()
.use_core() // Can't use std for kernel code
.derive_default(true) // allows for default initializing structs
// CStr types are safer and easier to work with when interacting with string constants
Expand All @@ -60,7 +48,7 @@ impl BuilderExt for Builder {
// Building in eWDK can pollute system search path when clang-sys tries to detect
// c_search_paths
.detect_include_paths(false)
.clang_args(config.get_include_paths()?.iter().map(|include_path| {
.clang_args(config.include_paths()?.map(|include_path| {
format!(
"--include-directory={}",
include_path
Expand All @@ -70,7 +58,7 @@ impl BuilderExt for Builder {
}))
.clang_args(
config
.get_preprocessor_definitions_iter()
.preprocessor_definitions()
.map(|(key, value)| {
format!(
"--define-macro={key}{}",
Expand Down
Loading
Loading