From 222ff6fe7969b27aeb0713dc3ff828586c957a83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Sun, 20 Oct 2019 13:02:21 +0200 Subject: [PATCH] Clean up the wasm-builder and release 1.0.8 (#3858) --- substrate/Cargo.lock | 2 +- substrate/core/executor/runtime-test/build.rs | 2 +- substrate/core/test-runtime/build.rs | 2 +- substrate/core/utils/wasm-builder/Cargo.toml | 2 +- substrate/core/utils/wasm-builder/src/lib.rs | 23 +++++++++++-------- .../utils/wasm-builder/src/prerequisites.rs | 12 ++++------ substrate/node-template/runtime/build.rs | 2 +- substrate/node/runtime/build.rs | 2 +- 8 files changed, 23 insertions(+), 24 deletions(-) diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock index d9bfc40409..aab1866999 100644 --- a/substrate/Cargo.lock +++ b/substrate/Cargo.lock @@ -5759,7 +5759,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" -version = "1.0.7" +version = "1.0.8" dependencies = [ "build-helper 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "cargo_metadata 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/substrate/core/executor/runtime-test/build.rs b/substrate/core/executor/runtime-test/build.rs index 136dc79398..68e5205f0c 100644 --- a/substrate/core/executor/runtime-test/build.rs +++ b/substrate/core/executor/runtime-test/build.rs @@ -21,7 +21,7 @@ fn main() { "wasm_binary.rs", WasmBuilderSource::CratesOrPath { path: "../../utils/wasm-builder", - version: "1.0.7", + version: "1.0.8", }, // This instructs LLD to export __heap_base as a global variable, which is used by the // external memory allocator. diff --git a/substrate/core/test-runtime/build.rs b/substrate/core/test-runtime/build.rs index 2e2d1fc93e..200cd6d42c 100644 --- a/substrate/core/test-runtime/build.rs +++ b/substrate/core/test-runtime/build.rs @@ -21,7 +21,7 @@ fn main() { "wasm_binary.rs", WasmBuilderSource::CratesOrPath { path: "../utils/wasm-builder", - version: "1.0.7", + version: "1.0.8", }, // Note that we set the stack-size to 1MB explicitly even though it is set // to this value by default. This is because some of our tests (`restoration_of_globals`) diff --git a/substrate/core/utils/wasm-builder/Cargo.toml b/substrate/core/utils/wasm-builder/Cargo.toml index 7fcdd6c4e1..e9d38f2bd2 100644 --- a/substrate/core/utils/wasm-builder/Cargo.toml +++ b/substrate/core/utils/wasm-builder/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "substrate-wasm-builder" -version = "1.0.7" +version = "1.0.8" authors = ["Parity Technologies "] description = "Utility for building WASM binaries" edition = "2018" diff --git a/substrate/core/utils/wasm-builder/src/lib.rs b/substrate/core/utils/wasm-builder/src/lib.rs index b97559c076..93e1700792 100644 --- a/substrate/core/utils/wasm-builder/src/lib.rs +++ b/substrate/core/utils/wasm-builder/src/lib.rs @@ -205,9 +205,7 @@ impl CargoCommand { } fn args(&mut self, args: &[&str]) -> &mut Self { - for arg in args { - self.arg(arg); - } + args.into_iter().for_each(|a| { self.arg(a); }); self } @@ -227,12 +225,17 @@ impl CargoCommand { /// Check if the supplied cargo command is a nightly version fn is_nightly(&self) -> bool { - self.command() - .arg("--version") - .output() - .map_err(|_| ()) - .and_then(|o| String::from_utf8(o.stdout).map_err(|_| ())) - .unwrap_or_default() - .contains("-nightly") + // `RUSTC_BOOTSTRAP` tells a stable compiler to behave like a nightly. So, when this env + // variable is set, we can assume that whatever rust compiler we have, it is a nightly compiler. + // For "more" information, see: + // https://github.com/rust-lang/rust/blob/fa0f7d0080d8e7e9eb20aa9cbf8013f96c81287f/src/libsyntax/feature_gate/check.rs#L891 + env::var("RUSTC_BOOTSTRAP").is_ok() || + self.command() + .arg("--version") + .output() + .map_err(|_| ()) + .and_then(|o| String::from_utf8(o.stdout).map_err(|_| ())) + .unwrap_or_default() + .contains("-nightly") } } diff --git a/substrate/core/utils/wasm-builder/src/prerequisites.rs b/substrate/core/utils/wasm-builder/src/prerequisites.rs index 73e356f0c2..3a7f8387dc 100644 --- a/substrate/core/utils/wasm-builder/src/prerequisites.rs +++ b/substrate/core/utils/wasm-builder/src/prerequisites.rs @@ -14,7 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -use std::{env, fs}; +use std::fs; + use tempfile::tempdir; /// Checks that all prerequisites are installed. @@ -22,20 +23,15 @@ use tempfile::tempdir; /// # Returns /// Returns `None` if everything was found and `Some(ERR_MSG)` if something could not be found. pub fn check() -> Option<&'static str> { - if !rustc_stable_forced_to_nightly() && !check_nightly_installed(){ + if !check_nightly_installed(){ return Some("Rust nightly not installed, please install it!") } check_wasm_toolchain_installed() } -fn rustc_stable_forced_to_nightly() -> bool { - env::var("RUSTC_BOOTSTRAP") == Ok("1".to_string()) -} - fn check_nightly_installed() -> bool { - let command = crate::get_nightly_cargo(); - command.is_nightly() + crate::get_nightly_cargo().is_nightly() } fn check_wasm_toolchain_installed() -> Option<&'static str> { diff --git a/substrate/node-template/runtime/build.rs b/substrate/node-template/runtime/build.rs index ddbeefa112..c5e798c6ef 100644 --- a/substrate/node-template/runtime/build.rs +++ b/substrate/node-template/runtime/build.rs @@ -19,7 +19,7 @@ use wasm_builder_runner::{build_current_project_with_rustflags, WasmBuilderSourc fn main() { build_current_project_with_rustflags( "wasm_binary.rs", - WasmBuilderSource::Crates("1.0.7"), + WasmBuilderSource::Crates("1.0.8"), // This instructs LLD to export __heap_base as a global variable, which is used by the // external memory allocator. "-Clink-arg=--export=__heap_base", diff --git a/substrate/node/runtime/build.rs b/substrate/node/runtime/build.rs index 7311fb90ce..f5c2f98a75 100644 --- a/substrate/node/runtime/build.rs +++ b/substrate/node/runtime/build.rs @@ -21,7 +21,7 @@ fn main() { "wasm_binary.rs", WasmBuilderSource::CratesOrPath { path: "../../core/utils/wasm-builder", - version: "1.0.7", + version: "1.0.8", }, // This instructs LLD to export __heap_base as a global variable, which is used by the // external memory allocator.