* Update all dependencies * Upgrade dependencies whenever “easy” “easy” means that there are no major changes required. * Fix build and bump paste dependency to 0.1.6 * Remove dead code * Re-add = dependency for futures-preview * Add missing std features for runtime-io * Remove git dependencies as updated versions have been published to crates.io * try to debug bug * For sr-io, "std" should imply "no_oom" and "no_panic_handler". Otherwise, rustc complains (correctly) about duplicate lang items. * Add missing "runtime-io/std" features * Fix compilation errors * Prevent duplicate lang items Rust does not allow duplicate lang items. When compiled without the `std` feature, `sr-io` defines two lang items. Therefore, `sr-io` compiled without `feature = "std"` must not be linked with `std`. However, `pwasm-utils` and `wasmi-validation` both bring in `std` unless compiled with `default-features = "false"`. This caused a duplicate lang item error. Building both with `default-features = "false"` prevents this error. When building with `feature = "std"`, they should both be built with the `std` feature, so this feature needs to be explicitly depended on. * Bump `impl_version` * Make tests pass Three tests used 1 less gas than they had previously. * Try to un-break build * Add a Cargo.lock file * Revert offchain code * Revert "Revert offchain code" This reverts commit d216d08cc6ca0344614669c1d24cde3aa5c0d4e2. * Don’t try to send a body with a GET request without adding a Transfer-Encoding or Content-Length header. This has always been wrong, but hyperium/hyper#1925 hid the bug until hyper was upgraded to 0.12.35. * Change some more GET requests to POST requests * Fix excess line width and remove an `extern crate` * Delete commented-out extern crate Co-Authored-By: Sergei Pepyakin <sergei@parity.io> * Fix regression in Cargo.toml files dev-dependencies need `default-features = false`, too. * Bump parity-wasm dependency * Bump `futures-preview` * Apply suggestions from code review Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> * Update Cargo.lock files * Apply suggestions from code review Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> * Update core/service/src/chain_ops.rs Co-Authored-By: Sergei Pepyakin <sergei@parity.io>
WASM builder is a utility for building a project as a WASM binary
The WASM builder is a tool that integrates the process of building the WASM binary of your project into the main
cargo build process.
Project setup
A project that should be compiled as a WASM binary needs to:
- Add a
build.rsfile. - Add
substrate-wasm-builder-runneras dependency intobuild-dependencies.
The build.rs file needs to contain the following code:
use wasm_builder_runner::{build_current_project, WasmBuilderSource};
fn main() {
build_current_project(
// The name of the file being generated in out-dir.
"wasm_binary.rs",
// How to include wasm-builder, in this case from crates.io.
WasmBuilderSource::Crates("1.0.0"),
);
}
As the final step, you need to add the following to your project:
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
This will include the generated WASM binary as two constants WASM_BINARY and WASM_BINARY_BLOATY.
The former is a compact WASM binary and the latter is not compacted.
Environment variables
By using environment variables, you can configure which WASM binaries are built and how:
SKIP_WASM_BUILD- Skips building any WASM binary. This is useful when only native should be recompiled.BUILD_DUMMY_WASM_BINARY- Builds dummy WASM binaries. These dummy binaries are empty and useful forcargo checkruns.WASM_BUILD_TYPE- Sets the build type for building WASM binaries. Supported values arereleaseordebug. By default the build type is equal to the build type used by the main build.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 instructscargoto watch for file changes this environment variable should only be required in certain circumstances.WASM_BUILD_RUSTFLAGS- ExtendRUSTFLAGSgiven tocargo buildwhile building the WASM binary.
Each project can be skipped individually by using the environment variable SKIP_PROJECT_NAME_WASM_BUILD.
Where PROJECT_NAME needs to be replaced by the name of the cargo project, e.g. node-runtime will
be NODE_RUNTIME.
Prerequisites:
WASM builder requires the following prerequisities for building the WASM binary:
- rust nightly +
wasm32-unknown-unknowntoolchain - wasm-gc
License: GPL-3.0