End build when wasm-builder does not find a prerequisite (#3030)

* End build when `wasm-builder` does not find a prerequisite

Using `compile_error!` was a stupid idea by me, as rust would not
re-execute the build.rs.

* Increment the `wasm-builder` version

* Update core/utils/wasm-builder/src/lib.rs

Co-Authored-By: André Silva <andre.beat@gmail.com>
This commit is contained in:
Bastian Köcher
2019-07-05 15:02:14 +02:00
committed by GitHub
parent 22ec13cf65
commit 0ed2b26c96
8 changed files with 12 additions and 20 deletions
+1 -1
View File
@@ -4832,7 +4832,7 @@ dependencies = [
[[package]]
name = "substrate-wasm-builder"
version = "1.0.2"
version = "1.0.3"
dependencies = [
"build-helper 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cargo_metadata 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -21,7 +21,7 @@ fn main() {
"wasm_binary.rs",
WasmBuilderSource::CratesOrPath {
path: "../../utils/wasm-builder",
version: "1.0.2",
version: "1.0.3",
},
);
}
+1 -1
View File
@@ -21,7 +21,7 @@ fn main() {
"wasm_binary.rs",
WasmBuilderSource::CratesOrPath {
path: "../utils/wasm-builder",
version: "1.0.2",
version: "1.0.3",
},
);
}
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "substrate-wasm-builder"
version = "1.0.2"
version = "1.0.3"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Utility for building WASM binaries"
edition = "2018"
+5 -13
View File
@@ -78,7 +78,7 @@
//! - wasm-gc
//!
use std::{env, fs, path::PathBuf, process::{Command, Stdio}};
use std::{env, fs, path::PathBuf, process::{Command, Stdio, self}};
mod prerequisites;
mod wasm_project;
@@ -107,24 +107,16 @@ pub fn build_project(file_name: &str, cargo_manifest: &str) {
let cargo_manifest = PathBuf::from(cargo_manifest);
if !cargo_manifest.exists() {
create_out_file(
file_name,
format!("compile_error!(\"'{}' does not exists!\")", cargo_manifest.display())
);
return
panic!("'{}' does not exist!", cargo_manifest.display());
}
if !cargo_manifest.ends_with("Cargo.toml") {
create_out_file(
file_name,
format!("compile_error!(\"'{}' no valid path to a `Cargo.toml`!\")", cargo_manifest.display())
);
return
panic!("'{}' no valid path to a `Cargo.toml`!", cargo_manifest.display());
}
if let Some(err_msg) = prerequisites::check() {
create_out_file(file_name, format!("compile_error!(\"{}\");", err_msg));
return
eprintln!("{}", err_msg);
process::exit(1);
}
let (wasm_binary, bloaty) = wasm_project::create_and_compile(&cargo_manifest);
@@ -33,7 +33,7 @@ pub fn check() -> Option<&'static str> {
.status()
.map(|s| !s.success()).unwrap_or(true)
{
return Some("wasm-gc not installed, please install it!")
return Some("`wasm-gc` not installed, please install it!")
}
if !check_wasm_toolchain_installed() {
+1 -1
View File
@@ -17,5 +17,5 @@
use wasm_builder_runner::{build_current_project, WasmBuilderSource};
fn main() {
build_current_project("wasm_binary.rs", WasmBuilderSource::Crates("1.0.2"));
build_current_project("wasm_binary.rs", WasmBuilderSource::Crates("1.0.3"));
}
+1 -1
View File
@@ -21,7 +21,7 @@ fn main() {
"wasm_binary.rs",
WasmBuilderSource::CratesOrPath {
path: "../../core/utils/wasm-builder",
version: "1.0.2",
version: "1.0.3",
},
);
}