Skip to content

Commit

Permalink
iOS JIT support and enhancements for scenarios app (#10820)
Browse files Browse the repository at this point in the history
* Make the scripts runnable from any directory

* Add JIT script for iOS
  • Loading branch information
dnfield authored Aug 12, 2019
1 parent d3be628 commit 79c5012
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 15 deletions.
4 changes: 2 additions & 2 deletions testing/scenario_app/assemble_apk.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

./compile_android_aot.sh $1 $2
"${BASH_SOURCE%/*}/compile_android_aot.sh" $1 $2

pushd android
pushd "${BASH_SOURCE%/*}/android"
./gradlew assembleDebug --no-daemon
popd
12 changes: 6 additions & 6 deletions testing/scenario_app/compile_android_aot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fi

echo "Using dart from $HOST_TOOLS, gen_snapshot from $DEVICE_TOOLS."

OUTDIR="build/android"
OUTDIR="${BASH_SOURCE%/*}/build/android"

echo "Creating $OUTDIR..."

Expand All @@ -35,15 +35,15 @@ echo "Compiling kernel..."
--sdk-root "$HOST_TOOLS/flutter_patched_sdk" \
--aot --tfa --target=flutter \
--output-dill "$OUTDIR/app.dill" \
lib/main.dart
"${BASH_SOURCE%/*}/lib/main.dart"

echo "Compiling ELF Shared Library..."

"$DEVICE_TOOLS/gen_snapshot" --deterministic --snapshot_kind=app-aot-elf --elf="$OUTDIR/libapp.so" --strip "$OUTDIR/app.dill"

mkdir -p "android/app/src/main/jniLibs/arm64-v8a"
mkdir -p "android/app/libs"
cp "$OUTDIR/libapp.so" "android/app/src/main/jniLibs/arm64-v8a/"
cp "$DEVICE_TOOLS/../flutter.jar" "android/app/libs/"
mkdir -p "${BASH_SOURCE%/*}/android/app/src/main/jniLibs/arm64-v8a"
mkdir -p "${BASH_SOURCE%/*}/android/app/libs"
cp "$OUTDIR/libapp.so" "${BASH_SOURCE%/*}/android/app/src/main/jniLibs/arm64-v8a/"
cp "$DEVICE_TOOLS/../flutter.jar" "${BASH_SOURCE%/*}/android/app/libs/"

echo "Created $OUTDIR/libapp.so."
14 changes: 7 additions & 7 deletions testing/scenario_app/compile_ios_aot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fi

echo "Using dart from $HOST_TOOLS, gen_snapshot from $DEVICE_TOOLS."

OUTDIR="build/ios"
OUTDIR="${BASH_SOURCE%/*}/build/ios"

echo "Creating $OUTDIR..."

Expand All @@ -36,7 +36,7 @@ echo "Compiling kernel..."
--sdk-root "$HOST_TOOLS/flutter_patched_sdk" \
--aot --tfa --target=flutter \
--output-dill "$OUTDIR/app.dill" \
lib/main.dart
"${BASH_SOURCE%/*}/lib/main.dart"

echo "Compiling AOT Assembly..."

Expand Down Expand Up @@ -65,12 +65,12 @@ clang -arch arm64 \

strip "$OUTDIR/App.framework/App"

cp ios/AppFrameworkInfo.plist "$OUTDIR/App.framework/Info.plist"
cp "${BASH_SOURCE%/*}/ios/AppFrameworkInfo.plist" "$OUTDIR/App.framework/Info.plist"

echo "Created $OUTDIR/App.framework/App."

rm -rf ios/Scenarios/App.framework
rm -rf ios/Scenarios/Flutter.framework
cp -R "$OUTDIR/App.framework" ios/Scenarios
cp -R "$DEVICE_TOOLS/../Flutter.framework" ios/Scenarios
rm -rf "${BASH_SOURCE%/*}/ios/Scenarios/App.framework"
rm -rf "${BASH_SOURCE%/*}/ios/Scenarios/Flutter.framework"
cp -R "$OUTDIR/App.framework" "${BASH_SOURCE%/*}/ios/Scenarios"
cp -R "$DEVICE_TOOLS/../Flutter.framework" "${BASH_SOURCE%/*}/ios/Scenarios"

81 changes: 81 additions & 0 deletions testing/scenario_app/compile_ios_jit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

#TODO(dnfield): Get rid of this script and instead use proper build rules

set -e

HOST_TOOLS=$1
DEVICE_TOOLS=$2

if [[ ! -d "$HOST_TOOLS" ]]; then
echo "Must specify the host out directory containing dart."
exit 1
fi

if [[ ! -d "$DEVICE_TOOLS" ]]; then
echo "Must specify the device out directory containing gen_snapshot."
exit 1
fi

echo "Using dart from $HOST_TOOLS, gen_snapshot from $DEVICE_TOOLS."

OUTDIR="${BASH_SOURCE%/*}/build/ios"

echo "Creating $OUTDIR..."

mkdir -p "$OUTDIR"
mkdir -p "$OUTDIR/App.framework/flutter_assets"

echo "Compiling to kernel..."

"$HOST_TOOLS/dart" \
"$HOST_TOOLS/gen/frontend_server.dart.snapshot" \
--sdk-root "$HOST_TOOLS/flutter_patched_sdk" \
--strong --target=flutter \
--no-link-platform \
--output-dill "$OUTDIR/App.framework/flutter_assets/kernel_blob.bin" \
"${BASH_SOURCE%/*}/lib/main.dart"

echo "Compiling JIT Snapshot..."

"$DEVICE_TOOLS/gen_snapshot" --deterministic \
--enable-asserts \
--causal_async_stacks \
--isolate_snapshot_instructions="$OUTDIR/isolate_snapshot_instr" \
--snapshot_kind=app-jit \
--load_vm_snapshot_data="$DEVICE_TOOLS/../gen/flutter/lib/snapshot/vm_isolate_snapshot.bin" \
--load_isolate_snapshot_data="$DEVICE_TOOLS/../gen/flutter/lib/snapshot/isolate_snapshot.bin" \
--isolate_snapshot_data="$OUTDIR/App.framework/flutter_assets/isolate_snapshot_data" \
--isolate_snapshot_instructions="$OUTDIR/App.framework/flutter_assets/isolate_snapshot_instr" \
"$OUTDIR/App.framework/flutter_assets/kernel_blob.bin"

cp "$DEVICE_TOOLS/../gen/flutter/lib/snapshot/vm_isolate_snapshot.bin" "$OUTDIR/App.framework/flutter_assets/vm_snapshot_data"

SYSROOT=$(xcrun --sdk iphonesimulator --show-sdk-path)
echo "Using $SYSROOT as sysroot."

echo "Creating stub App using $SYSROOT..."

echo "static const int Moo = 88;" | xcrun clang -x c \
-arch x86_64 \
-isysroot "$SYSROOT" \
-miphoneos-version-min=8.0 \
-dynamiclib \
-Xlinker -rpath -Xlinker '@executable_path/Frameworks' \
-Xlinker -rpath -Xlinker '@loader_path/Frameworks' \
-install_name '@rpath/App.framework/App' \
-o "$OUTDIR/App.framework/App" -

strip "$OUTDIR/App.framework/App"

cp "${BASH_SOURCE%/*}/ios/AppFrameworkInfo.plist" "$OUTDIR/App.framework/Info.plist"
echo "Created $OUTDIR/App.framework/App."

rm -rf "${BASH_SOURCE%/*}/ios/Scenarios/App.framework"
rm -rf "${BASH_SOURCE%/*}/ios/Scenarios/Flutter.framework"
cp -R "$OUTDIR/App.framework" "${BASH_SOURCE%/*}/ios/Scenarios"
cp -R "$DEVICE_TOOLS/../Flutter.framework" "${BASH_SOURCE%/*}/ios/Scenarios"

0 comments on commit 79c5012

Please sign in to comment.