Change manual dependency on wasm-gc executable to an automatic cargo dependency. (#3854)

Improves user experience.
This commit is contained in:
Andrew Dirksen
2019-10-19 01:38:19 -07:00
committed by Bastian Köcher
parent 141a64cf41
commit 470b62366f
10 changed files with 30 additions and 42 deletions
@@ -75,7 +75,6 @@
//! WASM builder requires the following prerequisities for building the WASM binary:
//!
//! - rust nightly + `wasm32-unknown-unknown` toolchain
//! - wasm-gc
//!
use std::{env, fs, path::PathBuf, process::{Command, Stdio, self}};
@@ -14,9 +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/>.
use std::{process::{Command, Stdio}, fs};
use std::env;
use std::{env, fs};
use tempfile::tempdir;
/// Checks that all prerequisites are installed.
@@ -28,15 +26,6 @@ pub fn check() -> Option<&'static str> {
return Some("Rust nightly not installed, please install it!")
}
if Command::new("wasm-gc")
.stdout(Stdio::null())
.stderr(Stdio::null())
.status()
.map(|s| !s.success()).unwrap_or(true)
{
return Some("`wasm-gc` not installed, please install it!")
}
check_wasm_toolchain_installed()
}
@@ -16,7 +16,7 @@
use crate::write_file_if_changed;
use std::{fs, path::{Path, PathBuf}, borrow::ToOwned, process::{Command, self}, env};
use std::{fs, path::{Path, PathBuf}, borrow::ToOwned, process, env};
use toml::value::Table;
@@ -352,15 +352,8 @@ fn compact_wasm_file(
.join(format!("{}.wasm", wasm_binary));
let wasm_compact_file = project.join(format!("{}.compact.wasm", wasm_binary));
let res = Command::new("wasm-gc")
.arg(&wasm_file)
.arg(&wasm_compact_file)
.status()
.map(|s| s.success());
if !res.unwrap_or(false) {
panic!("Failed to compact generated WASM binary.");
}
wasm_gc::garbage_collect_file(&wasm_file, &wasm_compact_file)
.expect("Failed to compact generated WASM binary.");
(WasmBinary(wasm_compact_file), WasmBinaryBloaty(wasm_file))
}