Skip to content

Commit 8f621ad

Browse files
authored
[web] Environment variable to disable felt snapshot (flutter#13187)
1 parent 85aef6c commit 8f621ad

3 files changed

Lines changed: 45 additions & 14 deletions

File tree

lib/web_ui/dev/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,18 @@ repo. Screenshot tests are compared with the golden files at that revision.
5050
When making engine changes that affect screenshots, first submit a PR to
5151
flutter/goldens updating the screenshots. Then update this file pointing to
5252
the new revision.
53+
54+
## Developing the `felt` tool
55+
If you are making changes in the `felt` tool itself, you need to be aware of Dart snapshots. We create a Dart snapshot of the `felt` tool to make the startup faster.
56+
57+
To make sure you are running the `felt` tool with your changes included, you would need to stop using the snapshot. This can be achived through the environment variable `FELT_USE_SNAPSHOT`:
58+
59+
```
60+
FELT_USE_SNAPSHOT=false felt <command>
61+
```
62+
or
63+
```
64+
FELT_USE_SNAPSHOT=0 felt <command>
65+
```
66+
67+
_**Note**: if `FELT_USE_SNAPSHOT` is omitted or has any value other than "false" or "0", the snapshot mode will be enabled._

lib/web_ui/dev/common.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ class _LinuxBinding implements PlatformBinding {
5858

5959
class _MacBinding implements PlatformBinding {
6060
@override
61-
int getChromeBuild(YamlMap browserLock) => browserLock['Mac'];
61+
int getChromeBuild(YamlMap browserLock) {
62+
final YamlMap chromeMap = browserLock['chrome'];
63+
return chromeMap['Mac'];
64+
}
6265

6366
@override
6467
String getChromeDownloadUrl(String version) =>

lib/web_ui/dev/felt

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,37 @@ then
4444
ninja -C $HOST_DEBUG_UNOPT_DIR
4545
fi
4646

47-
# Invalidate cache if:
48-
# * SNAPSHOT_PATH is not a file, or
49-
# * STAMP_PATH is not a file with nonzero size, or
50-
# * Contents of STAMP_PATH is not our local git HEAD revision, or
51-
# * pubspec.yaml last modified after pubspec.lock
52-
#
53-
# To force invalidate the cache run `felt clean` or `rm .dart_tool/felt.shapshot.stamp`
54-
if [[ ! -f $SNAPSHOT_PATH || ! -s "$STAMP_PATH" || "$(cat "$STAMP_PATH")" != "$REVISION" || "$WEB_UI_DIR/pubspec.yaml" -nt "$WEB_UI_DIR/pubspec.lock" ]]; then
55-
echo "Snapshotting the felt tool for faster subsequent runs."
47+
install_deps() {
5648
echo "Running \`pub get\` in 'engine/src/flutter/lib/web_ui'"
5749
(cd "$WEB_UI_DIR"; $DART_SDK_DIR/bin/pub get)
5850

5951
echo "Running \`pub get\` in 'engine/src/flutter/web_sdk/web_engine_tester'"
6052
(cd "$FLUTTER_DIR/web_sdk/web_engine_tester"; $DART_SDK_DIR/bin/pub get)
61-
mkdir -p $DART_TOOL_DIR
53+
}
6254

63-
"$DART_SDK_DIR/bin/dart" --snapshot="$SNAPSHOT_PATH" --packages="$WEB_UI_DIR/.packages" "$SCRIPT_PATH"
64-
echo "$REVISION" > "$STAMP_PATH"
55+
if [[ "$FELT_USE_SNAPSHOT" == "false" || "$FELT_USE_SNAPSHOT" == "0" ]]; then
56+
echo "[Snapshot mode: off]"
57+
# Running without snapshot means there is high likelyhood of local changes. In
58+
# that case, let's clear the snapshot to avoid any surprises.
59+
rm -f "$SNAPSHOT_PATH"
60+
rm -f "$STAMP_PATH"
61+
install_deps
62+
$DART_SDK_DIR/bin/dart "$DEV_DIR/felt.dart" $@
63+
else
64+
# Create a new snapshot if any of the following is true:
65+
# * SNAPSHOT_PATH is not a file, or
66+
# * STAMP_PATH is not a file with nonzero size, or
67+
# * Contents of STAMP_PATH is not our local git HEAD revision, or
68+
# * pubspec.yaml last modified after pubspec.lock
69+
if [[ ! -f $SNAPSHOT_PATH || ! -s "$STAMP_PATH" || "$(cat "$STAMP_PATH")" != "$REVISION" || "$WEB_UI_DIR/pubspec.yaml" -nt "$WEB_UI_DIR/pubspec.lock" ]]; then
70+
echo "[Snapshot mode: on] (creating a new snapshot)"
71+
install_deps
72+
mkdir -p $DART_TOOL_DIR
73+
74+
"$DART_SDK_DIR/bin/dart" --snapshot="$SNAPSHOT_PATH" --packages="$WEB_UI_DIR/.packages" "$SCRIPT_PATH"
75+
echo "$REVISION" > "$STAMP_PATH"
76+
fi
77+
78+
$DART_SDK_DIR/bin/dart --packages="$WEB_UI_DIR/.packages" "$SNAPSHOT_PATH" $@
6579
fi
6680

67-
$DART_SDK_DIR/bin/dart --packages="$WEB_UI_DIR/.packages" "$SNAPSHOT_PATH" $@

0 commit comments

Comments
 (0)