Skip to content

Commit 7a75fe9

Browse files
author
Michael Müller
authored
Suggest binaryen installation from GitHub on outdated version (#274)
* Suggest `binaryen` installation from GitHub on outdated version * Fix tests
1 parent efb8ced commit 7a75fe9

2 files changed

Lines changed: 18 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
### Added
10+
- Suggest `binaryen` installation from GitHub release on outdated version - [#274](https://github.com/paritytech/cargo-contract/pull/274)
11+
912
## [0.12.0] - 2021-04-21
1013

1114
### Fixed

src/cmd/build.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -437,15 +437,21 @@ fn check_wasm_opt_version_compatibility(wasm_opt_path: &Path) -> Result<()> {
437437
// $ wasm-opt --version
438438
// wasm-opt version 99 (version_99-79-gc12cc3f50)
439439
// ```
440+
let github_note = "\n\n\
441+
If you tried installing from your system package manager the best\n\
442+
way forward is to download a recent binary release directly:\n\n\
443+
https://github.com/WebAssembly/binaryen/releases\n\n\
444+
Make sure that the `wasm-opt` file from that release is in your `PATH`.";
440445
let version_stdout = str::from_utf8(&cmd.stdout)
441446
.expect("Cannot convert stdout output of wasm-opt to string")
442447
.trim();
443448
let re = Regex::new(r"wasm-opt version (\d+)").expect("invalid regex");
444449
let captures = re.captures(version_stdout).ok_or_else(|| {
445450
anyhow::anyhow!(
446451
"Unable to extract version information from '{}'.\n\
447-
Your wasm-opt version is most probably too old. Make sure you use a version >= 99.",
448-
version_stdout
452+
Your wasm-opt version is most probably too old. Make sure you use a version >= 99.{}",
453+
version_stdout,
454+
github_note,
449455
)
450456
})?;
451457
let version_number: u32 = captures
@@ -473,8 +479,9 @@ fn check_wasm_opt_version_compatibility(wasm_opt_path: &Path) -> Result<()> {
473479
);
474480
if version_number < 99 {
475481
anyhow::bail!(
476-
"Your wasm-opt version is {}, but we require a version >= 99.",
477-
version_number
482+
"Your wasm-opt version is {}, but we require a version >= 99.{}",
483+
version_number,
484+
github_note,
478485
);
479486
}
480487
Ok(())
@@ -836,10 +843,8 @@ mod tests_ci_only {
836843

837844
// then
838845
assert!(res.is_err());
839-
assert_eq!(
840-
format!("{:?}", res),
841-
"Err(Your wasm-opt version is 98, but we require a version >= 99.)"
842-
);
846+
assert!(format!("{:?}", res)
847+
.starts_with("Err(Your wasm-opt version is 98, but we require a version >= 99."));
843848

844849
Ok(())
845850
})
@@ -874,10 +879,8 @@ mod tests_ci_only {
874879

875880
// then
876881
assert!(res.is_err());
877-
assert_eq!(
878-
format!("{:?}", res),
879-
"Err(Your wasm-opt version is 98, but we require a version >= 99.)"
880-
);
882+
assert!(format!("{:?}", res)
883+
.starts_with("Err(Your wasm-opt version is 98, but we require a version >= 99."));
881884

882885
Ok(())
883886
})

0 commit comments

Comments
 (0)