dart-sdk/sdk/bin/run_dart2wasm_d8
Joshua Litt b493cdfc1b [dart2wasm] Add runner script to streamline running wasm in d8.
Change-Id: I0f891d28419d0df55f94e0229ff33e87b791e7d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273280
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-12-02 19:55:16 +00:00

41 lines
1.3 KiB
Bash
Executable file

#!/usr/bin/env bash
# Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
# 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.
# Run the output of dart2wasm on d8.
function follow_links() {
file="$1"
while [ -h "$file" ]; do
# On Mac OS, readlink -f doesn't work.
file="$(readlink "$file")"
done
echo "$file"
}
# Unlike $0, $BASH_SOURCE points to the absolute path of this file.
PROG_NAME="$(follow_links "$BASH_SOURCE")"
# Handle the case where dart-sdk/bin has been symlinked to.
PROG_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
SDK_DIR="$(cd "${PROG_DIR}/../.." ; pwd -P)"
D8_DIR="$(cd "${PROG_DIR}/../../third_party/d8" ; pwd -P)"
# Locate D8 executable. Only macos and linux are supported.
if [[ `uname` == 'Darwin' ]]; then
D8_EXEC="$D8_DIR/macos/d8"
else
D8_EXEC="$D8_DIR/linux/d8"
fi
# We allow extra d8 options to be passed in through an environment variable.
if [[ $D8_OPTIONS ]]; then
read -a OPTIONS <<< "$D8_OPTIONS"
EXTRA_D8_OPTIONS+=("${OPTIONS[@]}")
fi
exec "$D8_EXEC" --experimental-wasm-gc --experimental-wasm-stack-switching \
--experimental-wasm-type-reflection "${EXTRA_D8_OPTIONS[@]}" \
pkg/dart2wasm/bin/run_wasm.js -- "$@"