Skip to content

Commit

Permalink
Fix fork main (#25)
Browse files Browse the repository at this point in the history
* refactor: add lint exceptions for clippy::manual_c_str_literals and clippy::ref_as_ptr (microsoft#108)

* ci: fix various pipeline breakages (nightly rustfmt bug, new nightly clippy lints, upstream winget dependency issue) (microsoft#117)

* docs: fix `winget` llvm install command option (microsoft#115)

Signed-off-by: Nicholas Rishel <rishel.nick@gmail.com>
Co-authored-by: Melvin Wang <melvin.mc.wang@gmail.com>

* fix!: prevent linking of wdk libraries in tests that depend on `wdk-sys` (microsoft#118)

* refactor: change version bounds for `manual_c_str_literals` and `ref_as_ptr` clippy lints (microsoft#127)

Signed-off-by: Melvin Wang <melvin.mc.wang@gmail.com>

* Revert "Fix wdk sys ci tests (#23)"

This reverts commit 165f26a.

---------

Signed-off-by: Nicholas Rishel <rishel.nick@gmail.com>
Signed-off-by: Melvin Wang <melvin.mc.wang@gmail.com>
Co-authored-by: Nicholas Rishel <rishel.nick@gmail.com>
  • Loading branch information
wmmc88 and PrototypeNM1 authored Apr 8, 2024
1 parent 165f26a commit 4208234
Show file tree
Hide file tree
Showing 18 changed files with 43 additions and 30 deletions.
6 changes: 3 additions & 3 deletions .github/actions/winget-install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@ runs:
shell: pwsh
run: |
New-Item -Type Directory $env:RUNNER_TEMP/winget-install
Invoke-WebRequest -Headers $AuthenticatedHeaders -Uri https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.7.3/Microsoft.UI.Xaml.2.7.x64.appx -OutFile $env:RUNNER_TEMP/winget-install/Microsoft.UI.Xaml.2.7.x64.appx
Invoke-WebRequest -Headers $AuthenticatedHeaders -Uri https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.6/Microsoft.UI.Xaml.2.8.x64.appx -OutFile $env:RUNNER_TEMP/winget-install/Microsoft.UI.Xaml.2.8.x64.appx
Invoke-WebRequest -Uri https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx -OutFile $env:RUNNER_TEMP/winget-install/Microsoft.VCLibs.x64.14.00.Desktop.appx # Needed per https://github.com/microsoft/winget-cli/blob/21de1607ed5c90174e6bb931406975c18681a5dd/README.md?plain=1#L35C19-L35C19
Invoke-WebRequest -Headers $AuthenticatedHeaders -Uri $env:LatestWingetDownloadUri -OutFile $env:RUNNER_TEMP/winget-install/winget.msixbundle
Invoke-WebRequest -Headers $AuthenticatedHeaders -Uri $env:LatestWingetLicenseDownloadUri -OutFile $env:RUNNER_TEMP/winget-install/license.xml
- name: Start Winget Installation
shell: pwsh
run: |
Add-AppxProvisionedPackage -Online -PackagePath $env:RUNNER_TEMP/winget-install/winget.msixbundle -LicensePath $env:RUNNER_TEMP/winget-install/license.xml -DependencyPackagePath $env:RUNNER_TEMP/winget-install/Microsoft.UI.Xaml.2.7.x64.appx, $env:RUNNER_TEMP/winget-install/Microsoft.VCLibs.x64.14.00.Desktop.appx
Add-AppxProvisionedPackage -Online -PackagePath $env:RUNNER_TEMP/winget-install/winget.msixbundle -LicensePath $env:RUNNER_TEMP/winget-install/license.xml -DependencyPackagePath $env:RUNNER_TEMP/winget-install/Microsoft.UI.Xaml.2.8.x64.appx, $env:RUNNER_TEMP/winget-install/Microsoft.VCLibs.x64.14.00.Desktop.appx
- name: Wait for Completion of Winget Installation
shell: pwsh
run: |
while ((Get-Command * | Select-String winget).ToString() -ne "winget.exe") {
while ((Get-Command * | Select-String winget)?.ToString() -ne "winget.exe") {
Start-Sleep -Seconds 1
}
Write-Output "Winget Version: $(winget --version)"
6 changes: 4 additions & 2 deletions .github/workflows/code-formatting-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ jobs:
uses: actions/checkout@v4

- name: Install Rust Toolchain (Nightly)
uses: dtolnay/rust-toolchain@nightly
# Need to temporarily pin nightly used for fmt because of upstream bug: https://github.com/rust-lang/rustfmt/issues/6082, https://github.com/rust-lang/rustfmt/issues/6099
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-02-17
components: rustfmt

- name: Run Cargo Format
run: cargo +nightly fmt --all -- --check
run: cargo +nightly-2024-02-17 fmt --all -- --check

taplo-fmt:
name: .toml Formatting Check
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
- name: Install Cargo Expand
uses: taiki-e/install-action@v2
with:
tool: cargo-expand
tool: cargo-expand@1.0.80

- name: Run Cargo Test
run: cargo +${{ matrix.rust_toolchain }} test --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }}
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ That's it! Thank you for your contribution!
The following tools should be installed as a part of the `windows-drivers-rs` developer workflow:
* `cargo-expand`: `cargo install --locked cargo-expand`
* `cargo-expand`: `cargo install --locked cargo-expand --version 1.0.80`
* `cargo-audit`: `cargo install --locked cargo-audit`
* `cargo-udeps`: `cargo install --locked cargo-udeps`
* `taplo-cli`: `cargo install --locked taplo-cli`
Expand Down
3 changes: 3 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ success = rm -r ${CARGO_MAKE_CRATE_CUSTOM_TRIPLE_TARGET_DIRECTORY}/tests
assert ${success} "Failed to delete tests directory"
'''

[tasks.test]
install_crate = { crate_name = "cargo-expand", version = "1.0.80" }

[tasks.audit]
args = ["audit", "--deny", "warnings"]

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This project was built with support of WDM, KMDF, and UMDF drivers in mind, as w
### Build Requirements

* Binding generation via `bindgen` requires `libclang`. The easiest way to acquire this is via `winget`
* `winget -i install LLVM.LLVM`
* `winget install -i LLVM.LLVM`
* Ensure you select the GUI option to add LLVM to the PATH
* To execute post-build tasks (ie. `inf2cat`, `infverif`, etc.), `cargo make` is used
* `cargo install --locked cargo-make --no-default-features --features tls-native`
Expand Down Expand Up @@ -168,7 +168,7 @@ When executing the default task, just `cargo make` make also works since the `de

### 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).
`windows-drivers-rs` extends `cargo make` to forward specific arguments 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

Expand Down
2 changes: 1 addition & 1 deletion crates/wdk-build/rust-driver-makefile.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file can be leveraged to build downstream drivers. See examples at https://github.com/microsoft/Windows-rust-drivers-samples

# FIXME: this flow is based on the signing process of a KMDF PNP driver. There should be different flows availabe for different types of drivers as outlined in https://learn.microsoft.com/en-us/windows-hardware/drivers/install/test-signing-driver-packages
# FIXME: this flow is based on the signing process of a KMDF PNP driver. There should be different flows available for different types of drivers as outlined in https://learn.microsoft.com/en-us/windows-hardware/drivers/install/test-signing-driver-packages
[config]
min_version = "0.37.8"
init_task = "wdk-build-init"
Expand Down
2 changes: 1 addition & 1 deletion crates/wdk-build/src/bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl BuilderExt for Builder {
// -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)
// `_variable` are separate tokens already, and don't need `##` to concatenate them)
.clang_arg("--warn-=no-invalid-token-paste")
.clang_arg("-fms-extensions")
.blocklist_item("ExAllocatePoolWithTag") // Deprecated
Expand Down
2 changes: 1 addition & 1 deletion crates/wdk-build/src/cargo_make.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ where
fn forward_env_var_to_cargo_make<S: AsRef<str>>(env_var_name: S) {
let env_var_name = env_var_name.as_ref();

// Since this executes in a child proccess to cargo-make, we need to forward the
// Since this executes in a child process to cargo-make, we need to forward the
// values we want to change to duckscript, in order to get it to modify the
// parent process (ie. cargo-make)
if let Some(env_var_value) = std::env::var_os(env_var_name) {
Expand Down
23 changes: 16 additions & 7 deletions crates/wdk-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! configure any build that depends on the WDK (Windows Driver Kit). This is
//! especially useful for crates that generate FFI bindings to the WDK,
//! WDK-dependent libraries, and programs built on top of the WDK (ex. Drivers).
//! This library is built to be able to accomodate different WDK releases, as
//! This library is built to be able to accommodate different WDK releases, as
//! well strives to allow for all the configuration the WDK allows. This
//! includes being ables to select different WDF versions and different driver
//! models (WDM, KMDF, UMDF).
Expand Down Expand Up @@ -47,8 +47,8 @@ use utils::PathExt;
/// Configuration parameters for a build dependent on the WDK
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct Config {
/// Path to root of WDK. Corresponds with WDKContentRoot environment
/// varialbe in eWDK
/// Path to root of WDK. Corresponds with `WDKContentRoot` environment
/// variable in eWDK
pub wdk_content_root: PathBuf,
/// Build configuration of driver
pub driver_config: DriverConfig,
Expand Down Expand Up @@ -108,7 +108,7 @@ pub struct UMDFConfig {
/// Errors that could result from configuring a build via [`wdk-build`]
#[derive(Debug, Error)]
pub enum ConfigError {
/// Error returned when an std::io operation fails
/// Error returned when an [`std::io`] operation fails
#[error(transparent)]
IoError(#[from] std::io::Error),

Expand Down Expand Up @@ -139,7 +139,7 @@ pub enum ConfigError {
)]
WDKContentRootDetectionError,

/// Error returned when cargo_metadata execution or parsing fails
/// Error returned when `cargo_metadata` execution or parsing fails
#[error(transparent)]
CargoMetadataError(#[from] cargo_metadata::Error),

Expand Down Expand Up @@ -198,7 +198,7 @@ pub enum ExportError {
/// Error returned when the crate being compiled does not have a `links`
/// value in its Cargo.toml
#[error(
"Missing `links` value in crate's config.toml. Metadata is unable to propogate to \
"Missing `links` value in crate's config.toml. Metadata is unable to propagate to \
dependencies without a `links` value"
)]
MissingLinksValue(#[from] std::env::VarError),
Expand Down Expand Up @@ -562,9 +562,18 @@ impl Config {
///
/// This consists mainly of linker setting configuration. This must be
/// called from a Cargo build script of the binary being built
///
/// # Errors
///
/// This function will return an error if any of the required paths do not
/// exist.
///
/// # Panics
///
/// Panics if the invoked from outside a Cargo build environmen
pub fn configure_binary_build(&self) -> Result<(), ConfigError> {
self.configure_library_build()?;

// Linker arguments derived from Microsoft.Link.Common.props in Ni(22H2) WDK
println!("cargo:rustc-cdylib-link-arg=/NXCOMPAT");
println!("cargo:rustc-cdylib-link-arg=/DYNAMICBASE");
Expand Down
2 changes: 0 additions & 2 deletions crates/wdk-build/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,6 @@ pub fn detect_cpu_architecture_in_build_script() -> CPUArchitecture {

#[cfg(test)]
mod tests {
use std::path::PathBuf;

use windows::Win32::UI::Shell::{FOLDERID_ProgramFiles, SHGetKnownFolderPath, KF_FLAG_DEFAULT};

use super::*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub extern "system" fn driver_entry(
WdfDriverCreate,
driver as PDRIVER_OBJECT,
registry_path,
// The order of the next two arguements is swapped!
// The order of the next two arguments is swapped!
&mut driver_config,
WDF_NO_OBJECT_ATTRIBUTES,
driver_handle_output,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ error[E0308]: arguments to this function are incorrect
| | WdfDriverCreate,
| | driver as PDRIVER_OBJECT,
| | registry_path,
| | // The order of the next two arguements is swapped!
| | // The order of the next two arguments is swapped!
| | &mut driver_config,
| | ------------------ expected `*mut _WDF_OBJECT_ATTRIBUTES`, found `&mut _WDF_DRIVER_CONFIG`
| | WDF_NO_OBJECT_ATTRIBUTES,
Expand All @@ -21,7 +21,7 @@ help: swap these arguments
29 + WdfDriverCreate,
30 + driver as PDRIVER_OBJECT,
31 + registry_path,
32 + // The order of the next two arguements is swapped!
32 + // The order of the next two arguments is swapped!
33 + &mut driver_config,
34 + WDF_NO_OBJECT_ATTRIBUTES,
35 + driver_handle_output,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub extern "system" fn driver_entry(
WdfDriverCreate,
driver as PDRIVER_OBJECT,
registry_path,
// The order of the next two arguements is swapped!
// The order of the next two arguments is swapped!
&mut driver_config,
WDF_NO_OBJECT_ATTRIBUTES,
driver_handle_output,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ error[E0308]: arguments to this function are incorrect
| | WdfDriverCreate,
| | driver as PDRIVER_OBJECT,
| | registry_path,
| | // The order of the next two arguements is swapped!
| | // The order of the next two arguments is swapped!
| | &mut driver_config,
| | ------------------ expected `*mut _WDF_OBJECT_ATTRIBUTES`, found `&mut _WDF_DRIVER_CONFIG`
| | WDF_NO_OBJECT_ATTRIBUTES,
Expand All @@ -21,7 +21,7 @@ help: swap these arguments
28 + WdfDriverCreate,
29 + driver as PDRIVER_OBJECT,
30 + registry_path,
31 + // The order of the next two arguements is swapped!
31 + // The order of the next two arguments is swapped!
32 + &mut driver_config,
33 + WDF_NO_OBJECT_ATTRIBUTES,
34 + driver_handle_output,
Expand Down
3 changes: 2 additions & 1 deletion crates/wdk-sys/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ use crate::types::{NTSTATUS, POOL_FLAGS, PVOID, PWDF_OBJECT_ATTRIBUTES};
#[allow(non_upper_case_globals)]
#[rustversion::attr(
any(
all(not(nightly), since(1.79)),
all(not(nightly), since(1.78)),
all(nightly, since(2024-02-09)),
),
// required until following issue is resolved: https://github.com/rust-lang/rust-bindgen/issues/2710
allow(clippy::manual_c_str_literals)
)]
#[allow(clippy::unreadable_literal)]
Expand Down
2 changes: 1 addition & 1 deletion crates/wdk-sys/src/test_stubs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// License: MIT OR Apache-2.0

//! Any library dependency that depends on `wdk-sys` requires these stubs to
//! provide symobols to sucessfully compile and run tests. They can be brought
//! provide symobols to successfully compile and run tests. They can be brought
//! into scope by introducing `wdk-sys` with the `test-stubs` feature in the
//! `dev-dependencies` of the crate's `Cargo.toml`
Expand Down
2 changes: 1 addition & 1 deletion crates/wdk-sys/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
)]
#[rustversion::attr(
any(
all(not(nightly), since(1.79)),
all(not(nightly), since(1.78)),
all(nightly, since(2024-02-09)),
),
allow(clippy::ref_as_ptr)
Expand Down

0 comments on commit 4208234

Please sign in to comment.