Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion testing/scenario_app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ compared against golden reside.

## Running for Android

The test is run on a x86 emulator. To run the test locally, you must create an emulator running API level 28, and set the following screen settings in the avd's `config.ini` file:
The test is run on a x86 emulator. To run the test locally, you must create an emulator running API level 28, using an x86_64 ABI, and set the following screen settings in the avd's `config.ini` file:

```
hw.lcd.density = 480
Expand Down
42 changes: 32 additions & 10 deletions testing/scenario_app/assemble_apk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,37 @@

set -e

pushd "${BASH_SOURCE%/*}/../../.."
./flutter/tools/gn --unopt
ninja -C out/host_debug_unopt sky_engine sky_services
popd
# Needed because if it is set, cd may print the path it changed to.
unset CDPATH

pushd "${BASH_SOURCE%/*}"
./compile_android_aot.sh "$1" "$2"
popd
# On Mac OS, readlink -f doesn't work, so follow_links traverses the path one
# link at a time, and then cds into the link destination and find out where it
# ends up.
#
# The function is enclosed in a subshell to avoid changing the working directory
# of the caller.
function follow_links() (
cd -P "$(dirname -- "$1")"
file="$PWD/$(basename -- "$1")"
while [[ -L "$file" ]]; do
cd -P "$(dirname -- "$file")"
file="$(readlink -- "$file")"
cd -P "$(dirname -- "$file")"
file="$PWD/$(basename -- "$file")"
done
echo "$file"
)

pushd "${BASH_SOURCE%/*}/android"
./gradlew assembleDebug --no-daemon
popd
SCRIPT_DIR=$(follow_links "$(dirname -- "${BASH_SOURCE[0]}")")
SRC_DIR="$(cd "$SCRIPT_DIR/../../.."; pwd -P)"
export ANDROID_HOME="$SRC_DIR/third_party/android_tools/sdk"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. this aligns with what the LUCI recipe does. It's good that it makes it consistent.


"$SRC_DIR/flutter/tools/gn" --unopt
autoninja -C "$SRC_DIR/out/host_debug_unopt" sky_engine sky_services

"$SCRIPT_DIR/compile_android_aot.sh" "$1" "$2"

(
cd "$SCRIPT_DIR/android"
./gradlew assembleDebug --no-daemon
)
53 changes: 34 additions & 19 deletions testing/scenario_app/build_and_run_android_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,44 @@

set -e

# Needed because if it is set, cd may print the path it changed to.
unset CDPATH

# On Mac OS, readlink -f doesn't work, so follow_links traverses the path one
# link at a time, and then cds into the link destination and find out where it
# ends up.
#
# The function is enclosed in a subshell to avoid changing the working directory
# of the caller.
function follow_links() (
cd -P "$(dirname -- "$1")"
file="$PWD/$(basename -- "$1")"
while [[ -h "$file" ]]; do
cd -P "$(dirname -- "$file")"
file="$(readlink -- "$file")"
cd -P "$(dirname -- "$file")"
file="$PWD/$(basename -- "$file")"
done
echo "$file"
)

SCRIPT_DIR=$(follow_links "$(dirname -- "${BASH_SOURCE[0]}")")
SRC_DIR="$(cd "$SCRIPT_DIR/../../.."; pwd -P)"
GN="$SRC_DIR/flutter/tools/gn"

FLUTTER_ENGINE=android_debug_unopt_x64
export ANDROID_HOME="$SRC_DIR/third_party/android_tools/sdk"

if [ $# -eq 1 ]; then
FLUTTER_ENGINE=$1
if [[ $# -eq 1 ]]; then
FLUTTER_ENGINE="$1"
fi

cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd

pushd ../../..

if [ ! -d "out/$FLUTTER_ENGINE" ]; then
echo "You must GN to generate out/$FLUTTER_ENGINE and its host engine."
echo "Example: "
echo " ./tools/gn --android --unoptimized --android-cpu x64 --runtime-mode debug"
echo " ./tools/gn --unoptimized --runtime-mode debug"
echo "to create out/android_debug_unopt_x64 and out/host_debug_unopt."
exit 1
if [[ ! -d "$SRC_DIR/out/$FLUTTER_ENGINE" ]]; then
"$GN" --android --unoptimized --android-cpu x64 --runtime-mode debug
"$GN" --unoptimized --runtime-mode debug
fi

autoninja -C out/$FLUTTER_ENGINE

popd

./compile_android_jit.sh ../../../out/host_debug_unopt ../../../out/$FLUTTER_ENGINE/clang_x64
autoninja -C "$SRC_DIR/out/$FLUTTER_ENGINE"

./run_android_tests.sh $FLUTTER_ENGINE
"$SCRIPT_DIR/compile_android_jit.sh" "$SRC_DIR/out/host_debug_unopt" "$SRC_DIR/out/$FLUTTER_ENGINE/clang_x64"
"$SCRIPT_DIR/run_android_tests.sh" "$FLUTTER_ENGINE"
54 changes: 34 additions & 20 deletions testing/scenario_app/build_and_run_ios_tests.sh
Original file line number Diff line number Diff line change
@@ -1,33 +1,47 @@
#!/bin/sh
#!/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.

set -e

# Needed because if it is set, cd may print the path it changed to.
unset CDPATH

# On Mac OS, readlink -f doesn't work, so follow_links traverses the path one
# link at a time, and then cds into the link destination and find out where it
# ends up.
#
# The function is enclosed in a subshell to avoid changing the working directory
# of the caller.
function follow_links() (
cd -P "$(dirname -- "$1")"
file="$PWD/$(basename -- "$1")"
while [[ -h "$file" ]]; do
cd -P "$(dirname -- "$file")"
file="$(readlink -- "$file")"
cd -P "$(dirname -- "$file")"
file="$PWD/$(basename -- "$file")"
done
echo "$file"
)

SCRIPT_DIR=$(follow_links "$(dirname -- "${BASH_SOURCE[0]}")")
SRC_DIR="$(cd "$SCRIPT_DIR/../../.."; pwd -P)"
GN="$SRC_DIR/flutter/tools/gn"

FLUTTER_ENGINE=ios_debug_sim_unopt

if [ $# -eq 1 ]; then
FLUTTER_ENGINE=$1
if [[ $# -eq 1 ]]; then
FLUTTER_ENGINE="$1"
fi

cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd

pushd ../../..

if [ ! -d "out/$FLUTTER_ENGINE" ]; then
echo "You must GN to generate out/$FLUTTER_ENGINE"
echo "Example: "
echo " ./flutter/tools/gn --ios --simulator --unoptimized"
echo " ./flutter/tools/gn --unoptimized"
echo "to create out/ios_debug_sim_unopt and out/host_debug_unopt."
exit 1
if [ ! -d "$SRC_DIR/out/$FLUTTER_ENGINE" ]; then
"$GN" --ios --simulator --unoptimized
"$GN" --unoptimized
fi

autoninja -C out/$FLUTTER_ENGINE

popd

./compile_ios_jit.sh ../../../out/host_debug_unopt ../../../out/$FLUTTER_ENGINE/clang_x64
autoninja -C "$SRC_DIR/out/$FLUTTER_ENGINE"

./run_ios_tests.sh $FLUTTER_ENGINE
"$SCRIPT_DIR/compile_ios_jit.sh" "$SRC_DIR/out/host_debug_unopt" "$SRC_DIR/out/$FLUTTER_ENGINE/clang_x64"
"$SCRIPT_DIR/run_ios_tests.sh" "$FLUTTER_ENGINE"
56 changes: 41 additions & 15 deletions testing/scenario_app/compile_android_aot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,57 @@

set -e

HOST_TOOLS=$1
DEVICE_TOOLS=$2
# Needed because if it is set, cd may print the path it changed to.
unset CDPATH

# On Mac OS, readlink -f doesn't work, so follow_links traverses the path one
# link at a time, and then cds into the link destination and find out where it
# ends up.
#
# The function is enclosed in a subshell to avoid changing the working directory
# of the caller.
function follow_links() (
cd -P "$(dirname -- "$1")"
file="$PWD/$(basename -- "$1")"
while [[ -h "$file" ]]; do
cd -P "$(dirname -- "$file")"
file="$(readlink -- "$file")"
cd -P "$(dirname -- "$file")"
file="$PWD/$(basename -- "$file")"
done
echo "$file"
)

SCRIPT_DIR=$(follow_links "$(dirname -- "${BASH_SOURCE[0]}")")

HOST_TOOLS="$1"
DEVICE_TOOLS="$2"

if [[ ! -d "$HOST_TOOLS" ]]; then
echo "Must specify the host out directory containing dart."
echo "Directory $HOST_TOOLS not found."
echo "First argument must specify the host out directory containing dart (e.g. out/host_debug_unopt)."
exit 1
fi

if [[ ! -d "$DEVICE_TOOLS" ]]; then
echo "Must specify the device out directory containing gen_snapshot."
echo "Directory $DEVICE_TOOLS not found."
ehco "Second argument must specify the device out directory containing gen_snapshot (e.g. out/android_debug_unopt_x64/clang_x64)."
exit 1
fi

PUB_VERSION=$($HOST_TOOLS/dart-sdk/bin/pub --version)
echo "Using Pub ${PUB_VERSION} from $HOST_TOOLS/dart-sdk/bin/pub"
PUB="$HOST_TOOLS/dart-sdk/bin/pub"
PUB_VERSION="$("$PUB" --version)"
echo "Using Pub ${PUB_VERSION} from $PUB"

$HOST_TOOLS/dart-sdk/bin/pub get
(cd "$SCRIPT_DIR"; "$PUB" get)

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

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

echo "Creating $OUTDIR..."

mkdir -p $OUTDIR
mkdir -p "$OUTDIR"

echo "Compiling kernel..."

Expand All @@ -40,15 +66,15 @@ echo "Compiling kernel..."
--sdk-root "$HOST_TOOLS/flutter_patched_sdk" \
--aot --tfa --target=flutter \
--output-dill "$OUTDIR/app.dill" \
"${BASH_SOURCE%/*}/lib/main.dart"
"$SCRIPT_DIR/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"
"$HOST_TOOLS/gen_snapshot" --deterministic --snapshot_kind=app-aot-elf --elf="$OUTDIR/libapp.so" --strip "$OUTDIR/app.dill"

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/"
mkdir -p "$SCRIPT_DIR/android/app/src/main/jniLibs/arm64-v8a"
mkdir -p "$SCRIPT_DIR/android/app/libs"
cp "$OUTDIR/libapp.so" "$SCRIPT_DIR/android/app/src/main/jniLibs/arm64-v8a/"
cp "$DEVICE_TOOLS/../flutter.jar" "$SCRIPT_DIR/android/app/libs/"

echo "Created $OUTDIR/libapp.so."
58 changes: 42 additions & 16 deletions testing/scenario_app/compile_android_jit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,59 @@

set -e

HOST_TOOLS=$1
DEVICE_TOOLS=$2
# Needed because if it is set, cd may print the path it changed to.
unset CDPATH

# On Mac OS, readlink -f doesn't work, so follow_links traverses the path one
# link at a time, and then cds into the link destination and find out where it
# ends up.
#
# The function is enclosed in a subshell to avoid changing the working directory
# of the caller.
function follow_links() (
cd -P "$(dirname -- "$1")"
file="$PWD/$(basename -- "$1")"
while [[ -h "$file" ]]; do
cd -P "$(dirname -- "$file")"
file="$(readlink -- "$file")"
cd -P "$(dirname -- "$file")"
file="$PWD/$(basename -- "$file")"
done
echo "$file"
)

SCRIPT_DIR=$(follow_links "$(dirname -- "${BASH_SOURCE[0]}")")

HOST_TOOLS="$1"
DEVICE_TOOLS="$2"

if [[ ! -d "$HOST_TOOLS" ]]; then
echo "Must specify the host out directory containing dart."
echo "Directory $HOST_TOOLS not found."
echo "First argument must specify the host out directory containing dart (e.g. host_debug_unopt)."
exit 1
fi

if [[ ! -d "$DEVICE_TOOLS" ]]; then
echo "Must specify the device out directory containing gen_snapshot."
echo "Directory $DEVICE_TOOLS not found."
ehco "Second argument must specify the device out directory containing gen_snapshot (e.g. android_debug_unopt_x64)."
exit 1
fi

PUB_VERSION=$($HOST_TOOLS/dart-sdk/bin/pub --version)
echo "Using Pub ${PUB_VERSION} from $HOST_TOOLS/dart-sdk/bin/pub"
PUB="$HOST_TOOLS/dart-sdk/bin/pub"
PUB_VERSION="$("$PUB" --version)"
echo "Using Pub $PUB_VERSION from $PUB"

$HOST_TOOLS/dart-sdk/bin/pub get
"$PUB" get

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

OUTDIR="${BASH_SOURCE%/*}/build/app"
FLUTTER_ASSETS_DIR=$OUTDIR/assets/flutter_assets
LIBS_DIR="${BASH_SOURCE%/*}/android/app/libs"
GEN_SNAPSHOT=$DEVICE_TOOLS/gen_snapshot
OUTDIR="$SCRIPT_DIR/build/app"
FLUTTER_ASSETS_DIR="$OUTDIR/assets/flutter_assets"
LIBS_DIR="$SCRIPT_DIR/android/app/libs"
GEN_SNAPSHOT="$DEVICE_TOOLS/gen_snapshot"

if [[ ! -f "$GEN_SNAPSHOT" ]]; then
GEN_SNAPSHOT=$DEVICE_TOOLS/gen_snapshot_host_targeting_host
GEN_SNAPSHOT="$DEVICE_TOOLS/gen_snapshot_host_targeting_host"
fi

if [[ ! -f "$GEN_SNAPSHOT" ]]; then
Expand All @@ -41,9 +67,9 @@ fi

echo "Creating directories..."

mkdir -p $OUTDIR
mkdir -p $FLUTTER_ASSETS_DIR
mkdir -p $LIBS_DIR
mkdir -p "$OUTDIR"
mkdir -p "$FLUTTER_ASSETS_DIR"
mkdir -p "$LIBS_DIR"
Comment on lines +70 to +72
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed these quotes before. Thanks for fixing!


echo "Compiling kernel..."

Expand All @@ -53,7 +79,7 @@ echo "Compiling kernel..."
--target=flutter \
--no-link-platform \
--output-dill "$FLUTTER_ASSETS_DIR/kernel_blob.bin" \
"${BASH_SOURCE%/*}/lib/main.dart"
"$SCRIPT_DIR/lib/main.dart"

echo "Compiling JIT Snapshot..."

Expand Down
Loading