mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-24 04:15:45 +00:00
Ignore wasm_gc for debug build. (#6962)
* Ignore gc for debug build. * alternate implementation * Update utils/wasm-builder/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * fix Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -321,7 +321,7 @@ we support multiple environment variables:
|
|||||||
* `TRIGGER_WASM_BUILD` - Can be set to trigger a WASM build. On subsequent calls the value of the variable
|
* `TRIGGER_WASM_BUILD` - Can be set to trigger a WASM build. On subsequent calls the value of the variable
|
||||||
needs to change. As WASM builder instructs `cargo` to watch for file changes
|
needs to change. As WASM builder instructs `cargo` to watch for file changes
|
||||||
this environment variable should only be required in certain circumstances.
|
this environment variable should only be required in certain circumstances.
|
||||||
* `WASM_TARGET_DIRECTORY` - Will copy any build WASM binary to the given directory. The path needs
|
* `WASM_TARGET_DIRECTORY` - Will copy release build WASM binary to the given directory. The path needs
|
||||||
to be absolute.
|
to be absolute.
|
||||||
* `WASM_BUILD_RUSTFLAGS` - Extend `RUSTFLAGS` given to `cargo build` while building the wasm binary.
|
* `WASM_BUILD_RUSTFLAGS` - Extend `RUSTFLAGS` given to `cargo build` while building the wasm binary.
|
||||||
* `WASM_BUILD_NO_COLOR` - Disable color output of the wasm build.
|
* `WASM_BUILD_NO_COLOR` - Disable color output of the wasm build.
|
||||||
|
|||||||
@@ -168,17 +168,29 @@ pub fn build_project_with_default_rustflags(
|
|||||||
default_rustflags,
|
default_rustflags,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let (wasm_binary, wasm_binary_bloaty) = if let Some(wasm_binary) = wasm_binary {
|
||||||
|
(
|
||||||
|
wasm_binary.wasm_binary_path_escaped(),
|
||||||
|
bloaty.wasm_binary_bloaty_path_escaped(),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
(
|
||||||
|
bloaty.wasm_binary_bloaty_path_escaped(),
|
||||||
|
bloaty.wasm_binary_bloaty_path_escaped(),
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
write_file_if_changed(
|
write_file_if_changed(
|
||||||
file_name.into(),
|
file_name.into(),
|
||||||
format!(
|
format!(
|
||||||
r#"
|
r#"
|
||||||
pub const WASM_BINARY: Option<&[u8]> = Some(include_bytes!("{wasm_binary}"));
|
pub const WASM_BINARY: Option<&[u8]> = Some(include_bytes!("{wasm_binary}"));
|
||||||
pub const WASM_BINARY_BLOATY: Option<&[u8]> = Some(include_bytes!("{wasm_binary_bloaty}"));
|
pub const WASM_BINARY_BLOATY: Option<&[u8]> = Some(include_bytes!("{wasm_binary_bloaty}"));
|
||||||
"#,
|
"#,
|
||||||
wasm_binary = wasm_binary.wasm_binary_path_escaped(),
|
wasm_binary = wasm_binary,
|
||||||
wasm_binary_bloaty = bloaty.wasm_binary_bloaty_path_escaped(),
|
wasm_binary_bloaty = wasm_binary_bloaty,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if the build of the WASM binary should be skipped.
|
/// Checks if the build of the WASM binary should be skipped.
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ impl Drop for WorkspaceLock {
|
|||||||
pub fn create_and_compile(
|
pub fn create_and_compile(
|
||||||
cargo_manifest: &Path,
|
cargo_manifest: &Path,
|
||||||
default_rustflags: &str,
|
default_rustflags: &str,
|
||||||
) -> (WasmBinary, WasmBinaryBloaty) {
|
) -> (Option<WasmBinary>, WasmBinaryBloaty) {
|
||||||
let wasm_workspace_root = get_wasm_workspace_root();
|
let wasm_workspace_root = get_wasm_workspace_root();
|
||||||
let wasm_workspace = wasm_workspace_root.join("wbuild");
|
let wasm_workspace = wasm_workspace_root.join("wbuild");
|
||||||
|
|
||||||
@@ -113,7 +113,9 @@ pub fn create_and_compile(
|
|||||||
&wasm_workspace,
|
&wasm_workspace,
|
||||||
);
|
);
|
||||||
|
|
||||||
copy_wasm_to_target_directory(cargo_manifest, &wasm_binary);
|
wasm_binary.as_ref().map(|wasm_binary|
|
||||||
|
copy_wasm_to_target_directory(cargo_manifest, wasm_binary)
|
||||||
|
);
|
||||||
|
|
||||||
generate_rerun_if_changed_instructions(cargo_manifest, &project, &wasm_workspace);
|
generate_rerun_if_changed_instructions(cargo_manifest, &project, &wasm_workspace);
|
||||||
|
|
||||||
@@ -469,18 +471,23 @@ fn compact_wasm_file(
|
|||||||
project: &Path,
|
project: &Path,
|
||||||
cargo_manifest: &Path,
|
cargo_manifest: &Path,
|
||||||
wasm_workspace: &Path,
|
wasm_workspace: &Path,
|
||||||
) -> (WasmBinary, WasmBinaryBloaty) {
|
) -> (Option<WasmBinary>, WasmBinaryBloaty) {
|
||||||
let target = if is_release_build() { "release" } else { "debug" };
|
let is_release_build = is_release_build();
|
||||||
|
let target = if is_release_build { "release" } else { "debug" };
|
||||||
let wasm_binary = get_wasm_binary_name(cargo_manifest);
|
let wasm_binary = get_wasm_binary_name(cargo_manifest);
|
||||||
let wasm_file = wasm_workspace.join("target/wasm32-unknown-unknown")
|
let wasm_file = wasm_workspace.join("target/wasm32-unknown-unknown")
|
||||||
.join(target)
|
.join(target)
|
||||||
.join(format!("{}.wasm", wasm_binary));
|
.join(format!("{}.wasm", wasm_binary));
|
||||||
let wasm_compact_file = project.join(format!("{}.compact.wasm", wasm_binary));
|
let wasm_compact_file = if is_release_build {
|
||||||
|
let wasm_compact_file = project.join(format!("{}.compact.wasm", wasm_binary));
|
||||||
|
wasm_gc::garbage_collect_file(&wasm_file, &wasm_compact_file)
|
||||||
|
.expect("Failed to compact generated WASM binary.");
|
||||||
|
Some(WasmBinary(wasm_compact_file))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
wasm_gc::garbage_collect_file(&wasm_file, &wasm_compact_file)
|
(wasm_compact_file, WasmBinaryBloaty(wasm_file))
|
||||||
.expect("Failed to compact generated WASM binary.");
|
|
||||||
|
|
||||||
(WasmBinary(wasm_compact_file), WasmBinaryBloaty(wasm_file))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Custom wrapper for a [`cargo_metadata::Package`] to store it in
|
/// Custom wrapper for a [`cargo_metadata::Package`] to store it in
|
||||||
|
|||||||
Reference in New Issue
Block a user