wasm-builder: Make it easier to build a WASM binary (#4177)

Basically combines all the recommended calls into one
`build_using_defaults()` call or `init_with_defaults()` when there are
some custom changes required.
This commit is contained in:
Bastian Köcher
2024-04-22 21:28:27 +02:00
committed by GitHub
parent 3380e21cd9
commit bd9287f766
17 changed files with 64 additions and 86 deletions
+3 -9
View File
@@ -33,15 +33,9 @@
//! use substrate_wasm_builder::WasmBuilder;
//!
//! fn main() {
//! WasmBuilder::new()
//! // Tell the builder to build the project (crate) this `build.rs` is part of.
//! .with_current_project()
//! // Make sure to export the `heap_base` global, this is required by Substrate
//! .export_heap_base()
//! // Build the Wasm file so that it imports the memory (need to be provided by at instantiation)
//! .import_memory()
//! // Build it.
//! .build()
//! // Builds the WASM binary using the recommended defaults.
//! // If you need more control, you can call `new` or `init_with_defaults`.
//! WasmBuilder::build_using_defaults();
//! }
//! ```
//!