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

Felt analyze #37481

Merged
merged 5 commits into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all 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,
);
}
}
41 changes: 12 additions & 29 deletions lib/web_ui/dev/felt.bat
Original file line number Diff line number Diff line change
Expand Up @@ -35,38 +35,21 @@ IF NOT DEFINED DART_SDK_DIR (
)
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
IF FELT_USE_SNAPSHOT=="0" (
ECHO Invoking felt.dart without snapshot
SET FELT_TARGET=%FELT_PATH%
) ELSE (
%DART_SDK_DIR%\bin\dart --packages="%WEB_UI_DIR%\.dart_tool\package_config.json" "%SNAPSHOT_PATH%" %*
IF NOT EXIST "%SNAPSHOT_PATH%" (
ECHO Precompiling felt snapshot
CALL %DART_BIN% pub get
%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%" %*

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