Skip to content

Commit

Permalink
Use default-members in Cargo workspace
Browse files Browse the repository at this point in the history
Adds bpf code to the workspace and is excluded by default.
This allows for all deps to be managed in Cargo.lock and for cargo
update to work as expected from the root.
Similarly, rustfmt and clippy can operate on the whole workspace.

Signed-off-by: Dave Tucker <[email protected]>
  • Loading branch information
dave-tucker committed Aug 31, 2022
1 parent 37410be commit d329ae2
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 24 deletions.
3 changes: 2 additions & 1 deletion .vim/coc-settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"rust-analyzer.linkedProjects": ["Cargo.toml", "{{project-name}}-ebpf/Cargo.toml"]
"rust-analyzer.checkOnSave.allTargets": false,
"rust-analyzer.checkOnSave.command": "clippy"
}
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"rust-analyzer.linkedProjects": ["Cargo.toml", "{{project-name}}-ebpf/Cargo.toml"]
"rust-analyzer.checkOnSave.allTargets": false,
"rust-analyzer.checkOnSave.command": "clippy"
}
23 changes: 22 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
[workspace]
members = ["{{project-name}}", "{{project-name}}-common", "xtask"]
members = ["{{project-name}}", "{{project-name}}-ebpf", "{{project-name}}-common", "xtask"]
default-members = ["{{project-name}}", "{{project-name}}-common", "xtask"]

[profile.dev]
panic = "abort"
lto = true
rpath = false

[profile.release]
panic = "abort"
lto = true

[profile.dev.package.{{project-name}}-ebpf]
opt-level = 3
debug = false
debug-assertions = false
overflow-checks = false
incremental = false
codegen-units = 1

[profile.release.package.{{project-name}}-ebpf]
codegen-units = 1
2 changes: 1 addition & 1 deletion xtask/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub fn run(opts: Options) -> Result<(), anyhow::Error> {
args.append(&mut run_args);

// spawn the command
let err = Command::new(args.get(0).expect("No first argument"))
let err = Command::new(args.first().expect("No first argument"))
.args(args.iter().skip(1))
.exec();

Expand Down
21 changes: 1 addition & 20 deletions {{project-name}}-ebpf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,4 @@ aya-log-ebpf = { git = "https://github.com/aya-rs/aya", branch = "main" }

[[bin]]
name = "{{ project-name }}"
path = "src/main.rs"

[profile.dev]
opt-level = 3
debug = false
debug-assertions = false
overflow-checks = false
lto = true
panic = "abort"
incremental = false
codegen-units = 1
rpath = false

[profile.release]
lto = true
panic = "abort"
codegen-units = 1

[workspace]
members = []
path = "src/main.rs"

0 comments on commit d329ae2

Please sign in to comment.