Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 79c5012

Browse files
authored
iOS JIT support and enhancements for scenarios app (#10820)
* Make the scripts runnable from any directory * Add JIT script for iOS
1 parent d3be628 commit 79c5012

File tree

4 files changed

+96
-15
lines changed

4 files changed

+96
-15
lines changed

testing/scenario_app/assemble_apk.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

3-
./compile_android_aot.sh $1 $2
3+
"${BASH_SOURCE%/*}/compile_android_aot.sh" $1 $2
44

5-
pushd android
5+
pushd "${BASH_SOURCE%/*}/android"
66
./gradlew assembleDebug --no-daemon
77
popd

testing/scenario_app/compile_android_aot.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fi
2222

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

25-
OUTDIR="build/android"
25+
OUTDIR="${BASH_SOURCE%/*}/build/android"
2626

2727
echo "Creating $OUTDIR..."
2828

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

4040
echo "Compiling ELF Shared Library..."
4141

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

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

4949
echo "Created $OUTDIR/libapp.so."

testing/scenario_app/compile_ios_aot.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fi
2222

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

25-
OUTDIR="build/ios"
25+
OUTDIR="${BASH_SOURCE%/*}/build/ios"
2626

2727
echo "Creating $OUTDIR..."
2828

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

4141
echo "Compiling AOT Assembly..."
4242

@@ -65,12 +65,12 @@ clang -arch arm64 \
6565

6666
strip "$OUTDIR/App.framework/App"
6767

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

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

72-
rm -rf ios/Scenarios/App.framework
73-
rm -rf ios/Scenarios/Flutter.framework
74-
cp -R "$OUTDIR/App.framework" ios/Scenarios
75-
cp -R "$DEVICE_TOOLS/../Flutter.framework" ios/Scenarios
72+
rm -rf "${BASH_SOURCE%/*}/ios/Scenarios/App.framework"
73+
rm -rf "${BASH_SOURCE%/*}/ios/Scenarios/Flutter.framework"
74+
cp -R "$OUTDIR/App.framework" "${BASH_SOURCE%/*}/ios/Scenarios"
75+
cp -R "$DEVICE_TOOLS/../Flutter.framework" "${BASH_SOURCE%/*}/ios/Scenarios"
7676

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/bin/bash
2+
# Copyright 2013 The Flutter Authors. All rights reserved.
3+
# Use of this source code is governed by a BSD-style license that can be
4+
# found in the LICENSE file.
5+
6+
#TODO(dnfield): Get rid of this script and instead use proper build rules
7+
8+
set -e
9+
10+
HOST_TOOLS=$1
11+
DEVICE_TOOLS=$2
12+
13+
if [[ ! -d "$HOST_TOOLS" ]]; then
14+
echo "Must specify the host out directory containing dart."
15+
exit 1
16+
fi
17+
18+
if [[ ! -d "$DEVICE_TOOLS" ]]; then
19+
echo "Must specify the device out directory containing gen_snapshot."
20+
exit 1
21+
fi
22+
23+
echo "Using dart from $HOST_TOOLS, gen_snapshot from $DEVICE_TOOLS."
24+
25+
OUTDIR="${BASH_SOURCE%/*}/build/ios"
26+
27+
echo "Creating $OUTDIR..."
28+
29+
mkdir -p "$OUTDIR"
30+
mkdir -p "$OUTDIR/App.framework/flutter_assets"
31+
32+
echo "Compiling to kernel..."
33+
34+
"$HOST_TOOLS/dart" \
35+
"$HOST_TOOLS/gen/frontend_server.dart.snapshot" \
36+
--sdk-root "$HOST_TOOLS/flutter_patched_sdk" \
37+
--strong --target=flutter \
38+
--no-link-platform \
39+
--output-dill "$OUTDIR/App.framework/flutter_assets/kernel_blob.bin" \
40+
"${BASH_SOURCE%/*}/lib/main.dart"
41+
42+
echo "Compiling JIT Snapshot..."
43+
44+
"$DEVICE_TOOLS/gen_snapshot" --deterministic \
45+
--enable-asserts \
46+
--causal_async_stacks \
47+
--isolate_snapshot_instructions="$OUTDIR/isolate_snapshot_instr" \
48+
--snapshot_kind=app-jit \
49+
--load_vm_snapshot_data="$DEVICE_TOOLS/../gen/flutter/lib/snapshot/vm_isolate_snapshot.bin" \
50+
--load_isolate_snapshot_data="$DEVICE_TOOLS/../gen/flutter/lib/snapshot/isolate_snapshot.bin" \
51+
--isolate_snapshot_data="$OUTDIR/App.framework/flutter_assets/isolate_snapshot_data" \
52+
--isolate_snapshot_instructions="$OUTDIR/App.framework/flutter_assets/isolate_snapshot_instr" \
53+
"$OUTDIR/App.framework/flutter_assets/kernel_blob.bin"
54+
55+
cp "$DEVICE_TOOLS/../gen/flutter/lib/snapshot/vm_isolate_snapshot.bin" "$OUTDIR/App.framework/flutter_assets/vm_snapshot_data"
56+
57+
SYSROOT=$(xcrun --sdk iphonesimulator --show-sdk-path)
58+
echo "Using $SYSROOT as sysroot."
59+
60+
echo "Creating stub App using $SYSROOT..."
61+
62+
echo "static const int Moo = 88;" | xcrun clang -x c \
63+
-arch x86_64 \
64+
-isysroot "$SYSROOT" \
65+
-miphoneos-version-min=8.0 \
66+
-dynamiclib \
67+
-Xlinker -rpath -Xlinker '@executable_path/Frameworks' \
68+
-Xlinker -rpath -Xlinker '@loader_path/Frameworks' \
69+
-install_name '@rpath/App.framework/App' \
70+
-o "$OUTDIR/App.framework/App" -
71+
72+
strip "$OUTDIR/App.framework/App"
73+
74+
cp "${BASH_SOURCE%/*}/ios/AppFrameworkInfo.plist" "$OUTDIR/App.framework/Info.plist"
75+
echo "Created $OUTDIR/App.framework/App."
76+
77+
rm -rf "${BASH_SOURCE%/*}/ios/Scenarios/App.framework"
78+
rm -rf "${BASH_SOURCE%/*}/ios/Scenarios/Flutter.framework"
79+
cp -R "$OUTDIR/App.framework" "${BASH_SOURCE%/*}/ios/Scenarios"
80+
cp -R "$DEVICE_TOOLS/../Flutter.framework" "${BASH_SOURCE%/*}/ios/Scenarios"
81+

0 commit comments

Comments
 (0)