mirror of
https://github.com/flutter/flutter.git
synced 2026-02-06 03:39:05 +08:00
Also, defer to test package for throttling (this will require a test package update as well). Also, add a lot more instrumentation to --verbose mode for tests, and fix minor trivial things here and there, and add error handling in more places. Also, refactor how coverage works to be simpler and not use statics.
74 lines
2.5 KiB
Bash
Executable File
74 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# Copyright 2015 The Chromium 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
|
|
|
|
function follow_links() {
|
|
cd -P "${1%/*}"
|
|
file="$PWD/${1##*/}"
|
|
while [ -h "$file" ]; do
|
|
# On Mac OS, readlink -f doesn't work.
|
|
cd -P "${file%/*}"
|
|
file="$(readlink "$file")"
|
|
cd -P "${file%/*}"
|
|
file="$PWD/${file##*/}"
|
|
done
|
|
echo "$PWD/${file##*/}"
|
|
}
|
|
|
|
# Convert a filesystem path to a format usable by Dart's URI parser.
|
|
function path_uri() {
|
|
# Reduce multiple leading slashes to a single slash.
|
|
echo $1 | sed -E -e "s,^/+,/,"
|
|
}
|
|
|
|
PROG_NAME="$(path_uri $(follow_links "$BASH_SOURCE"))"
|
|
BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
|
|
export FLUTTER_ROOT="$(cd "${BIN_DIR}/.." ; pwd -P)"
|
|
|
|
FLUTTER_TOOLS_DIR="$FLUTTER_ROOT/packages/flutter_tools"
|
|
SNAPSHOT_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.snapshot"
|
|
STAMP_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.stamp"
|
|
SCRIPT_PATH="$FLUTTER_TOOLS_DIR/bin/flutter_tools.dart"
|
|
DART_SDK_PATH="$FLUTTER_ROOT/bin/cache/dart-sdk"
|
|
|
|
DART="$DART_SDK_PATH/bin/dart"
|
|
|
|
# To debug the tool, you can uncomment the following line to enable checked mode and set an observatory port:
|
|
# FLUTTER_TOOL_ARGS="--observe=65432 --checked"
|
|
|
|
(
|
|
if hash flock 2>/dev/null; then
|
|
flock 3 # ensures that we don't simultaneously update Dart in multiple parallel instances
|
|
# some platforms (e.g. Mac) don't have flock or any reliable alternative
|
|
fi
|
|
REVISION=`(cd "$FLUTTER_ROOT"; git rev-parse HEAD)`
|
|
if [ ! -f "$SNAPSHOT_PATH" ] || [ ! -s "$STAMP_PATH" ] || [ `cat "$STAMP_PATH"` != "$REVISION" ] || [ "$FLUTTER_TOOLS_DIR/pubspec.yaml" -nt "$FLUTTER_TOOLS_DIR/pubspec.lock" ]; then
|
|
mkdir -p "$FLUTTER_ROOT/bin/cache"
|
|
touch "$FLUTTER_ROOT/bin/cache/.dartignore"
|
|
"$FLUTTER_ROOT/bin/internal/update_dart_sdk.sh"
|
|
|
|
echo Building flutter tool...
|
|
FLUTTER_DIR="$FLUTTER_ROOT/packages/flutter"
|
|
(cd "$FLUTTER_TOOLS_DIR"; rm -f pubspec.lock; "../../bin/cache/dart-sdk/bin/pub" get --verbosity=error --no-packages-dir)
|
|
"$DART" --snapshot="$SNAPSHOT_PATH" --packages="$FLUTTER_TOOLS_DIR/.packages" "$SCRIPT_PATH"
|
|
echo $REVISION > "$STAMP_PATH"
|
|
fi
|
|
) 3< "$PROG_NAME"
|
|
|
|
set +e
|
|
"$DART" $FLUTTER_TOOL_ARGS "$SNAPSHOT_PATH" "$@"
|
|
|
|
# The VM exits with code 253 if the snapshot version is out-of-date.
|
|
# If it is, we need to snapshot it again.
|
|
EXIT_CODE=$?
|
|
if [ $EXIT_CODE != 253 ]; then
|
|
exit $EXIT_CODE
|
|
fi
|
|
|
|
set -e
|
|
"$DART" --snapshot="$SNAPSHOT_PATH" --packages="$FLUTTER_TOOLS_DIR/.packages" "$SCRIPT_PATH"
|
|
"$DART" $FLUTTER_TOOL_ARGS "$SNAPSHOT_PATH" "$@"
|