Skip to content

Commit 2c36a18

Browse files
committed
Improve Wasm assembler error message
Now includes information about which tool is missing and where to get it.
1 parent 0b372d0 commit 2c36a18

File tree

1 file changed

+41
-0
lines changed
  • web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasm/codegen

1 file changed

+41
-0
lines changed

web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasm/codegen/WasmAssembler.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,16 @@ private static RunResult runCommand(Path executable, List<String> args) throws I
189189
}
190190
}
191191

192+
protected String getDetails() {
193+
return "'%s' is part of the %s project (%s). At least version %s is required.".formatted(getExecutable(), getProjectName(), getURL(), getMinimumVersion());
194+
}
195+
196+
protected abstract String getProjectName();
197+
198+
protected abstract String getURL();
199+
200+
protected abstract String getMinimumVersion();
201+
192202
/**
193203
* The standard name of the assembler executable.
194204
*/
@@ -243,6 +253,7 @@ private UserError.UserException rethrowWithInfo(UserError.UserException err) {
243253
if (!pathOption.hasBeenSet()) {
244254
messages.add("A custom path to the " + getExecutable() + " executable can be set with the " + SubstrateOptionsParser.commandArgument(getPathOption(), "<path>") + " command-line option");
245255
}
256+
messages.add(getDetails());
246257
messages.add("To prevent native-toolchain checking provide command-line option " + SubstrateOptionsParser.commandArgument(SubstrateOptions.CheckToolchain, "-"));
247258
return UserError.abort(messages);
248259
}
@@ -394,6 +405,21 @@ protected Wat2Wasm(Path tempDirectory) {
394405
super(tempDirectory);
395406
}
396407

408+
@Override
409+
protected String getProjectName() {
410+
return "wabt";
411+
}
412+
413+
@Override
414+
protected String getURL() {
415+
return "https://github.com/WebAssembly/wabt";
416+
}
417+
418+
@Override
419+
protected String getMinimumVersion() {
420+
return "1.0.32";
421+
}
422+
397423
@Override
398424
protected String getExecutable() {
399425
return "wat2wasm";
@@ -439,6 +465,21 @@ protected Binaryen(Path tempDirectory) {
439465
super(tempDirectory);
440466
}
441467

468+
@Override
469+
protected String getProjectName() {
470+
return "Binaryen";
471+
}
472+
473+
@Override
474+
protected String getURL() {
475+
return "https://github.com/WebAssembly/binaryen";
476+
}
477+
478+
@Override
479+
protected String getMinimumVersion() {
480+
return "119";
481+
}
482+
442483
@Override
443484
protected String getExecutable() {
444485
return "wasm-as";

0 commit comments

Comments
 (0)