5
5
import 'package:engine_build_configs/engine_build_configs.dart' ;
6
6
7
7
import '../build_utils.dart' ;
8
-
8
+ import '../logger.dart' ;
9
9
import 'command.dart' ;
10
-
11
- const String _configFlag = 'config' ;
10
+ import 'flags.dart' ;
12
11
13
12
// TODO(johnmccutchan): Should BuildConfig be BuilderConfig and GlobalBuild be BuildConfig?
14
13
// TODO(johnmccutchan): List all available build targets and allow the user
@@ -24,20 +23,26 @@ final class BuildCommand extends CommandBase {
24
23
}) {
25
24
builds = runnableBuilds (environment, configs);
26
25
// 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
+ );
41
46
}
42
47
43
48
/// List of compatible builds.
@@ -51,7 +56,8 @@ final class BuildCommand extends CommandBase {
51
56
52
57
@override
53
58
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 ;
55
61
final GlobalBuild ? build = builds
56
62
.where ((GlobalBuild build) => build.name == configName)
57
63
.firstOrNull;
@@ -60,28 +66,38 @@ final class BuildCommand extends CommandBase {
60
66
return 1 ;
61
67
}
62
68
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;
68
78
void handler (RunnerEvent event) {
69
79
switch (event) {
70
80
case RunnerStart ():
71
- environment.logger.info ('$event : ${event .command .join (' ' )}' );
81
+ environment.logger.status ('$event ' , newline: false );
82
+ spinner = environment.logger.startSpinner ();
72
83
case RunnerProgress (done: true ):
84
+ spinner? .finish ();
85
+ spinner = null ;
73
86
environment.logger.clearLine ();
74
87
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
+ }
84
98
default :
99
+ spinner? .finish ();
100
+ spinner = null ;
85
101
environment.logger.status (event);
86
102
}
87
103
}
0 commit comments