Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --no-default-features cargo argument #214

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions xbuild/src/cargo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use crate::{CompileTarget, Opt};
pub struct Cargo {
package: String,
features: Vec<String>,
no_default_features: bool,
workspace_manifest: Option<Manifest>,
manifest: Manifest,
package_root: PathBuf,
Expand All @@ -28,6 +29,7 @@ impl Cargo {
pub fn new(
package: Option<&str>,
features: Vec<String>,
no_default_features: bool,
manifest_path: Option<PathBuf>,
target_dir: Option<PathBuf>,
offline: bool,
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -152,6 +155,7 @@ impl Cargo {
CargoBuild::new(
target,
&self.features,
self.no_default_features,
self.package_root(),
target_dir,
self.offline,
Expand Down Expand Up @@ -243,6 +247,7 @@ impl CargoBuild {
fn new(
target: CompileTarget,
features: &[String],
no_default_features: bool,
root_dir: &Path,
target_dir: &Path,
offline: bool,
Expand All @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions xbuild/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,17 @@ pub struct CargoArgs {
/// Space or comma separated list of features to activate
#[clap(long, short = 'F')]
features: Vec<String>,
/// Do not activate the `default` feature.
#[clap(long)]
no_default_features: bool,
}

impl CargoArgs {
pub fn cargo(self) -> Result<Cargo> {
Cargo::new(
self.package.as_deref(),
self.features,
self.no_default_features,
self.manifest_path,
self.target_dir,
self.offline,
Expand Down
Loading