From d329ae20c179128d674e8ed982e991b20bbc99ca Mon Sep 17 00:00:00 2001 From: Dave Tucker Date: Wed, 31 Aug 2022 14:55:39 +0000 Subject: [PATCH] Use default-members in Cargo workspace 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 --- .vim/coc-settings.json | 3 ++- .vscode/settings.json | 3 ++- Cargo.toml | 23 ++++++++++++++++++++++- xtask/src/run.rs | 2 +- {{project-name}}-ebpf/Cargo.toml | 21 +-------------------- 5 files changed, 28 insertions(+), 24 deletions(-) diff --git a/.vim/coc-settings.json b/.vim/coc-settings.json index 6a1ec7d..07c919f 100644 --- a/.vim/coc-settings.json +++ b/.vim/coc-settings.json @@ -1,3 +1,4 @@ { - "rust-analyzer.linkedProjects": ["Cargo.toml", "{{project-name}}-ebpf/Cargo.toml"] + "rust-analyzer.checkOnSave.allTargets": false, + "rust-analyzer.checkOnSave.command": "clippy" } diff --git a/.vscode/settings.json b/.vscode/settings.json index 6a1ec7d..07c919f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,4 @@ { - "rust-analyzer.linkedProjects": ["Cargo.toml", "{{project-name}}-ebpf/Cargo.toml"] + "rust-analyzer.checkOnSave.allTargets": false, + "rust-analyzer.checkOnSave.command": "clippy" } diff --git a/Cargo.toml b/Cargo.toml index c386364..a68e6b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 \ No newline at end of file diff --git a/xtask/src/run.rs b/xtask/src/run.rs index afa6928..5aab949 100644 --- a/xtask/src/run.rs +++ b/xtask/src/run.rs @@ -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(); diff --git a/{{project-name}}-ebpf/Cargo.toml b/{{project-name}}-ebpf/Cargo.toml index 6b7c3e9..f48e4af 100644 --- a/{{project-name}}-ebpf/Cargo.toml +++ b/{{project-name}}-ebpf/Cargo.toml @@ -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" \ No newline at end of file