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 6 commits
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
67 changes: 67 additions & 0 deletions lib/web_ui/dev/analyze.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';

import 'package:args/command_runner.dart';

import 'environment.dart';
import 'pipeline.dart';
import 'utils.dart';

class AnalyzeCommand extends Command<bool> with ArgUtils<bool> {
@override
String get name => 'analyze';

@override
String get description => 'Analyze the Flutter web engine.';

@override
FutureOr<bool> run() async {
final Pipeline buildPipeline = Pipeline(steps: <PipelineStep>[
PubGetStep(),
AnalyzeStep(),
]);
await buildPipeline.run();
return true;
}
}

/// Runs `dart pub get`.
class PubGetStep extends ProcessStep {
@override
String get description => 'pub get';

@override
bool get isSafeToInterrupt => true;

@override
Future<ProcessManager> createProcess() {
print('Running `dart pub get`...');
return startProcess(
environment.dartExecutable,
<String>['pub', 'get'],
workingDirectory: environment.webUiRootDir.path,
);
}
}

/// Runs `dart analyze --fatal-infos`.
class AnalyzeStep extends ProcessStep {
@override
String get description => 'analyze';

@override
bool get isSafeToInterrupt => true;

@override
Future<ProcessManager> createProcess() {
print('Running `dart analyze`...');
return startProcess(
environment.dartExecutable,
<String>['analyze', '--fatal-infos'],
workingDirectory: environment.webUiRootDir.path,
);
}
}
38 changes: 4 additions & 34 deletions lib/web_ui/dev/felt
Original file line number Diff line number Diff line change
Expand Up @@ -73,25 +73,17 @@ else
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
FELT_DEBUG_FLAGS="--enable-vm-service --pause-isolates-on-start"
fi

install_deps() {
# We need to run pub get here before we actually invoke felt.
echo "Running \`dart pub get\` in 'engine/src/flutter/lib/web_ui'"
(cd "$WEB_UI_DIR"; $DART_PATH pub get)

echo "Running \`dart pub get\` in 'engine/src/flutter/web_sdk/web_engine_tester'"
(cd "$FLUTTER_DIR/web_sdk/web_engine_tester"; $DART_PATH pub get)
}

if [[ $KERNEL_NAME == *"Darwin"* ]]
Expand Down Expand Up @@ -135,28 +127,6 @@ 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
cd $WEB_UI_DIR
install_deps
(cd $WEB_UI_DIR && $DART_SDK_DIR/bin/dart run $FELT_DEBUG_FLAGS dev/felt.dart $@)
40 changes: 3 additions & 37 deletions lib/web_ui/dev/felt.bat
Original file line number Diff line number Diff line change
Expand Up @@ -20,53 +20,19 @@ 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 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 SDK_PREBUILTS_DIR=%FLUTTER_DIR%\prebuilts
SET PREBUILT_TARGET=windows-x64
IF NOT DEFINED DART_SDK_DIR (
SET DART_SDK_DIR=%SDK_PREBUILTS_DIR%\%PREBUILT_TARGET%\dart-sdk
)
SET DART_BIN=%DART_SDK_DIR%\bin\dart

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 %DART_SDK_DIR%\bin\dart pub get
%DART_BIN% --snapshot="%SNAPSHOT_PATH%" --packages="%WEB_UI_DIR%\.dart_tool\package_config.json" %FELT_PATH%
)

IF "%1"=="test" (
%DART_SDK_DIR%\bin\dart --packages="%WEB_UI_DIR%\.dart_tool\package_config.json" "%SNAPSHOT_PATH%" %* --browser=chrome
) ELSE (
%DART_SDK_DIR%\bin\dart --packages="%WEB_UI_DIR%\.dart_tool\package_config.json" "%SNAPSHOT_PATH%" %*
)
:: We need to invoke pub get here before we actually invoke felt.
%DART_BIN% pub get
%DART_BIN% run dev/felt.dart %*

EXIT /B %ERRORLEVEL%
2 changes: 2 additions & 0 deletions lib/web_ui/dev/felt.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'dart:io' as io;

import 'package:args/command_runner.dart';

import 'analyze.dart';
import 'build.dart';
import 'clean.dart';
import 'exceptions.dart';
Expand All @@ -19,6 +20,7 @@ CommandRunner<bool> runner = CommandRunner<bool>(
'felt',
'Command-line utility for building and testing Flutter web engine.',
)
..addCommand(AnalyzeCommand())
..addCommand(BuildCommand())
..addCommand(CleanCommand())
..addCommand(GenerateFallbackFontDataCommand())
Expand Down
18 changes: 17 additions & 1 deletion lib/web_ui/dev/steps/compile_tests_step.dart
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,23 @@ Future<void> buildHostPage() async {
print('Building ${hostDartFile.path}.');
}

final int exitCode = await runProcess(
int exitCode = await runProcess(
environment.dartExecutable,
<String>[
'pub',
'get',
],
workingDirectory: environment.webEngineTesterRootDir.path
);

if (exitCode != 0) {
throw ToolExit(
'Failed to run pub get for web_engine_tester, exit code $exitCode',
exitCode: exitCode,
);
}

exitCode = await runProcess(
environment.dartExecutable,
<String>[
'compile',
Expand Down
5 changes: 4 additions & 1 deletion lib/web_ui/dev/steps/run_tests_step.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ class RunTestsStep implements PipelineStep {
);
}

if (sortedTests.skwasmTests.isNotEmpty) {
// TODO(jacksongardner): enable this test suite on safari
// For some reason, Safari is flaky when running the Skwasm test suite
// See https://github.com/flutter/flutter/issues/115312
if (browserName != kSafari && sortedTests.skwasmTests.isNotEmpty) {
await _runTestBatch(
testFiles: sortedTests.skwasmTests,
renderer: Renderer.skwasm,
Expand Down
Loading