Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
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
Update utils/wasm-builder/src/lib.rs
Co-authored-by: Bastian Köcher <[email protected]>
  • Loading branch information
cheme and bkchr authored Sep 7, 2020
commit dd0afef29ff350a51d8eaf6a1f25bd812bf034b0
31 changes: 15 additions & 16 deletions utils/wasm-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,30 +168,29 @@ pub fn build_project_with_default_rustflags(
default_rustflags,
);

if let Some(wasm_binary) = wasm_binary {
write_file_if_changed(
file_name.into(),
format!(
r#"
pub const WASM_BINARY: Option<&[u8]> = Some(include_bytes!("{wasm_binary}"));
pub const WASM_BINARY_BLOATY: Option<&[u8]> = Some(include_bytes!("{wasm_binary_bloaty}"));
"#,
wasm_binary = wasm_binary.wasm_binary_path_escaped(),
wasm_binary_bloaty = bloaty.wasm_binary_bloaty_path_escaped(),
),
);
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 {
write_file_if_changed(
(
wasm_binary.wasm_binary_path_escaped(),
bloaty.wasm_binary_bloaty_path_escaped()
)
};

write_file_if_changed(
file_name.into(),
format!(
r#"
pub const WASM_BINARY: Option<&[u8]> = WASM_BINARY_BLOATY;
pub const WASM_BINARY: Option<&[u8]> = Some(include_bytes!("{wasm_binary}"));
pub const WASM_BINARY_BLOATY: Option<&[u8]> = Some(include_bytes!("{wasm_binary_bloaty}"));
"#,
wasm_binary_bloaty = bloaty.wasm_binary_bloaty_path_escaped(),
wasm_binary,
wasm_binary_bloaty,
),
);
}
}

/// Checks if the build of the WASM binary should be skipped.
Expand Down