Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 6fb2f94

Browse files
authored
web: improve engine dev cycle on Windows (#25812)
* felt.bat: simple incremental felt for Windows
1 parent 2071b03 commit 6fb2f94

File tree

4 files changed

+74
-30
lines changed

4 files changed

+74
-30
lines changed

lib/web_ui/dev/felt.bat

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
:: felt: a command-line utility for Windows for building and testing
2+
:: Flutter web engine.
3+
:: FELT stands for Flutter Engine Local Tester.
4+
5+
@ECHO OFF
6+
SETLOCAL
7+
8+
:: Make sure gclient and ninja exist. Otherwise felt won't work.
9+
FOR /F "tokens=1-2 delims=:" %%a in ('where gclient') DO SET GCLIENT_PATH=%%b
10+
IF %GCLIENT_PATH%==[] (ECHO "ERROR: gclient is not in your PATH")
11+
12+
FOR /F "tokens=1-2 delims=:" %%a in ('where ninja') DO SET NINJA_PATH=%%b
13+
IF %NINJA_PATH%==[] (ECHO "ERROR: ninja is not in your PATH")
14+
15+
:: Starting from this script's path, walk up to engine source directory.
16+
SET SCRIPT_DIR=%~dp0
17+
FOR %%a IN ("%SCRIPT_DIR:~0,-1%") DO SET TMP=%%~dpa
18+
FOR %%a IN ("%TMP:~0,-1%") DO SET TMP=%%~dpa
19+
FOR %%a IN ("%TMP:~0,-1%") DO SET TMP=%%~dpa
20+
FOR %%a IN ("%TMP:~0,-1%") DO SET ENGINE_SRC_DIR=%%~dpa
21+
22+
SET ENGINE_SRC_DIR=%ENGINE_SRC_DIR:~0,-1%
23+
SET OUT_DIR=%ENGINE_SRC_DIR%\out
24+
SET HOST_DEBUG_UNOPT_DIR=%OUT_DIR%\host_debug_unopt
25+
SET DART_SDK_DIR=%HOST_DEBUG_UNOPT_DIR%\dart-sdk
26+
SET DART_BIN=%DART_SDK_DIR%\bin\dart
27+
SET PUB_BIN=%DART_SDK_DIR%\bin\pub
28+
SET FLUTTER_DIR=%ENGINE_SRC_DIR%\flutter
29+
SET WEB_UI_DIR=%FLUTTER_DIR%\lib\web_ui
30+
SET DEV_DIR=%WEB_UI_DIR%\dev
31+
SET FELT_PATH=%DEV_DIR%\felt.dart
32+
SET DART_TOOL_DIR=%WEB_UI_DIR%\.dart_tool
33+
SET SNAPSHOT_PATH=%DART_TOOL_DIR%\felt.snapshot
34+
35+
SET needsHostDebugUnoptRebuild=0
36+
for %%x in (%*) do (
37+
if ["%%~x"]==["--clean"] (
38+
ECHO Clean rebuild requested
39+
SET needsHostDebugUnoptRebuild=1
40+
)
41+
)
42+
43+
IF NOT EXIST %OUT_DIR% (SET needsHostDebugUnoptRebuild=1)
44+
IF NOT EXIST %HOST_DEBUG_UNOPT_DIR% (SET needsHostDebugUnoptRebuild=1)
45+
46+
IF %needsHostDebugUnoptRebuild%==1 (
47+
ECHO Building host_debug_unopt
48+
:: Delete old snapshot, if any, because the new Dart SDK may invalidate it.
49+
IF EXIST "%SNAPSHOT_PATH%" (
50+
del %SNAPSHOT_PATH%
51+
)
52+
CALL gclient sync -D
53+
CALL python %GN% --unoptimized --full-dart-sdk
54+
CALL ninja -C %HOST_DEBUG_UNOPT_DIR%)
55+
56+
cd %WEB_UI_DIR%
57+
IF NOT EXIST "%SNAPSHOT_PATH%" (
58+
ECHO Precompiling felt snapshot
59+
CALL %PUB_BIN% get
60+
%DART_BIN% --snapshot="%SNAPSHOT_PATH%" --packages="%WEB_UI_DIR%\.packages" %FELT_PATH%
61+
)
62+
63+
IF %1==test (
64+
%DART_SDK_DIR%\bin\dart --packages="%WEB_UI_DIR%\.packages" "%SNAPSHOT_PATH%" %* --browser=chrome
65+
) ELSE (
66+
%DART_SDK_DIR%\bin\dart --packages="%WEB_UI_DIR%\.packages" "%SNAPSHOT_PATH%" %*
67+
)
68+
69+
EXIT /B %ERRORLEVEL%

lib/web_ui/dev/felt.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ CommandRunner runner = CommandRunner<bool>(
2525
..addCommand(TestCommand())
2626
..addCommand(BuildCommand());
2727

28-
void main(List<String> args) async {
28+
void main(List<String> rawArgs) async {
29+
// Remove --clean from the list as that's processed by the wrapper script.
30+
final List<String> args = rawArgs.where((arg) => arg != '--clean').toList();
31+
2932
if (args.isEmpty) {
3033
// The felt tool was invoked with no arguments. Print usage.
3134
runner.printUsage();

lib/web_ui/dev/felt_windows.bat

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
:: TODO(yjbanov): migrate LUCI to felt.bat and delete this file.
12
:: felt_windows: a command-line utility for Windows for building and testing
23
:: Flutter web engine.
34
:: FELT stands for Flutter Engine Local Tester.
@@ -38,13 +39,6 @@ SET SNAPSHOT_PATH="%DART_TOOL_DIR%felt.snapshot"
3839
CD %FLUTTER_DIR%
3940
FOR /F "tokens=1 delims=:" %%a in ('git rev-parse HEAD') DO SET REVISION=%%a
4041

41-
:: Uncomment for debugging the values.
42-
:: ECHO "FELT_DIR:%FELT_DIR%"
43-
:: ECHO "WEB_UI_DIR:%WEB_UI_DIR%"
44-
:: ECHO "FLUTTER_DIR:%FLUTTER_DIR%"
45-
:: ECHO "ENGINE_SRC_DIR:%ENGINE_SRC_DIR%"
46-
:: ECHO "REVISION:%REVISION%"
47-
4842
SET orTempValue=1
4943
IF NOT EXIST %OUT_DIR% (SET orTempValue=0)
5044
IF NOT EXIST %HOST_DEBUG_UNOPT_DIR% (SET orTempValue=0)

lib/web_ui/dev/test_runner.dart

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,6 @@ class TestCommand extends Command<bool> with ArgUtils {
294294
Future<bool> runUnitTests() async {
295295
_copyTestFontsIntoWebUi();
296296
await _buildHostPage();
297-
if (io.Platform.isWindows) {
298-
// On Dart 2.7 or greater, it gives an error for not
299-
// recognized "pub" version and asks for "pub" get.
300-
// See: https://github.com/dart-lang/sdk/issues/39738
301-
await _runPubGet();
302-
}
303-
304297
await _prepare();
305298
await _buildTargets();
306299

@@ -636,21 +629,6 @@ class TestCommand extends Command<bool> with ArgUtils {
636629
}
637630
}
638631

639-
Future<void> _runPubGet() async {
640-
final int exitCode = await runProcess(
641-
environment.pubExecutable,
642-
<String>[
643-
'get',
644-
],
645-
workingDirectory: environment.webUiRootDir.path,
646-
);
647-
648-
if (exitCode != 0) {
649-
throw ToolException(
650-
'Failed to run pub get. Exited with exit code $exitCode');
651-
}
652-
}
653-
654632
Future<void> _buildHostPage() async {
655633
final String hostDartPath = path.join('lib', 'static', 'host.dart');
656634
final io.File hostDartFile = io.File(path.join(

0 commit comments

Comments
 (0)