From 2e457eb30113708ea1f3b3b6b5000a2f98ee70c8 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Wed, 12 May 2021 10:24:17 +0200 Subject: [PATCH 1/2] Suggest `binaryen` installation from GitHub on outdated version --- CHANGELOG.md | 3 +++ src/cmd/build.rs | 15 +++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd5a6bfc..49f68f6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added +- Suggest `binaryen` installation from GitHub release on outdated version - [#274](https://github.com/paritytech/cargo-contract/pull/274) + ## [0.12.0] - 2021-04-21 ### Fixed diff --git a/src/cmd/build.rs b/src/cmd/build.rs index 3e87c5af..d8076b5e 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -437,6 +437,11 @@ fn check_wasm_opt_version_compatibility(wasm_opt_path: &Path) -> Result<()> { // $ wasm-opt --version // wasm-opt version 99 (version_99-79-gc12cc3f50) // ``` + let github_note = "\n\n\ + If you tried installing from your system package manager the best\n\ + way forward is to download a recent binary release directly:\n\n\ + https://github.com/WebAssembly/binaryen/releases\n\n\ + Make sure that the `wasm-opt` file from that release is in your `PATH`."; let version_stdout = str::from_utf8(&cmd.stdout) .expect("Cannot convert stdout output of wasm-opt to string") .trim(); @@ -444,8 +449,9 @@ fn check_wasm_opt_version_compatibility(wasm_opt_path: &Path) -> Result<()> { let captures = re.captures(version_stdout).ok_or_else(|| { anyhow::anyhow!( "Unable to extract version information from '{}'.\n\ - Your wasm-opt version is most probably too old. Make sure you use a version >= 99.", - version_stdout + Your wasm-opt version is most probably too old. Make sure you use a version >= 99.{}", + version_stdout, + github_note, ) })?; let version_number: u32 = captures @@ -473,8 +479,9 @@ fn check_wasm_opt_version_compatibility(wasm_opt_path: &Path) -> Result<()> { ); if version_number < 99 { anyhow::bail!( - "Your wasm-opt version is {}, but we require a version >= 99.", - version_number + "Your wasm-opt version is {}, but we require a version >= 99.{}", + version_number, + github_note, ); } Ok(()) -- GitLab From 81d9bea1c11fa4cafc62016640dcbafa5ba28b63 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Wed, 12 May 2021 11:25:17 +0200 Subject: [PATCH 2/2] Fix tests --- src/cmd/build.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/cmd/build.rs b/src/cmd/build.rs index d8076b5e..25bfc025 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -843,10 +843,8 @@ mod tests_ci_only { // then assert!(res.is_err()); - assert_eq!( - format!("{:?}", res), - "Err(Your wasm-opt version is 98, but we require a version >= 99.)" - ); + assert!(format!("{:?}", res) + .starts_with("Err(Your wasm-opt version is 98, but we require a version >= 99.")); Ok(()) }) @@ -881,10 +879,8 @@ mod tests_ci_only { // then assert!(res.is_err()); - assert_eq!( - format!("{:?}", res), - "Err(Your wasm-opt version is 98, but we require a version >= 99.)" - ); + assert!(format!("{:?}", res) + .starts_with("Err(Your wasm-opt version is 98, but we require a version >= 99.")); Ok(()) }) -- GitLab