Skip to content

Commit

Permalink
feat: fetch rust-driver-makefile.toml from wdk-build
Browse files Browse the repository at this point in the history
  • Loading branch information
wmmc88 committed Jan 30, 2024
1 parent bd5d40e commit 43a2e82
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 23 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
target/
DriverCertificate.cer
.cargo-make-loadscripts/
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["general/echo/kmdf/driver/*","general/echo/kmdf/exe"]
members = ["general/echo/kmdf/driver/*", "general/echo/kmdf/exe"]
resolver = "2"

[workspace.package]
Expand All @@ -17,8 +17,8 @@ panic = "abort"
lto = true

[workspace.dependencies]
wdk = "0.1.0"
wdk-alloc = "0.1.0"
wdk-build = "0.1.0"
wdk-panic = "0.1.0"
wdk-sys = "0.1.0"
wdk = "0.2.0"
wdk-alloc = "0.2.0"
wdk-build = "0.2.0"
wdk-panic = "0.2.0"
wdk-sys = "0.2.0"
26 changes: 17 additions & 9 deletions Makefile.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
extend = ".cargo-make-loadscripts/rust-driver-makefile.toml"
extend = "target/rust-driver-makefile.toml"

[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
WDK_BUILD_ADDITIONAL_INFVERIF_FLAGS = "/msft"

[config]
load_script = """
pwsh.exe -Command "\
if ($env:CARGO_MAKE_CRATE_IS_WORKSPACE) { return };\
$cargoMakeURI = 'https://raw.githubusercontent.com/microsoft/windows-drivers-rs/main/rust-driver-makefile.toml';\
New-Item -ItemType Directory .cargo-make-loadscripts -Force;\
Invoke-RestMethod -Method GET -Uri $CargoMakeURI -OutFile $env:CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY/.cargo-make-loadscripts/rust-driver-makefile.toml\
"
"""
load_script = '''
#!@rust
//! ```cargo
//! [dependencies]
//! wdk-build = "0.2.0"
//! ```
#![allow(unused_doc_comments)]
wdk_build::cargo_make::load_rust_driver_makefile()?
'''

[tasks.default]
# Since this worspace contains both driver and non-driver crates, we need to explicitly specify `build` so that non-driver crates are still compiled
clear = true
dependencies = ["build", "package-driver-flow"]
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,18 @@ If build is successful, this will stamp the INF and create a CAT file placed wit
`shutdown -r -t 0`

1. Copy the following to the DUT (Device Under Test: the computer you want to test the driver on):
1. `.\target\..configuration..\package`
1. `Path\To\Driver\DriverCertificate.cer`
1. The driver `package` folder located in the [Cargo Output Directory](https://doc.rust-lang.org/cargo/guide/build-cache.html). The Cargo Output Directory changes based off of build profile, target architecture, etc.
* Ex. `<REPO_ROOT>\target\x86_64-pc-windows-msvc\debug\package`, `<REPO_ROOT>\target\x86_64-pc-windows-msvc\release\package`, `<REPO_ROOT>\target\aarch64-pc-windows-msvc\debug\package`, `<REPO_ROOT>\target\aarch64-pc-windows-msvc\release\package`,
`<REPO_ROOT>\target\debug\package`,
`<REPO_ROOT>\target\release\package`
1. The version of `devgen.exe` from the WDK Developer Tools that matches the archtecture of your DUT
* Ex. `C:\ewdk\Program Files\Windows Kits\10\Tools\10.0.22621.0\x64\devgen.exe`
1. Install the Certificate on the DUT:
1. Double click the certificate
1. Click Install Certificate
1. Store Location: Local Machine -> Next
1. Place all certificates in the following Store -> Browse -> Trusted Root Certification Authorities -> Ok -> Next
1. Repeat 2-4 for Store -> Browse -> Trusted Publishers -> Ok -> Next
1. Finish
1. Install the driver from Admin Command Prompt:
1. In the package directory, run: `pnputil.exe /add-driver echo_2.inf /install`
Expand Down
2 changes: 2 additions & 0 deletions general/echo/kmdf/driver/DriverSync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ rust-version = "1.72.1"
edition.workspace = true
publish.workspace = true

[package.metadata.wdk]

[lib]
crate-type = ["cdylib"]

Expand Down
4 changes: 0 additions & 4 deletions general/echo/kmdf/exe/Makefile.toml

This file was deleted.

0 comments on commit 43a2e82

Please sign in to comment.