Implement color output for wasm builder (#4004)

* Implement color output for wasm builder

* Fix `Cargo.lock`
This commit is contained in:
Bastian Köcher
2019-11-02 19:59:49 +01:00
committed by GitHub
parent 5503c483b1
commit d233ad55ad
7 changed files with 53 additions and 38 deletions
+12 -9
View File
@@ -1,9 +1,9 @@
## WASM builder is a utility for building a project as a WASM binary
# 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
## Project setup
A project that should be compiled as a WASM binary needs to:
@@ -34,25 +34,28 @@ 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
## 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
- `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
for `cargo check` runs.
- `WASM_BUILD_TYPE` - Sets the build type for building WASM binaries. Supported values are `release` or `debug`.
- `WASM_BUILD_TYPE` - Sets the build type for building wasm binaries. Supported values are `release` or `debug`.
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
- `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 instructs `cargo` to watch for file changes
this environment variable should only be required in certain circumstances.
- `WASM_BUILD_RUSTFLAGS` - Extend `RUSTFLAGS` given to `cargo build` while building the WASM binary.
- `WASM_BUILD_RUSTFLAGS` - Extend `RUSTFLAGS` given to `cargo build` while building the wasm binary.
- `WASM_BUILD_NO_COLOR` - Disable color output of the wasm build.
- `WASM_TARGET_DIRECTORY` - Will copy any build wasm binary to the given directory. The path needs
to be absolute.
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:
## Prerequisites:
WASM builder requires the following prerequisities for building the WASM binary: