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 1 commit
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
Next Next commit
Remove felt snapshotting behavior.
  • Loading branch information
eyebrowsoffire committed Nov 15, 2022
commit 2e15ef9d4bf178cb8a26954bcdcea3ce9e0a3c21
31 changes: 2 additions & 29 deletions lib/web_ui/dev/felt
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,8 @@ fi

WEB_UI_DIR="${FLUTTER_DIR}/lib/web_ui"
DEV_DIR="${WEB_UI_DIR}/dev"
DART_TOOL_DIR="${WEB_UI_DIR}/.dart_tool"
DART_PATH="$DART_SDK_DIR/bin/dart"
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 [[ "$FELT_DEBUG" == "true" || "$FELT_DEBUG" == "1" ]]
then
Expand Down Expand Up @@ -133,28 +129,5 @@ then
set -e
fi

if [[ "$FELT_USE_SNAPSHOT" == "false" || "$FELT_USE_SNAPSHOT" == "0" ]]; then
echo "[Snapshot mode: off]"
# Running without snapshot means there is high likelihood of local changes. In
# that case, let's clear the snapshot to avoid any surprises.
rm -f "$SNAPSHOT_PATH"
rm -f "$STAMP_PATH"
install_deps
$DART_SDK_DIR/bin/dart $FELT_DEBUG_FLAGS "$DEV_DIR/felt.dart" $@
else
# Create a new snapshot if any of the following is true:
# * 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
if [[ ! -f $SNAPSHOT_PATH || ! -s "$STAMP_PATH" || "$(cat "$STAMP_PATH")" != "$REVISION" || "$WEB_UI_DIR/pubspec.yaml" -nt "$WEB_UI_DIR/pubspec.lock" ]]; then
echo "[Snapshot mode: on] (creating a new snapshot)"
install_deps
mkdir -p $DART_TOOL_DIR

"$DART_SDK_DIR/bin/dart" --snapshot="$SNAPSHOT_PATH" --packages="$WEB_UI_DIR/.dart_tool/package_config.json" "$SCRIPT_PATH"
echo "$REVISION" > "$STAMP_PATH"
fi

$DART_SDK_DIR/bin/dart $FELT_DEBUG_FLAGS --packages="$WEB_UI_DIR/.dart_tool/package_config.json" "$SNAPSHOT_PATH" $@
fi
install_deps
$DART_SDK_DIR/bin/dart $FELT_DEBUG_FLAGS --packages="$WEB_UI_DIR/.dart_tool/package_config.json" "$SCRIPT_PATH" $@
Copy link
Contributor

Choose a reason for hiding this comment

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

If we use dart run could we avoid install_deps and needing to pass the --packages directly? https://dart.dev/tools/dart-run

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like even with dart run I have to run install_deps first (it doesn't seem like dart run pulls dependencies. But I can change over to dart run to remove the need for the --packages stuff.

15 changes: 1 addition & 14 deletions lib/web_ui/dev/felt.bat
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ SET WEB_UI_DIR=%FLUTTER_DIR%\lib\web_ui
SET DEV_DIR=%WEB_UI_DIR%\dev
SET FELT_PATH=%DEV_DIR%\felt.dart
SET DART_TOOL_DIR=%WEB_UI_DIR%\.dart_tool
SET SNAPSHOT_PATH=%DART_TOOL_DIR%\felt.snapshot
SET SDK_PREBUILTS_DIR=%FLUTTER_DIR%\prebuilts
SET PREBUILT_TARGET=windows-x64
IF NOT DEFINED DART_SDK_DIR (
Expand All @@ -40,18 +39,6 @@ cd %WEB_UI_DIR%
:: We need to invoke pub get here before we actually invoke felt.
CALL %DART_BIN% pub get

IF FELT_USE_SNAPSHOT=="0" (
ECHO Invoking felt.dart without snapshot
SET FELT_TARGET=%FELT_PATH%
) ELSE (
IF NOT EXIST "%SNAPSHOT_PATH%" (
ECHO Precompiling felt snapshot
%DART_BIN% --snapshot="%SNAPSHOT_PATH%" --packages="%WEB_UI_DIR%\.dart_tool\package_config.json" %FELT_PATH%
)
SET FELT_TARGET=%SNAPSHOT_PATH%
ECHO Invoking felt snapshot
)

%DART_BIN% --packages="%WEB_UI_DIR%\.dart_tool\package_config.json" "%FELT_TARGET%" %*
%DART_BIN% --packages="%WEB_UI_DIR%\.dart_tool\package_config.json" "%FELT_PATH%" %*

EXIT /B %ERRORLEVEL%