Snapshot the felt tool for faster start-up (flutter/engine#13090)

This commit is contained in:
Yegor
2019-10-11 13:44:06 -07:00
committed by GitHub
parent 086fd6bae8
commit 16e74ede52

View File

@@ -30,6 +30,11 @@ OUT_DIR="${ENGINE_SRC_DIR}/out"
HOST_DEBUG_UNOPT_DIR="${ENGINE_SRC_DIR}/out/host_debug_unopt"
DART_SDK_DIR="${ENGINE_SRC_DIR}/out/host_debug_unopt/dart-sdk"
GN="${FLUTTER_DIR}/tools/gn"
DART_TOOL_DIR="${WEB_UI_DIR}/.dart_tool"
SNAPSHOT_PATH="${DART_TOOL_DIR}/felt.snapshot"
STAMP_PATH="${DART_TOOL_DIR}/felt.snapshot.stamp"
SCRIPT_PATH="${DEV_DIR}/felt.dart"
REVISION="$(cd "$FLUTTER_DIR"; git rev-parse HEAD)"
if [ ! -d "${OUT_DIR}" ] || [ ! -d "${HOST_DEBUG_UNOPT_DIR}" ]
then
@@ -39,10 +44,24 @@ then
ninja -C $HOST_DEBUG_UNOPT_DIR
fi
echo "Running \`pub get\` in 'engine/src/flutter/lib/web_ui'"
(cd "$WEB_UI_DIR"; $DART_SDK_DIR/bin/pub get)
# Invalidate cache if:
# * SNAPSHOT_PATH is not a file, or
# * STAMP_PATH is not a file with nonzero size, or
# * Contents of STAMP_PATH is not our local git HEAD revision, or
# * pubspec.yaml last modified after pubspec.lock
#
# To force invalidate the cache run `felt clean` or `rm .dart_tool/felt.shapshot.stamp`
if [[ ! -f $SNAPSHOT_PATH || ! -s "$STAMP_PATH" || "$(cat "$STAMP_PATH")" != "$REVISION" || "$WEB_UI_DIR/pubspec.yaml" -nt "$WEB_UI_DIR/pubspec.lock" ]]; then
echo "Snapshotting the felt tool for faster subsequent runs."
echo "Running \`pub get\` in 'engine/src/flutter/lib/web_ui'"
(cd "$WEB_UI_DIR"; $DART_SDK_DIR/bin/pub get)
echo "Running \`pub get\` in 'engine/src/flutter/web_sdk/web_engine_tester'"
(cd "$FLUTTER_DIR/web_sdk/web_engine_tester"; $DART_SDK_DIR/bin/pub get)
echo "Running \`pub get\` in 'engine/src/flutter/web_sdk/web_engine_tester'"
(cd "$FLUTTER_DIR/web_sdk/web_engine_tester"; $DART_SDK_DIR/bin/pub get)
mkdir -p $DART_TOOL_DIR
$DART_SDK_DIR/bin/dart "$DEV_DIR/felt.dart" $@
"$DART_SDK_DIR/bin/dart" --snapshot="$SNAPSHOT_PATH" --packages="$WEB_UI_DIR/.packages" "$SCRIPT_PATH"
echo "$REVISION" > "$STAMP_PATH"
fi
$DART_SDK_DIR/bin/dart --packages="$WEB_UI_DIR/.packages" "$SNAPSHOT_PATH" $@