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

Added workspace section to override parent workspace #378

Merged
merged 2 commits into from
Nov 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion src/cmd/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ impl CheckCommand {
/// Preferred default `[profile.release]` settings will be added if they are missing, existing
/// user-defined settings will be preserved.
///
/// The `[workspace]` will be added if it is missing to ignore `workspace` from parent `Cargo.toml`.
///
/// To disable this and use the original `Cargo.toml` as is then pass the `-Z original_manifest` flag.
fn exec_cargo_for_wasm_target(
crate_metadata: &CrateMetadata,
Expand Down Expand Up @@ -289,7 +291,8 @@ fn exec_cargo_for_wasm_target(
.with_root_package_manifest(|manifest| {
manifest
.with_removed_crate_type("rlib")?
.with_profile_release_defaults(Profile::default_contract_release())?;
.with_profile_release_defaults(Profile::default_contract_release())?
.with_workspace()?;
Ok(())
})?
.using_temp(cargo_build)?;
Expand Down
11 changes: 11 additions & 0 deletions src/workspace/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,17 @@ impl Manifest {
Ok(self)
}

/// Set empty `[workspace]` section if it is not exist
xgreenx marked this conversation as resolved.
Show resolved Hide resolved
///
/// It allows ignore `workspace` from parent `Cargo.toml`.
/// It can reduce the size of the contract in some cases.
xgreenx marked this conversation as resolved.
Show resolved Hide resolved
pub fn with_workspace(&mut self) -> Result<&mut Self> {
if let toml::map::Entry::Vacant(value) = self.toml.entry("workspace") {
value.insert(value::Value::Table(Default::default()));
}
Ok(self)
}

/// Get mutable reference to `[profile.release]` section
fn get_profile_release_table_mut(&mut self) -> Result<&mut value::Table> {
let profile = self
Expand Down