Skip to content

Commit 7ef8e49

Browse files
maxdedMarijnS95
authored andcommitted
Add --no-default-features cargo argument
1 parent d4e790b commit 7ef8e49

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

xbuild/src/cargo/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use crate::{task, CompileTarget, Opt};
1717
pub struct Cargo {
1818
package: String,
1919
features: Vec<String>,
20+
no_default_features: bool,
2021
workspace_manifest: Option<Manifest>,
2122
manifest: Manifest,
2223
package_root: PathBuf,
@@ -28,6 +29,7 @@ impl Cargo {
2829
pub fn new(
2930
package: Option<&str>,
3031
features: Vec<String>,
32+
no_default_features: bool,
3133
manifest_path: Option<PathBuf>,
3234
target_dir: Option<PathBuf>,
3335
offline: bool,
@@ -104,6 +106,7 @@ impl Cargo {
104106
Ok(Self {
105107
package: package.clone(),
106108
features,
109+
no_default_features,
107110
workspace_manifest: workspace_manifest.map(|(_path, manifest)| manifest),
108111
manifest,
109112
package_root: package_root.to_owned(),
@@ -152,6 +155,7 @@ impl Cargo {
152155
CargoBuild::new(
153156
target,
154157
&self.features,
158+
self.no_default_features,
155159
self.package_root(),
156160
target_dir,
157161
self.offline,
@@ -243,6 +247,7 @@ impl CargoBuild {
243247
fn new(
244248
target: CompileTarget,
245249
features: &[String],
250+
no_default_features: bool,
246251
root_dir: &Path,
247252
target_dir: &Path,
248253
offline: bool,
@@ -265,9 +270,13 @@ impl CargoBuild {
265270
if offline {
266271
cmd.arg("--offline");
267272
}
273+
if no_default_features {
274+
cmd.arg("--no-default-features");
275+
}
268276
for features in features {
269277
cmd.arg("--features").arg(features);
270278
}
279+
271280
Ok(Self {
272281
cmd,
273282
target,

xbuild/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,13 +279,17 @@ pub struct CargoArgs {
279279
/// Space or comma separated list of features to activate
280280
#[clap(long, short = 'F')]
281281
features: Vec<String>,
282+
/// Do not activate the `default` feature.
283+
#[clap(long)]
284+
no_default_features: bool,
282285
}
283286

284287
impl CargoArgs {
285288
pub fn cargo(self) -> Result<Cargo> {
286289
Cargo::new(
287290
self.package.as_deref(),
288291
self.features,
292+
self.no_default_features,
289293
self.manifest_path,
290294
self.target_dir,
291295
self.offline,

0 commit comments

Comments
 (0)