Skip to content

Commit 92f9d79

Browse files
committed
book: Set driver link-arg in build.rs
`config.toml` is a project-level configuration. Cargo will only read the configuration from the current directory and up, and not in: - package directories in a workspace - package directories when `--manifest-path` is used Use `build.rs` instead, which will be executed before the package is built and only apply the flags for the specific package. This allows mixing drivers and applications in a workspace while still invoking Cargo from the workspace root. Ref: https://doc.rust-lang.org/cargo/reference/config.html#hierarchical-structure Ref: https://doc.rust-lang.org/cargo/reference/build-scripts.html Signed-off-by: Tim Crawford <[email protected]>
1 parent 2aaa2fe commit 92f9d79

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

book/src/how_to/building_drivers.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,15 @@ value to `efi_boot_service_driver` or `efi_runtime_driver`.
1111

1212
Example:
1313

14-
```toml
15-
# In .cargo/config.toml:
16-
[build]
17-
rustflags = ["-C", "link-args=/subsystem:efi_runtime_driver"]
14+
```rust
15+
// In build.rs
16+
17+
fn main() {
18+
let target = std::env::var("TARGET").unwrap();
19+
if target.ends_with("-unknown-uefi") {
20+
println!("cargo::rustc-link-arg=/subsystem:efi_runtime_driver");
21+
}
22+
}
1823
```
1924

2025
[spec-images]: https://uefi.org/specs/UEFI/2.10/02_Overview.html#uefi-images

0 commit comments

Comments
 (0)