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
+21
View File
@@ -2840,6 +2840,14 @@ dependencies = [
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "parity-wasm"
version = "0.32.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "parity-wasm"
version = "0.40.3"
@@ -5759,6 +5767,7 @@ dependencies = [
"tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-gc-api 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -6516,6 +6525,16 @@ dependencies = [
"weedle 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasm-gc-api"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-wasm 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasm-timer"
version = "0.1.3"
@@ -7019,6 +7038,7 @@ dependencies = [
"checksum parity-scale-codec-derive 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "42af752f59119656fa3cb31e8852ed24e895b968c0bdb41847da7f0cea6d155f"
"checksum parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f"
"checksum parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2005637ccf93dbb60c85081ccaaf3f945f573da48dcc79f27f9646caa3ec1dc"
"checksum parity-wasm 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "16ad52817c4d343339b3bc2e26861bd21478eda0b7509acf83505727000512ac"
"checksum parity-wasm 0.40.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1e39faaa292a687ea15120b1ac31899b13586446521df6c149e46f1584671e0f"
"checksum parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f0802bff09003b291ba756dc7e79313e51cc31667e94afbe847def490424cde5"
"checksum parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337"
@@ -7219,6 +7239,7 @@ dependencies = [
"checksum wasm-bindgen-macro-support 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "9c075d27b7991c68ca0f77fe628c3513e64f8c477d422b859e03f28751b46fc5"
"checksum wasm-bindgen-shared 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "83d61fe986a7af038dd8b5ec660e5849cbd9f38e7492b9404cc48b2b4df731d1"
"checksum wasm-bindgen-webidl 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "9b979afb0535fe4749906a674082db1211de8aef466331d43232f63accb7c07c"
"checksum wasm-gc-api 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c32691b6c7e6c14e7f8fd55361a9088b507aa49620fcd06c09b3a1082186b9"
"checksum wasm-timer 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "aa3e01d234bb71760e685cfafa5e2c96f8ad877c161a721646356651069e26ac"
"checksum wasmi 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f31d26deb2d9a37e6cfed420edce3ed604eab49735ba89035e13c98f9a528313"
"checksum wasmi-validation 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6bc0356e3df56e639fc7f7d8a99741915531e27ed735d911ed83d7e1339c8188"
-1
View File
@@ -20,7 +20,6 @@ RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && \
export PATH="$PATH:$HOME/.cargo/bin" && \
rustup toolchain install nightly && \
rustup target add wasm32-unknown-unknown --toolchain nightly && \
cargo install --git https://github.com/alexcrichton/wasm-gc && \
rustup default nightly && \
rustup default stable && \
cargo build "--$PROFILE"
+4 -9
View File
@@ -184,7 +184,6 @@ curl https://sh.rustup.rs -sSf | sh
rustup update nightly
rustup target add wasm32-unknown-unknown --toolchain nightly
rustup update stable
cargo install --git https://github.com/alexcrichton/wasm-gc
----
You will also need to install the following packages:
@@ -231,13 +230,9 @@ If you are trying to set up Substrate on Windows, you should do the following:
rustup update stable
rustup target add wasm32-unknown-unknown --toolchain nightly
4. Next, you install wasm-gc, which is used to slim down Wasm files:
4. Then, you need to install LLVM: https://releases.llvm.org/download.html
cargo install --git https://github.com/alexcrichton/wasm-gc --force
5. Then, you need to install LLVM: https://releases.llvm.org/download.html
6. Next, you need to install OpenSSL, which we will do with `vcpkg`:
5. Next, you need to install OpenSSL, which we will do with `vcpkg`:
mkdir \Tools
cd \Tools
@@ -246,14 +241,14 @@ If you are trying to set up Substrate on Windows, you should do the following:
.\bootstrap-vcpkg.bat
.\vcpkg.exe install openssl:x64-windows-static
7. After, you need to add OpenSSL to your System Variables. Note that in order for the following commands to work, you need to use Windows Powershell:
6. After, you need to add OpenSSL to your System Variables. Note that in order for the following commands to work, you need to use Windows Powershell:
$env:OPENSSL_DIR = 'C:\Tools\vcpkg\installed\x64-windows-static'
$env:OPENSSL_STATIC = 'Yes'
[System.Environment]::SetEnvironmentVariable('OPENSSL_DIR', $env:OPENSSL_DIR, [System.EnvironmentVariableTarget]::User)
[System.Environment]::SetEnvironmentVariable('OPENSSL_STATIC', $env:OPENSSL_STATIC, [System.EnvironmentVariableTarget]::User)
8. Finally, you need to install `cmake`: https://cmake.org/download/
7. Finally, you need to install `cmake`: https://cmake.org/download/
==== Shared Steps
@@ -15,3 +15,4 @@ tempfile = "3.1.0"
toml = "0.5.3"
walkdir = "2.2.9"
fs2 = "0.4.3"
wasm-gc-api = "0.1.11"
@@ -57,7 +57,6 @@ be `NODE_RUNTIME`.
WASM builder requires the following prerequisities for building the WASM binary:
- rust nightly + `wasm32-unknown-unknown` toolchain
- wasm-gc
License: GPL-3.0
@@ -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))
}
-4
View File
@@ -10,7 +10,3 @@ if [ -z $CI_PROJECT_NAME ] ; then
fi
rustup target add wasm32-unknown-unknown --toolchain nightly
# Install wasm-gc. It's useful for stripping slimming down wasm binaries.
command -v wasm-gc || \
cargo +nightly install --git https://github.com/alexcrichton/wasm-gc --force
-4
View File
@@ -10,7 +10,3 @@ if [ -z $CI_PROJECT_NAME ] ; then
fi
rustup target add wasm32-unknown-unknown --toolchain nightly
# Install wasm-gc. It's useful for stripping slimming down wasm binaries.
command -v wasm-gc || \
cargo +nightly install --git https://github.com/alexcrichton/wasm-gc --force