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

Small optimisation to --profile dev wasm builds #1851

Merged
merged 17 commits into from
Oct 25, 2023
Merged
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
Prev Previous commit
Next Next commit
finish build config renaming
  • Loading branch information
liamaharon committed Oct 23, 2023
commit 898cc42c2a153226b82733efce12f0de8fad12ff
18 changes: 9 additions & 9 deletions substrate/utils/wasm-builder/src/wasm_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ pub(crate) fn create_and_compile(
);

let build_config = BuildConfiguration::detect(&project);
build_blob(&build_config.wasm_build_profile, &project, default_rustflags, cargo_cmd);
build_blob(&build_config.blob_build_profile, &project, default_rustflags, cargo_cmd);
let (wasm_binary, wasm_binary_compressed, bloaty) = maybe_compact_wasm_and_copy_blobs(
&project,
&build_config,
Expand Down Expand Up @@ -636,8 +636,8 @@ impl BuildConfiguration {
.to_string();
(name, false)
};
let cargo_build_profile = Profile::iter().find(|p| p.directory() == name);
let wasm_build_profile = match (cargo_build_profile.clone(), overriden) {
let outer_build_profile = Profile::iter().find(|p| p.directory() == name);
let blob_build_profile = match (outer_build_profile.clone(), overriden) {
// When not overriden by a env variable we default to using the `Release` profile
// for the wasm build even when the main build uses the debug build. This
// is because the `Debug` profile is too slow for normal development activities.
Expand Down Expand Up @@ -669,8 +669,8 @@ impl BuildConfiguration {
},
};
BuildConfiguration {
cargo_build_profile: cargo_build_profile.unwrap_or(Profile::Release),
wasm_build_profile,
outer_build_profile: outer_build_profile.unwrap_or(Profile::Release),
blob_build_profile,
}
}
}
Expand All @@ -682,7 +682,7 @@ fn offline_build() -> bool {

/// Build the project and create the runtime blob.
fn build_blob(
wasm_build_profile: &Profile,
blob_build_profile: &Profile,
project: &Path,
default_rustflags: &str,
cargo_cmd: CargoCommandVersioned,
Expand Down Expand Up @@ -716,7 +716,7 @@ fn build_blob(
}

build_cmd.arg("--profile");
build_cmd.arg(wasm_build_profile.name());
build_cmd.arg(blob_build_profile.name());

if offline_build() {
build_cmd.arg("--offline");
Expand Down Expand Up @@ -746,13 +746,13 @@ fn maybe_compact_wasm_and_copy_blobs(
let out_name = out_name.unwrap_or_else(|| default_out_name.clone());
let in_path = project
.join("target/wasm32-unknown-unknown")
.join(build_config.wasm_build_profile.directory())
.join(build_config.blob_build_profile.directory())
.join(format!("{}.wasm", default_out_name));

// When cargo is running cargo in `--profile dev` the user wants speed, so skip producing
// compact and compressed blobs.
let (wasm_compact_path, wasm_compact_compressed_path) = if build_config
.cargo_build_profile
.outer_build_profile
.wants_compact()
{
let wasm_compact_path = project.join(format!("{}.compact.wasm", out_name,));
Expand Down