mirror of
https://github.com/dart-lang/sdk
synced 2024-09-30 04:08:32 +00:00
[dart2wasm] Make tools/test.py -n dart2wasm-linux-jsshell ... work
Change-Id: I0a2678a5b141ab52597860380df7d44fd1f1db74 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338381 Commit-Queue: Martin Kustermann <kustermann@google.com> Reviewed-by: Ömer Ağacan <omersa@google.com>
This commit is contained in:
parent
cd4c378f82
commit
6e771a1ce9
|
@ -2,14 +2,23 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
//
|
||||
// Runner V8 script for testing dart2wasm, takes ".wasm" files as arguments.
|
||||
// Runner V8/JSShell script for testing dart2wasm, takes ".wasm" files as
|
||||
// arguments.
|
||||
//
|
||||
// Run as follows:
|
||||
// Run as follows on D8:
|
||||
//
|
||||
// $> d8 run_wasm.js \
|
||||
// -- /abs/path/to/<dart_module>.mjs <dart_module>.wasm [<ffi_module>.wasm] \
|
||||
// [-- Dart commandline arguments...]
|
||||
//
|
||||
// Run as follows on JSShell:
|
||||
//
|
||||
// $> js run_wasm.js \
|
||||
// /abs/path/to/<dart_module>.mjs <dart_module>.wasm [<ffi_module>.wasm] \
|
||||
// [-- Dart commandline arguments...]
|
||||
//
|
||||
// (Notice the missing -- here!)
|
||||
//
|
||||
// Please note we require an absolute path for the JS runtime. This is a
|
||||
// workaround for a discrepancy in D8. Specifically, `import`(used to load .mjs
|
||||
// files) searches for imports relative to run_wasm.js, but `readbuffer`(used to
|
||||
|
@ -306,11 +315,17 @@ const ffiArg = 2;
|
|||
self.dartUseDateNowForTicks = true;
|
||||
})(this, []);
|
||||
|
||||
|
||||
// This script is intended to be used by either D8 or JSShell. We distinguish
|
||||
// the two by seeing whether the global `arguments` exists (D8 uses `arguments`
|
||||
// and JsShell uses `scriptArgs`).
|
||||
var isD8 = (typeof arguments != "undefined");
|
||||
|
||||
// We would like this itself to be a ES module rather than a script, but
|
||||
// unfortunately d8 does not return a failed error code if an unhandled
|
||||
// exception occurs asynchronously in an ES module.
|
||||
const main = async () => {
|
||||
var args = arguments;
|
||||
var args = isD8 ? arguments : scriptArgs;
|
||||
var dartArgs = [];
|
||||
const argsSplit = args.indexOf("--");
|
||||
if (argsSplit != -1) {
|
||||
|
@ -321,7 +336,7 @@ const main = async () => {
|
|||
const dart2wasm = await import(args[jsRuntimeArg]);
|
||||
function compile(filename) {
|
||||
// Create a Wasm module from the binary wasm file.
|
||||
var bytes = readbuffer(filename);
|
||||
var bytes = isD8 ? readbuffer(filename) : readRelativeToScript(filename, "binary") ;
|
||||
return new WebAssembly.Module(bytes);
|
||||
}
|
||||
|
||||
|
|
|
@ -868,6 +868,7 @@ class Compiler extends NamedEnum {
|
|||
case Compiler.dart2wasm:
|
||||
return const [
|
||||
Runtime.none,
|
||||
Runtime.jsshell,
|
||||
Runtime.d8,
|
||||
Runtime.chrome,
|
||||
Runtime.firefox,
|
||||
|
|
|
@ -601,10 +601,11 @@ class Dart2WasmCompilerConfiguration extends CompilerConfiguration {
|
|||
CommandArtifact? artifact) {
|
||||
final filename = artifact!.filename;
|
||||
final args = testFile.dartOptions;
|
||||
final isD8 = runtimeConfiguration is D8RuntimeConfiguration;
|
||||
return [
|
||||
'--turboshaft-wasm',
|
||||
if (isD8) '--turboshaft-wasm',
|
||||
'pkg/dart2wasm/bin/run_wasm.js',
|
||||
'--',
|
||||
if (isD8) '--',
|
||||
'${filename.substring(0, filename.lastIndexOf('.'))}.mjs',
|
||||
filename,
|
||||
...testFile.sharedObjects
|
||||
|
|
|
@ -450,13 +450,13 @@
|
|||
"timeout": 240
|
||||
}
|
||||
},
|
||||
"dart2wasm-(linux|mac|win)-(d8|chrome|firefox)": {
|
||||
"dart2wasm-(linux|mac|win)-(d8|jsshell|chrome|firefox)": {
|
||||
"options": {
|
||||
"host-checked": true,
|
||||
"timeout": 240
|
||||
}
|
||||
},
|
||||
"dart2wasm-(linux|mac|win)-optimized-(d8|chrome|firefox)": {
|
||||
"dart2wasm-(linux|mac|win)-optimized-(d8|jsshell|chrome|firefox)": {
|
||||
"options": {
|
||||
"dart2wasm-options": [
|
||||
"-O"
|
||||
|
@ -465,7 +465,7 @@
|
|||
"timeout": 240
|
||||
}
|
||||
},
|
||||
"dart2wasm-(linux|mac|win)-jscm-(d8|chrome|firefox)": {
|
||||
"dart2wasm-(linux|mac|win)-jscm-(d8|jsshell|chrome|firefox)": {
|
||||
"options": {
|
||||
"dart2wasm-options": [
|
||||
"--js-compatibility"
|
||||
|
|
|
@ -7,11 +7,10 @@ JSDIR=${0%/*}/../../../third_party/firefox_jsshell
|
|||
|
||||
case $OSTYPE in
|
||||
*[Dd]arwin*)
|
||||
exec $JSDIR/mac/jsshell/js "$@"
|
||||
exec $JSDIR/js "$@"
|
||||
;;
|
||||
*[Ll]inux*)
|
||||
LD_LIBRARY_PATH=$JSDIR/linux/jsshell/ \
|
||||
exec $JSDIR/linux/jsshell/js "$@"
|
||||
exec $JSDIR/js "$@"
|
||||
;;
|
||||
*)
|
||||
echo No jsshell binary for $(uname) >2
|
||||
|
|
Loading…
Reference in a new issue