diff --git a/lib/web_ui/dev/felt.bat b/lib/web_ui/dev/felt.bat new file mode 100644 index 0000000000000..c3c15cf12e832 --- /dev/null +++ b/lib/web_ui/dev/felt.bat @@ -0,0 +1,69 @@ +:: felt: a command-line utility for Windows for building and testing +:: Flutter web engine. +:: FELT stands for Flutter Engine Local Tester. + +@ECHO OFF +SETLOCAL + +:: Make sure gclient and ninja exist. Otherwise felt won't work. +FOR /F "tokens=1-2 delims=:" %%a in ('where gclient') DO SET GCLIENT_PATH=%%b +IF %GCLIENT_PATH%==[] (ECHO "ERROR: gclient is not in your PATH") + +FOR /F "tokens=1-2 delims=:" %%a in ('where ninja') DO SET NINJA_PATH=%%b +IF %NINJA_PATH%==[] (ECHO "ERROR: ninja is not in your PATH") + +:: Starting from this script's path, walk up to engine source directory. +SET SCRIPT_DIR=%~dp0 +FOR %%a IN ("%SCRIPT_DIR:~0,-1%") DO SET TMP=%%~dpa +FOR %%a IN ("%TMP:~0,-1%") DO SET TMP=%%~dpa +FOR %%a IN ("%TMP:~0,-1%") DO SET TMP=%%~dpa +FOR %%a IN ("%TMP:~0,-1%") DO SET ENGINE_SRC_DIR=%%~dpa + +SET ENGINE_SRC_DIR=%ENGINE_SRC_DIR:~0,-1% +SET OUT_DIR=%ENGINE_SRC_DIR%\out +SET HOST_DEBUG_UNOPT_DIR=%OUT_DIR%\host_debug_unopt +SET DART_SDK_DIR=%HOST_DEBUG_UNOPT_DIR%\dart-sdk +SET DART_BIN=%DART_SDK_DIR%\bin\dart +SET PUB_BIN=%DART_SDK_DIR%\bin\pub +SET FLUTTER_DIR=%ENGINE_SRC_DIR%\flutter +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 needsHostDebugUnoptRebuild=0 +for %%x in (%*) do ( + if ["%%~x"]==["--clean"] ( + ECHO Clean rebuild requested + SET needsHostDebugUnoptRebuild=1 + ) +) + +IF NOT EXIST %OUT_DIR% (SET needsHostDebugUnoptRebuild=1) +IF NOT EXIST %HOST_DEBUG_UNOPT_DIR% (SET needsHostDebugUnoptRebuild=1) + +IF %needsHostDebugUnoptRebuild%==1 ( + ECHO Building host_debug_unopt + :: Delete old snapshot, if any, because the new Dart SDK may invalidate it. + IF EXIST "%SNAPSHOT_PATH%" ( + del %SNAPSHOT_PATH% + ) + CALL gclient sync -D + CALL python %GN% --unoptimized --full-dart-sdk + CALL ninja -C %HOST_DEBUG_UNOPT_DIR%) + +cd %WEB_UI_DIR% +IF NOT EXIST "%SNAPSHOT_PATH%" ( + ECHO Precompiling felt snapshot + CALL %PUB_BIN% get + %DART_BIN% --snapshot="%SNAPSHOT_PATH%" --packages="%WEB_UI_DIR%\.packages" %FELT_PATH% +) + +IF %1==test ( + %DART_SDK_DIR%\bin\dart --packages="%WEB_UI_DIR%\.packages" "%SNAPSHOT_PATH%" %* --browser=chrome +) ELSE ( + %DART_SDK_DIR%\bin\dart --packages="%WEB_UI_DIR%\.packages" "%SNAPSHOT_PATH%" %* +) + +EXIT /B %ERRORLEVEL% diff --git a/lib/web_ui/dev/felt.dart b/lib/web_ui/dev/felt.dart index e0dff3219bce2..7d8688a5d0632 100644 --- a/lib/web_ui/dev/felt.dart +++ b/lib/web_ui/dev/felt.dart @@ -25,7 +25,10 @@ CommandRunner runner = CommandRunner( ..addCommand(TestCommand()) ..addCommand(BuildCommand()); -void main(List args) async { +void main(List rawArgs) async { + // Remove --clean from the list as that's processed by the wrapper script. + final List args = rawArgs.where((arg) => arg != '--clean').toList(); + if (args.isEmpty) { // The felt tool was invoked with no arguments. Print usage. runner.printUsage(); diff --git a/lib/web_ui/dev/felt_windows.bat b/lib/web_ui/dev/felt_windows.bat index 2ae0e2ab8b125..1b999e993d02d 100644 --- a/lib/web_ui/dev/felt_windows.bat +++ b/lib/web_ui/dev/felt_windows.bat @@ -1,3 +1,4 @@ +:: TODO(yjbanov): migrate LUCI to felt.bat and delete this file. :: felt_windows: a command-line utility for Windows for building and testing :: Flutter web engine. :: FELT stands for Flutter Engine Local Tester. @@ -38,13 +39,6 @@ SET SNAPSHOT_PATH="%DART_TOOL_DIR%felt.snapshot" CD %FLUTTER_DIR% FOR /F "tokens=1 delims=:" %%a in ('git rev-parse HEAD') DO SET REVISION=%%a -:: Uncomment for debugging the values. -:: ECHO "FELT_DIR:%FELT_DIR%" -:: ECHO "WEB_UI_DIR:%WEB_UI_DIR%" -:: ECHO "FLUTTER_DIR:%FLUTTER_DIR%" -:: ECHO "ENGINE_SRC_DIR:%ENGINE_SRC_DIR%" -:: ECHO "REVISION:%REVISION%" - SET orTempValue=1 IF NOT EXIST %OUT_DIR% (SET orTempValue=0) IF NOT EXIST %HOST_DEBUG_UNOPT_DIR% (SET orTempValue=0) diff --git a/lib/web_ui/dev/test_runner.dart b/lib/web_ui/dev/test_runner.dart index d164f29c37b21..e56f400811c9b 100644 --- a/lib/web_ui/dev/test_runner.dart +++ b/lib/web_ui/dev/test_runner.dart @@ -294,13 +294,6 @@ class TestCommand extends Command with ArgUtils { Future runUnitTests() async { _copyTestFontsIntoWebUi(); await _buildHostPage(); - if (io.Platform.isWindows) { - // On Dart 2.7 or greater, it gives an error for not - // recognized "pub" version and asks for "pub" get. - // See: https://github.com/dart-lang/sdk/issues/39738 - await _runPubGet(); - } - await _prepare(); await _buildTargets(); @@ -636,21 +629,6 @@ class TestCommand extends Command with ArgUtils { } } - Future _runPubGet() async { - final int exitCode = await runProcess( - environment.pubExecutable, - [ - 'get', - ], - workingDirectory: environment.webUiRootDir.path, - ); - - if (exitCode != 0) { - throw ToolException( - 'Failed to run pub get. Exited with exit code $exitCode'); - } - } - Future _buildHostPage() async { final String hostDartPath = path.join('lib', 'static', 'host.dart'); final io.File hostDartFile = io.File(path.join(