Skip to content

Commit

Permalink
Hack making projects with force-release flag be compiled in release mode
Browse files Browse the repository at this point in the history
  • Loading branch information
fedor committed Sep 16, 2017
1 parent 0873ddf commit fd2a0b5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/cargo/core/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub struct Manifest {
workspace: WorkspaceConfig,
original: Rc<TomlManifest>,
features: Features,
force_release: Option<bool>,
im_a_teapot: Option<bool>,
always_optimize_deps: Option<bool>,
}
Expand Down Expand Up @@ -247,6 +248,7 @@ impl Manifest {
workspace: WorkspaceConfig,
features: Features,
im_a_teapot: Option<bool>,
force_release: Option<bool>,
always_optimize_deps: Option<bool>,
original: Rc<TomlManifest>) -> Manifest {
Manifest {
Expand All @@ -265,6 +267,7 @@ impl Manifest {
features: features,
original: original,
im_a_teapot: im_a_teapot,
force_release: force_release,
always_optimize_deps,
}
}
Expand Down Expand Up @@ -319,6 +322,10 @@ impl Manifest {
}
}

pub fn debug_allowed(&self) -> bool {
self.force_release.unwrap_or(false) == false
}

pub fn feature_gate(&self) -> CargoResult<()> {
if self.im_a_teapot.is_some() {
self.features.require(Feature::test_dummy_unstable()).chain_err(|| {
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/core/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl Package {
}

pub fn is_local(&self) -> bool {
self.manifest.summary().source_id().is_path()
self.manifest.debug_allowed() && self.manifest.summary().source_id().is_path()
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ pub struct TomlProject {
cargo_features: Option<Vec<String>>,
#[serde(rename = "im-a-teapot")]
im_a_teapot: Option<bool>,
#[serde(rename = "force-release")]
force_release: Option<bool>,
#[serde(rename = "always-optimize-deps")]
always_optimize_deps: Option<bool>,

Expand Down Expand Up @@ -669,6 +671,7 @@ impl TomlManifest {
workspace_config,
features,
project.im_a_teapot,
project.force_release,
project.always_optimize_deps,
me.clone());
if project.license_file.is_some() && project.license.is_some() {
Expand Down

0 comments on commit fd2a0b5

Please sign in to comment.