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

Commit c7dc1f7

Browse files
committed
[et] Improve the logger for the ninja build, adds a spinner
1 parent a148bdb commit c7dc1f7

File tree

5 files changed

+359
-48
lines changed

5 files changed

+359
-48
lines changed

tools/engine_tool/lib/src/commands/build_command.dart

Lines changed: 49 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
import 'package:engine_build_configs/engine_build_configs.dart';
66

77
import '../build_utils.dart';
8-
8+
import '../logger.dart';
99
import 'command.dart';
10-
11-
const String _configFlag = 'config';
10+
import 'flags.dart';
1211

1312
// TODO(johnmccutchan): Should BuildConfig be BuilderConfig and GlobalBuild be BuildConfig?
1413
// TODO(johnmccutchan): List all available build targets and allow the user
@@ -24,20 +23,26 @@ final class BuildCommand extends CommandBase {
2423
}) {
2524
builds = runnableBuilds(environment, configs);
2625
// Add options here that are common to all queries.
27-
argParser.addOption(
28-
_configFlag,
29-
abbr: 'c',
30-
defaultsTo: 'host_debug',
31-
help: 'Specify the build config to use',
32-
allowed: <String>[
33-
for (final GlobalBuild config in runnableBuilds(environment, configs))
34-
config.name,
35-
],
36-
allowedHelp: <String, String>{
37-
for (final GlobalBuild config in runnableBuilds(environment, configs))
38-
config.name: config.gn.join(' '),
39-
},
40-
);
26+
argParser
27+
..addOption(
28+
configFlag,
29+
abbr: 'c',
30+
defaultsTo: 'host_debug',
31+
help: 'Specify the build config to use',
32+
allowed: <String>[
33+
for (final GlobalBuild config in runnableBuilds(environment, configs))
34+
config.name,
35+
],
36+
allowedHelp: <String, String>{
37+
for (final GlobalBuild config in runnableBuilds(environment, configs))
38+
config.name: config.gn.join(' '),
39+
},
40+
)
41+
..addFlag(
42+
runTestsFlag,
43+
help: 'Whether to run tests after building.',
44+
defaultsTo: true,
45+
);
4146
}
4247

4348
/// List of compatible builds.
@@ -51,7 +56,8 @@ final class BuildCommand extends CommandBase {
5156

5257
@override
5358
Future<int> run() async {
54-
final String configName = argResults![_configFlag] as String;
59+
final String configName = argResults![configFlag] as String;
60+
final bool runTests = argResults![runTestsFlag] as bool;
5561
final GlobalBuild? build = builds
5662
.where((GlobalBuild build) => build.name == configName)
5763
.firstOrNull;
@@ -60,28 +66,38 @@ final class BuildCommand extends CommandBase {
6066
return 1;
6167
}
6268
final GlobalBuildRunner buildRunner = GlobalBuildRunner(
63-
platform: environment.platform,
64-
processRunner: environment.processRunner,
65-
abi: environment.abi,
66-
engineSrcDir: environment.engine.srcDir,
67-
build: build);
69+
platform: environment.platform,
70+
processRunner: environment.processRunner,
71+
abi: environment.abi,
72+
engineSrcDir: environment.engine.srcDir,
73+
build: build,
74+
runTests: runTests,
75+
);
76+
77+
Spinner? spinner;
6878
void handler(RunnerEvent event) {
6979
switch (event) {
7080
case RunnerStart():
71-
environment.logger.info('$event: ${event.command.join(' ')}');
81+
environment.logger.status('$event ', newline: false);
82+
spinner = environment.logger.startSpinner();
7283
case RunnerProgress(done: true):
84+
spinner?.finish();
85+
spinner = null;
7386
environment.logger.clearLine();
7487
environment.logger.status(event);
75-
case RunnerProgress(done: false):
76-
{
77-
final String percent = '${event.percent.toStringAsFixed(1)}%';
78-
final String fraction = '(${event.completed}/${event.total})';
79-
final String prefix = '[${event.name}] $percent $fraction ';
80-
final String what = event.what;
81-
environment.logger.clearLine();
82-
environment.logger.status('$prefix$what');
83-
}
88+
case RunnerProgress(done: false): {
89+
spinner?.finish();
90+
spinner = null;
91+
final String percent = '${event.percent.toStringAsFixed(1)}%';
92+
final String fraction = '(${event.completed}/${event.total})';
93+
final String prefix = '[${event.name}] $percent $fraction ';
94+
final String what = event.what;
95+
environment.logger.clearLine();
96+
environment.logger.status('$prefix$what', newline: false, fit: true);
97+
}
8498
default:
99+
spinner?.finish();
100+
spinner = null;
85101
environment.logger.status(event);
86102
}
87103
}

tools/engine_tool/lib/src/commands/flags.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
// Keep this list alphabetized.
1414
const String allFlag = 'all';
1515
const String builderFlag = 'builder';
16+
const String configFlag = 'config';
1617
const String dryRunFlag = 'dry-run';
1718
const String quietFlag = 'quiet';
19+
const String runTestsFlag = 'run-tests';
1820
const String verboseFlag = 'verbose';

0 commit comments

Comments
 (0)