This is a helper crate that can be used in build scripts for building Gear programs.
gear-wasm-buider crate as a build dependency to the Cargo.toml:toml
...
[build-dependencies]
gear-wasm-builder = "0.1.0"
...
build.rs file and place it at the directory with Cargo.toml:rust
fn main() {
gear_wasm_builder::build();
}
cargo as usually:bash
cargo clean
cargo build
cargo build --release
cargo test
cargo test --release
target/wasm32-unknown-unknown/<profile> directory:.wasm — original WASM built from the source files.opt.wasm — optimised WASM binary to be submitted to the blockchain.meta.wasm — metadata providing WASM binary for auxiliary purposeswasm_binary.rs source file to use the WASM code while e.g. writing tests.```rust mod code { include!(concat!(env!("OUTDIR"), "/wasmbinary.rs")); }
fn debugwasm() { asserteq!( std::fs::read("target/wasm32-unknown-unknown/debug/testprogram.wasm").unwrap(), code::WASMBINARY, ); asserteq!( std::fs::read("target/wasm32-unknown-unknown/debug/testprogram.opt.wasm").unwrap(), code::WASMBINARYOPT, ); asserteq!( std::fs::read("target/wasm32-unknown-unknown/debug/testprogram.meta.wasm").unwrap(), code::WASMBINARYMETA, ); } ```
Source code is licensed under GPL-3.0-or-later WITH Classpath-exception-2.0.