From f0b7f90f70c8be91840c6a80f485ef1080c55f5c Mon Sep 17 00:00:00 2001 From: Max de Danschutter Date: Thu, 17 Oct 2024 13:36:04 +0200 Subject: [PATCH] Add `--no-default-features` cargo argument --- xbuild/src/cargo/mod.rs | 9 +++++++++ xbuild/src/lib.rs | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/xbuild/src/cargo/mod.rs b/xbuild/src/cargo/mod.rs index be2cd71..c0bee54 100644 --- a/xbuild/src/cargo/mod.rs +++ b/xbuild/src/cargo/mod.rs @@ -17,6 +17,7 @@ use crate::{CompileTarget, Opt}; pub struct Cargo { package: String, features: Vec, + no_default_features: bool, workspace_manifest: Option, manifest: Manifest, package_root: PathBuf, @@ -28,6 +29,7 @@ impl Cargo { pub fn new( package: Option<&str>, features: Vec, + no_default_features: bool, manifest_path: Option, target_dir: Option, offline: bool, @@ -104,6 +106,7 @@ impl Cargo { Ok(Self { package: package.clone(), features, + no_default_features, workspace_manifest: workspace_manifest.map(|(_path, manifest)| manifest), manifest, package_root: package_root.to_owned(), @@ -152,6 +155,7 @@ impl Cargo { CargoBuild::new( target, &self.features, + self.no_default_features, self.package_root(), target_dir, self.offline, @@ -243,6 +247,7 @@ impl CargoBuild { fn new( target: CompileTarget, features: &[String], + no_default_features: bool, root_dir: &Path, target_dir: &Path, offline: bool, @@ -265,9 +270,13 @@ impl CargoBuild { if offline { cmd.arg("--offline"); } + if no_default_features { + cmd.arg("--no-default-features"); + } for features in features { cmd.arg("--features").arg(features); } + Ok(Self { cmd, target, diff --git a/xbuild/src/lib.rs b/xbuild/src/lib.rs index 4a376e5..d65dc6e 100644 --- a/xbuild/src/lib.rs +++ b/xbuild/src/lib.rs @@ -279,6 +279,9 @@ pub struct CargoArgs { /// Space or comma separated list of features to activate #[clap(long, short = 'F')] features: Vec, + /// Do not activate the `default` feature. + #[clap(long)] + no_default_features: bool, } impl CargoArgs { @@ -286,6 +289,7 @@ impl CargoArgs { Cargo::new( self.package.as_deref(), self.features, + self.no_default_features, self.manifest_path, self.target_dir, self.offline,