[vm] Add flags to gen_kernel script to support old ABIs
Bug: https://github.com/dart-lang/sdk/issues/36047
Change-Id: If6343223c03dc7f53d597294ef7a32c204236da6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97566
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
diff --git a/pkg/vm/tool/gen_kernel b/pkg/vm/tool/gen_kernel
index d0494c7..a968d05 100755
--- a/pkg/vm/tool/gen_kernel
+++ b/pkg/vm/tool/gen_kernel
@@ -8,6 +8,25 @@
set -e
+ABI_VERSION=""
+HAS_PLATFORM=""
+ARGV=()
+
+for arg in "$@"; do
+ case $arg in
+ --abi-version=*)
+ ABI_VERSION="$(echo "$arg" | sed "s|--abi-version=||")"
+ ;;
+ --platform*)
+ HAS_PLATFORM="TRUE"
+ ARGV+=("$arg")
+ ;;
+ *)
+ ARGV+=("$arg")
+ ;;
+ esac
+done
+
function follow_links() {
file="$1"
while [ -h "$file" ]; do
@@ -35,4 +54,18 @@
OUT_DIR="$SDK_DIR/out"
fi
-exec "$DART" $DART_VM_FLAGS "${SDK_DIR}/pkg/vm/bin/gen_kernel.dart" $@
+export DART_CONFIGURATION=${DART_CONFIGURATION:-ReleaseX64}
+BIN_DIR="$OUT_DIR/$DART_CONFIGURATION"
+
+if [ $ABI_VERSION ]; then
+ ABI_DIR="$BIN_DIR/dart-sdk/lib/_internal/abiversions/$ABI_VERSION"
+ PLATFORM=()
+ if [ -z $HAS_PLATFORM ]; then
+ PLATFORM+=("--platform" "$ABI_DIR/vm_platform_strong.dill")
+ fi
+ exec "$BIN_DIR/dart" $DART_VM_FLAGS --enable-interpreter \
+ "$ABI_DIR/gen_kernel_bytecode.dill" "${PLATFORM[@]}" "${ARGV[@]}"
+else
+ exec "$DART" $DART_VM_FLAGS \
+ "${SDK_DIR}/pkg/vm/bin/gen_kernel.dart" "${ARGV[@]}"
+fi