From 4c09a3c13310e2fb034ab3325b7aaa8532d43fb0 Mon Sep 17 00:00:00 2001 From: Mitsutoshi Aoe Date: Wed, 20 Apr 2022 10:43:44 +0900 Subject: [PATCH] Add support for custom profiles This patch adds the new --profile NAME option to support cargo's custom profiles. The behavior hasn't changed when --release is passed or when nothing related to profiles are given. --- src/app.rs | 2 +- src/opt.rs | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/app.rs b/src/app.rs index d9f2426..f5f2a66 100644 --- a/src/app.rs +++ b/src/app.rs @@ -162,7 +162,7 @@ fn make_compile_opts(cargo_options: &CargoOpts, cfg: &Config) -> Result, /// Pass --release to cargo - #[structopt(long)] + #[structopt(long, conflicts_with = "profile")] release: bool, + /// Pass --profile NAME to cargo + #[structopt(long, value_name = "NAME")] + profile: Option, + /// Output .trace file to the given path /// /// Defaults to `target/instruments/{name}_{template-name}_{date}.trace`. @@ -155,7 +159,7 @@ impl fmt::Display for Target { pub(crate) struct CargoOpts { pub(crate) package: Package, pub(crate) target: Target, - pub(crate) release: bool, + pub(crate) profile: String, pub(crate) features: CliFeatures, } @@ -169,7 +173,11 @@ impl AppConfig { self.all_features, !self.no_default_features, )?; - Ok(CargoOpts { package, target, release: self.release, features }) + let profile = self + .profile + .clone() + .unwrap_or_else(|| (if self.release { "release" } else { "dev" }).to_owned()); + Ok(CargoOpts { package, target, profile, features }) } fn get_package(&self) -> Package {