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

Commit 12dabe8

Browse files
Felt analyze (#37481)
* Adding `felt analyze` command that CI will run. * Remove some copypasta'd stuff. * Also remove code path from felt.dart that forces a rebuild if it doesn't detect the host_debug_unopt directory. * More cleanup of felt.bat for CI. * Fix typo in felt.bat.
1 parent f467eee commit 12dabe8

File tree

3 files changed

+81
-29
lines changed

3 files changed

+81
-29
lines changed

lib/web_ui/dev/analyze.dart

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'dart:async';
6+
7+
import 'package:args/command_runner.dart';
8+
9+
import 'environment.dart';
10+
import 'pipeline.dart';
11+
import 'utils.dart';
12+
13+
class AnalyzeCommand extends Command<bool> with ArgUtils<bool> {
14+
@override
15+
String get name => 'analyze';
16+
17+
@override
18+
String get description => 'Analyze the Flutter web engine.';
19+
20+
@override
21+
FutureOr<bool> run() async {
22+
final Pipeline buildPipeline = Pipeline(steps: <PipelineStep>[
23+
PubGetStep(),
24+
AnalyzeStep(),
25+
]);
26+
await buildPipeline.run();
27+
return true;
28+
}
29+
}
30+
31+
/// Runs `dart pub get`.
32+
class PubGetStep extends ProcessStep {
33+
@override
34+
String get description => 'pub get';
35+
36+
@override
37+
bool get isSafeToInterrupt => true;
38+
39+
@override
40+
Future<ProcessManager> createProcess() {
41+
print('Running `dart pub get`...');
42+
return startProcess(
43+
environment.dartExecutable,
44+
<String>['pub', 'get'],
45+
workingDirectory: environment.webUiRootDir.path,
46+
);
47+
}
48+
}
49+
50+
/// Runs `dart analyze --fatal-infos`.
51+
class AnalyzeStep extends ProcessStep {
52+
@override
53+
String get description => 'analyze';
54+
55+
@override
56+
bool get isSafeToInterrupt => true;
57+
58+
@override
59+
Future<ProcessManager> createProcess() {
60+
print('Running `dart analyze`...');
61+
return startProcess(
62+
environment.dartExecutable,
63+
<String>['analyze', '--fatal-infos'],
64+
workingDirectory: environment.webUiRootDir.path,
65+
);
66+
}
67+
}

lib/web_ui/dev/felt.bat

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -35,38 +35,21 @@ IF NOT DEFINED DART_SDK_DIR (
3535
)
3636
SET DART_BIN=%DART_SDK_DIR%\bin\dart
3737

38-
SET needsHostDebugUnoptRebuild=0
39-
for %%x in (%*) do (
40-
if ["%%~x"]==["--clean"] (
41-
ECHO Clean rebuild requested
42-
SET needsHostDebugUnoptRebuild=1
43-
)
44-
)
45-
46-
IF NOT EXIST %OUT_DIR% (SET needsHostDebugUnoptRebuild=1)
47-
IF NOT EXIST %HOST_DEBUG_UNOPT_DIR% (SET needsHostDebugUnoptRebuild=1)
48-
49-
IF %needsHostDebugUnoptRebuild%==1 (
50-
ECHO Building host_debug_unopt
51-
:: Delete old snapshot, if any, because the new Dart SDK may invalidate it.
52-
IF EXIST "%SNAPSHOT_PATH%" (
53-
del %SNAPSHOT_PATH%
54-
)
55-
CALL gclient sync -D
56-
CALL python %GN% --unoptimized --full-dart-sdk
57-
CALL ninja -C %HOST_DEBUG_UNOPT_DIR%)
58-
5938
cd %WEB_UI_DIR%
60-
IF NOT EXIST "%SNAPSHOT_PATH%" (
61-
ECHO Precompiling felt snapshot
62-
CALL %DART_SDK_DIR%\bin\dart pub get
63-
%DART_BIN% --snapshot="%SNAPSHOT_PATH%" --packages="%WEB_UI_DIR%\.dart_tool\package_config.json" %FELT_PATH%
64-
)
6539

66-
IF "%1"=="test" (
67-
%DART_SDK_DIR%\bin\dart --packages="%WEB_UI_DIR%\.dart_tool\package_config.json" "%SNAPSHOT_PATH%" %* --browser=chrome
40+
IF FELT_USE_SNAPSHOT=="0" (
41+
ECHO Invoking felt.dart without snapshot
42+
SET FELT_TARGET=%FELT_PATH%
6843
) ELSE (
69-
%DART_SDK_DIR%\bin\dart --packages="%WEB_UI_DIR%\.dart_tool\package_config.json" "%SNAPSHOT_PATH%" %*
44+
IF NOT EXIST "%SNAPSHOT_PATH%" (
45+
ECHO Precompiling felt snapshot
46+
CALL %DART_BIN% pub get
47+
%DART_BIN% --snapshot="%SNAPSHOT_PATH%" --packages="%WEB_UI_DIR%\.dart_tool\package_config.json" %FELT_PATH%
48+
)
49+
SET FELT_TARGET=%SNAPSHOT_PATH%
50+
ECHO Invoking felt snapshot
7051
)
7152

53+
%DART_BIN% --packages="%WEB_UI_DIR%\.dart_tool\package_config.json" "%FELT_TARGET%" %*
54+
7255
EXIT /B %ERRORLEVEL%

lib/web_ui/dev/felt.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'dart:io' as io;
66

77
import 'package:args/command_runner.dart';
88

9+
import 'analyze.dart';
910
import 'build.dart';
1011
import 'clean.dart';
1112
import 'exceptions.dart';
@@ -19,6 +20,7 @@ CommandRunner<bool> runner = CommandRunner<bool>(
1920
'felt',
2021
'Command-line utility for building and testing Flutter web engine.',
2122
)
23+
..addCommand(AnalyzeCommand())
2224
..addCommand(BuildCommand())
2325
..addCommand(CleanCommand())
2426
..addCommand(GenerateFallbackFontDataCommand())

0 commit comments

Comments
 (0)