Skip to content

Commit

Permalink
new cargo alias for xtask (run, build, release)
Browse files Browse the repository at this point in the history
Signed-off-by: qjerome <qjerome@rawsec.lu>
  • Loading branch information
qjerome committed Apr 3, 2024
1 parent 03c14a3 commit 8f4cbb3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 24 additions & 13 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
}

Expand Down Expand Up @@ -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}"));
}
}
}
}
Expand Down

0 comments on commit 8f4cbb3

Please sign in to comment.