| Crates.io | gear-wasm-builder |
| lib.rs | gear-wasm-builder |
| version | 1.9.1 |
| created_at | 2022-02-18 12:04:32.645778+00 |
| updated_at | 2025-09-05 14:18:41.187729+00 |
| description | Utility for building Gear programs |
| homepage | https://gear-tech.io |
| repository | https://github.com/gear-tech/gear |
| max_upload_size | |
| id | 534663 |
| size | 88,430 |
This is a helper crate that can be used in build scripts for building Gear programs.
gear-wasm-builder crate as a build dependency to the Cargo.toml:# ...
[build-dependencies]
gear-wasm-builder = "0.1.2"
# ...
build.rs file and place it at the directory with Cargo.toml:fn main() {
gear_wasm_builder::build();
}
cargo as usually:cargo clean
cargo build
cargo build --release
cargo test
cargo test --release
target/wasm32-gear/<profile> directory:.wasm — original WASM built from the source files.opt.wasm — optimised WASM binary to be submitted to the blockchainwasm_binary.rs source file to use the WASM code while e.g. writing tests. When
doing this, you need to use some feature which will be excluded from passing it down to the build process triggered
by the build script. By default, this is the std feature. If you want to use a custom feature for that, use one of
the the build_XXX_custom functions in your build.rs#[cfg(feature = "std")]
mod code {
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
}
#[test]
fn debug_wasm() {
assert_eq!(
std::fs::read("target/wasm32-gear/debug/test_program.wasm").unwrap(),
code::WASM_BINARY,
);
assert_eq!(
std::fs::read("target/wasm32-gear/debug/test_program.opt.wasm").unwrap(),
code::WASM_BINARY_OPT,
);
}
Source code is licensed under GPL-3.0-or-later WITH Classpath-exception-2.0.