Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
1ed68f2
Introduce `wasm-builder` and `wasm-builder-runner` to retire `build.sh`
bkchr Jun 13, 2019
96b1fb6
Add build script and remove the wasm project
bkchr Jun 13, 2019
47dd047
Port `node-runtime` to new wasm-builder
bkchr Jun 14, 2019
468bbee
Make `substrate-executor` tests work with `wasm-builder`
bkchr Jun 14, 2019
3e6108f
Move `node-template` to `wasm-builder`
bkchr Jun 14, 2019
cdd2619
Remove `build.sh` :)
bkchr Jun 14, 2019
fb80a34
Remove the last include_bytes
bkchr Jun 14, 2019
8a61c2f
Adds the missing build.rs files
bkchr Jun 14, 2019
f4ceedc
Remove `build.sh` from CI
bkchr Jun 14, 2019
c9e4094
Debug CI
bkchr Jun 14, 2019
4269b6f
Make it work in CI
bkchr Jun 14, 2019
98c3dad
CI attempt 3
bkchr Jun 14, 2019
3140240
Make `substrate-runtime-test` compile on stable
bkchr Jun 14, 2019
ee690d4
Ahhh, some missed `include_bytes!`
bkchr Jun 14, 2019
cd62ba8
AHH
bkchr Jun 14, 2019
4daabf1
Add suggestions
bkchr Jun 17, 2019
1b334b2
Improve search for `Cargo.lock` and don't panic if it is not found
bkchr Jun 17, 2019
22273d8
Merge branch 'master' into bkchr-wasm-builder
bkchr Jun 17, 2019
30960db
Searching from manifest path was no good idea
bkchr Jun 17, 2019
b54231d
Make the `wasm-builder` source better configurable
bkchr Jun 17, 2019
d522b5c
Merge remote-tracking branch 'origin/master' into bkchr-wasm-builder
bkchr Jun 26, 2019
320ce2d
Expose the bloaty wasm binary as well
bkchr Jun 26, 2019
3a8c627
Make sure to rerun WASM recompilation on changes in dependencies
bkchr Jun 26, 2019
5e17414
Introduce new `WASM_BUILD_TYPE` env and make sure to call `build.rs` on
bkchr Jun 26, 2019
54e07da
Remove `build.sh` from READMEs
bkchr Jun 26, 2019
416e5e5
Rename the projects
bkchr Jun 26, 2019
2ffc83a
Fixes CI
bkchr Jun 26, 2019
cef2a99
Merge remote-tracking branch 'origin/master' into bkchr-wasm-builder
bkchr Jun 26, 2019
5dfd5d6
Update lock file
bkchr Jun 26, 2019
04aca22
Fixes merge-conflict
bkchr Jun 26, 2019
ed434f5
Apply suggestions from code review
bkchr Jun 26, 2019
420f5d9
Try to make windows happy
bkchr Jun 27, 2019
c6a4dbb
Replace all back slashes in paths with slashes
bkchr Jun 29, 2019
a2e471e
Apply suggestions from code review
bkchr Jun 29, 2019
434ee08
Use cargo from `CARGO` env variable
bkchr Jun 29, 2019
1dd2803
Merge remote-tracking branch 'origin/master' into bkchr-wasm-builder
bkchr Jun 29, 2019
fd2da24
Fix compilation
bkchr Jun 30, 2019
f0c2746
Use `rustup` for running the nightly build
bkchr Jul 1, 2019
c150290
Make individual projects skipable
bkchr Jul 1, 2019
58db3fc
Fix compilation
bkchr Jul 1, 2019
3bb8192
Merge remote-tracking branch 'origin/master' into bkchr-wasm-builder
bkchr Jul 2, 2019
8143a18
Fixes compilation
bkchr Jul 2, 2019
3cd7239
Build all WASM projects in one workspace
bkchr Jul 3, 2019
a83e575
Replace more back slashes!
bkchr Jul 3, 2019
6343b8e
Remove `inlcude_bytes!`
bkchr Jul 3, 2019
efb977b
Adds some documentation
bkchr Jul 3, 2019
e34b0fc
Apply suggestions from code review
bkchr Jul 4, 2019
36e6d97
Apply suggestions from code review
bkchr Jul 4, 2019
c5804bb
More review comments
bkchr Jul 4, 2019
4d22d0e
Merge remote-tracking branch 'origin/master' into bkchr-wasm-builder
bkchr Jul 4, 2019
3007382
Update `Cargo.lock`
bkchr Jul 4, 2019
51660ab
Set license
bkchr Jul 4, 2019
c7674da
Apply suggestions from code review
bkchr Jul 4, 2019
c2f5580
Merge branch 'bkchr-wasm-builder' of github.com:paritytech/substrate …
bkchr Jul 4, 2019
ca8ff6f
More review comments + adds `TRIGGER_WASM_BUILD` env
bkchr Jul 4, 2019
b38fe79
Fix doc tests
bkchr Jul 4, 2019
b4c7b54
Increase version + update README
bkchr Jul 4, 2019
4427ebe
Switch crates.io version of `wasm-builder`
bkchr Jul 4, 2019
61b5c7a
Update README
bkchr Jul 4, 2019
890d420
Switch to released version of `wasm-builder-runner`
bkchr Jul 4, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions core/utils/wasm-builder-runner/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# WASM builder runner

As cargo just contains millions of bugs when it comes to correct dependency and feature
As cargo contains many bugs when it comes to correct dependency and feature
resolution, we need this little tool. See <https://github.com/rust-lang/cargo/issues/5730> for
more information.

It will create a project that itself will call `substrate-wasm-builder` to not let any dependency
from `substrate-wasm-builder` influence the main project's dependencies.
It will create a project that will call `substrate-wasm-builder` to prevent any dependencies
from `substrate-wasm-builder` influencing the main project's dependencies.

For more information see <https://crates.io/substrate-wasm-builder>
10 changes: 5 additions & 5 deletions core/utils/wasm-builder-runner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@

//! # WASM builder runner
//!
//! Since cargo contains millions of bugs when it comes to correct dependency and feature
//! Since cargo contains many bugs when it comes to correct dependency and feature
//! resolution, we need this little tool. See <https://github.com/rust-lang/cargo/issues/5730> for
//! more information.
//!
//! It will create a project that itself will call `substrate-wasm-builder` to not let any dependency
//! from `substrate-wasm-builder` influence the main project's dependencies.
//! It will create a project that will call `substrate-wasm-builder` to prevent any dependencies
//! from `substrate-wasm-builder` influencing the main project's dependencies.
//!
//! For more information see <https://crates.io/substrate-wasm-builder>

Expand Down Expand Up @@ -76,7 +76,7 @@ impl WasmBuilderSource {
}
}

/// Build the currently build project as WASM binary.
/// Build the currently built project as WASM binary.
///
/// The current project is determined using the `CARGO_MANIFEST_DIR` environment variable.
///
Expand Down Expand Up @@ -192,7 +192,7 @@ fn provide_dummy_wasm_binary(file_path: &Path) {
}

/// Generate the `rerun-if-changed` instructions for cargo to make sure that the WASM binary is
/// rebuild when needed.
/// rebuilt when needed.
fn generate_rerun_if_changed_instructions() {
// Make sure that the `build.rs` is called again if one of the following env variables changes.
println!("cargo:rerun-if-env-changed={}", SKIP_BUILD_ENV);
Expand Down
12 changes: 6 additions & 6 deletions core/utils/wasm-builder/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# substrate-wasm-builder

## WASM builder is an 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 building of a WASM binary of your project into the main
`cargo` build process.

### Project setup

A project that should be compiled as WASM binary needs to add a `build.rs`, add
A project that should be compiled as a WASM binary needs to add a `build.rs`, add
`substrate-wasm-builder-runner` as dependency into `build-dependencies` and requires to have a
feature called `no-std`. The `build.rs` needs to contain the following code:

Expand All @@ -26,18 +26,18 @@ fn main() {

The `no-std` feature will be enabled by WASM builder while compiling your project to WASM.

As a last step you need to add the following to your project:
As a last step, you need to add the following to your project:

```rust,nocompile
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 the WASM binary compacted and the later without compaction.
This will include the generated WASM binary as two constants `WASM_BINARY` and `WASM_BINARY_BLOATY`.
The former is the WASM binary compacted and the latter without compaction.

### Environment variables

By using environment variables, you can configure which WASM binaries are build and how:
By using environment variables, you can configure which WASM binaries to build 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
Expand Down
12 changes: 6 additions & 6 deletions core/utils/wasm-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.

//! # WASM builder is an 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.
Expand Down Expand Up @@ -50,7 +50,7 @@
//! ```
//!
//! 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 later is not compacted.
//! The former is a compact WASM binary and the latter is not compacted.
//!
//! ## Environment variables
//!
Expand Down Expand Up @@ -85,16 +85,16 @@ const SKIP_BUILD_ENV: &str = "SKIP_WASM_BUILD";
/// Environment variable to force a certain build type when building the WASM binary.
/// Expects "debug" or "release" as value.
///
/// By default the WASM binary uses the same build type a the main cargo build.
/// By default the WASM binary uses the same build type as the main cargo build.
const WASM_BUILD_TYPE_ENV: &str = "WASM_BUILD_TYPE";

/// Build the currently build project as WASM binary.
/// Build the currently built project as WASM binary.
///
/// The current project is determined by using the `CARGO_MANIFEST_DIR` environment variable.
///
/// `file_name` - The name + path of the file being generated. The file contains the
/// constant `WASM_BINARY` which contains the build wasm binary.
/// `cargo_manifest` - The path to the `Cargo.toml` of the project that should be build.
/// constant `WASM_BINARY`, which contains the built WASM binary.
/// `cargo_manifest` - The path to the `Cargo.toml` of the project that should be built.
pub fn build_project(file_name: &str, cargo_manifest: &str) {
if check_skip_build() {
return;
Expand Down
8 changes: 4 additions & 4 deletions core/utils/wasm-builder/src/wasm_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub fn create_and_compile(cargo_manifest: &Path) -> (WasmBinary, WasmBinaryBloat

/// Find the `Cargo.lock` relative to the `OUT_DIR` environment variable.
///
/// If the `Cargo.lock` can not be found, we emit a warning and return `None`.
/// If the `Cargo.lock` cannot be found, we emit a warning and return `None`.
fn find_cargo_lock(cargo_manifest: &Path) -> Option<PathBuf> {
let mut path = build_helper::out_dir();

Expand Down Expand Up @@ -231,7 +231,7 @@ fn create_project(cargo_manifest: &Path, wasm_workspace: &Path) -> PathBuf {
project_folder
}

/// Returns if the project should be build a release.
/// Returns if the project should be built as a release.
fn is_release_build() -> bool {
if let Ok(var) = env::var(crate::WASM_BUILD_TYPE_ENV) {
match var.as_str() {
Expand Down Expand Up @@ -270,7 +270,7 @@ fn build_project(project: &Path) {
}
}

/// Compact the WASM binary using `wasm-gc` and returns the path to the bloaty WASM binary.
/// Compact the WASM binary using `wasm-gc`. Returns the path to the bloaty WASM binary.
fn compact_wasm_file(
project: &Path,
cargo_manifest: &Path,
Expand All @@ -297,7 +297,7 @@ fn compact_wasm_file(
}

/// Generate the `rerun-if-changed` instructions for cargo to make sure that the WASM binary is
/// rebuild when needed.
/// rebuilt when needed.
fn generate_rerun_if_changed_instructions(
cargo_manifest: &Path,
project_folder: &Path,
Expand Down