From 8f4cbb3cd888be21c0cf8e96dd6f20a584c20566 Mon Sep 17 00:00:00 2001 From: qjerome Date: Wed, 3 Apr 2024 13:58:06 +0200 Subject: [PATCH] new cargo alias for xtask (run, build, release) Signed-off-by: qjerome --- .cargo/config.toml | 3 +++ xtask/src/main.rs | 37 ++++++++++++++++++++++++------------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 91641c5..91e3996 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -8,6 +8,9 @@ target = ["x86_64-unknown-linux-gnu", "bpfel-unknown-none"] # replace with the target triple you are developing on must be the same as # as the other target than bpf specified in build.target xtask = "run -q --target=x86_64-unknown-linux-gnu --package xtask --release --" +xrun = "xtask run" +xbuild = "xtask build" +xrelease = "xtask release" [profile.release] lto = true diff --git a/xtask/src/main.rs b/xtask/src/main.rs index b21edff..05306ca 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -18,6 +18,13 @@ pub struct Options { #[derive(Debug, Parser)] struct ReleaseOptions { + /// Do not run cargo release on eBPF directory + #[clap(short = 'i', long)] + ignore_ebpf: bool, + /// Do not run cargo release on workspace packages + #[clap(short = 'I', long)] + ignore_ws: bool, + /// Arguments to pass to cargo release args: Vec, } @@ -169,24 +176,28 @@ fn main() -> Result<(), anyhow::Error> { } Release(o) => { - let mut cargo = std::process::Command::new("cargo"); - cargo.current_dir(EBPF_DIR).arg("release").args(&o.args); + if !o.ignore_ebpf { + let mut cargo = std::process::Command::new("cargo"); + cargo.current_dir(EBPF_DIR).arg("release").args(&o.args); - let status = cargo.status()?; - if !status.success() { - return Err(anyhow!("cargo release failed: {status}")); - } + let status = cargo.status()?; + if !status.success() { + return Err(anyhow!("cargo release failed: {status}")); + } - if o.args.contains(&"-h".into()) || o.args.contains(&"--help".into()) { - return Ok(()); + if o.args.contains(&"-h".into()) || o.args.contains(&"--help".into()) { + return Ok(()); + } } - let mut cargo = std::process::Command::new("cargo"); - cargo.arg("release").args(&o.args); + if !o.ignore_ws { + let mut cargo = std::process::Command::new("cargo"); + cargo.arg("release").args(&o.args); - let status = cargo.status()?; - if !status.success() { - return Err(anyhow!("cargo release failed: {status}")); + let status = cargo.status()?; + if !status.success() { + return Err(anyhow!("cargo release failed: {status}")); + } } } }