From a6b1fb9a1e829de77aff08038e58d7af867f8527 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Tue, 18 Jul 2023 17:37:29 -0400 Subject: [PATCH] xtask: allow arbitrary flags to cargo build --- xtask/src/run.rs | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/xtask/src/run.rs b/xtask/src/run.rs index f5f41aef..7a29ad5f 100644 --- a/xtask/src/run.rs +++ b/xtask/src/run.rs @@ -1,4 +1,5 @@ use std::{ + ffi::OsString, fmt::Write as _, io::BufReader, path::PathBuf, @@ -12,12 +13,9 @@ use xtask::AYA_BUILD_INTEGRATION_BPF; #[derive(Debug, Parser)] pub struct BuildOptions { - /// Pass --release to `cargo build`. + /// Arguments to pass to `cargo build`. #[clap(long)] - pub release: bool, - /// Pass --target to `cargo build`. - #[clap(long)] - pub target: Option, + pub cargo_arg: Vec, } #[derive(Debug, Parser)] @@ -28,26 +26,22 @@ pub struct Options { #[clap(short, long, default_value = "sudo -E")] pub runner: String, /// Arguments to pass to your application. - #[clap(name = "args", last = true)] - pub run_args: Vec, + #[clap(last = true)] + pub run_args: Vec, } /// Build the project pub fn build(opts: BuildOptions) -> Result> { - let BuildOptions { release, target } = opts; + let BuildOptions { cargo_arg } = opts; let mut cmd = Command::new("cargo"); - cmd.env(AYA_BUILD_INTEGRATION_BPF, "true").args([ - "build", - "--tests", - "--message-format=json", - "--package=integration-test", - ]); - if release { - cmd.arg("--release"); - } - if let Some(target) = target { - cmd.args(["--target", &target]); - } + cmd.env(AYA_BUILD_INTEGRATION_BPF, "true") + .args([ + "build", + "--tests", + "--message-format=json", + "--package=integration-test", + ]) + .args(cargo_arg); let mut child = cmd .stdout(Stdio::piped())