Skip to content

Commit a1106da

Browse files
author
Harry Terkelsen
authored
[web] Make "felt build" wait for both engine and canvaskit builds (#32308)
1 parent 6dd43e6 commit a1106da

File tree

1 file changed

+35
-40
lines changed

1 file changed

+35
-40
lines changed

lib/web_ui/dev/build.dart

Lines changed: 35 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// found in the LICENSE file.
44

55
import 'dart:async';
6-
import 'dart:io' show Platform;
6+
import 'dart:io' show Directory, Platform;
77

88
import 'package:args/command_runner.dart';
99
import 'package:path/path.dart' as path;
@@ -43,10 +43,17 @@ class BuildCommand extends Command<bool> with ArgUtils<bool> {
4343
@override
4444
FutureOr<bool> run() async {
4545
final FilePath libPath = FilePath.fromWebUi('lib');
46-
final Pipeline buildPipeline = Pipeline(steps: <PipelineStep>[
47-
GnPipelineStep(buildCanvasKit),
48-
NinjaPipelineStep(buildCanvasKit),
49-
]);
46+
final List<PipelineStep> steps = <PipelineStep>[
47+
GnPipelineStep(target: 'engine'),
48+
NinjaPipelineStep(target: environment.hostDebugUnoptDir),
49+
];
50+
if (buildCanvasKit) {
51+
steps.addAll(<PipelineStep>[
52+
GnPipelineStep(target: 'canvaskit'),
53+
NinjaPipelineStep(target: environment.canvasKitOutDir),
54+
]);
55+
}
56+
final Pipeline buildPipeline = Pipeline(steps: steps);
5057
await buildPipeline.run();
5158

5259
if (isWatchMode) {
@@ -68,78 +75,66 @@ class BuildCommand extends Command<bool> with ArgUtils<bool> {
6875
/// Not safe to interrupt as it may leave the `out/` directory in a corrupted
6976
/// state. GN is pretty quick though, so it's OK to not support interruption.
7077
class GnPipelineStep extends ProcessStep {
71-
GnPipelineStep(this.buildCanvasKit);
78+
GnPipelineStep({this.target = 'engine'})
79+
: assert(target == 'engine' || target == 'sdk');
7280

7381
@override
7482
String get description => 'gn';
7583

7684
@override
7785
bool get isSafeToInterrupt => false;
7886

79-
/// Whether or not to build CanvasKit.
80-
final bool buildCanvasKit;
87+
/// The target to build with gn.
88+
///
89+
/// Acceptable values: engine, canvaskit
90+
final String target;
8191

8292
@override
8393
Future<ProcessManager> createProcess() {
8494
print('Running gn...');
85-
Future<ProcessManager> gnProcess = startProcess(
86-
path.join(environment.flutterDirectory.path, 'tools', 'gn'),
87-
<String>[
95+
final List<String> gnArgs = <String>[];
96+
if (target == 'engine') {
97+
gnArgs.addAll(<String>[
8898
'--unopt',
8999
if (Platform.isMacOS) '--xcode-symlinks',
90100
'--full-dart-sdk',
91-
],
92-
);
93-
if (buildCanvasKit) {
94-
gnProcess = gnProcess.then((_) {
95-
return startProcess(
96-
path.join(environment.flutterDirectory.path, 'tools', 'gn'),
97-
<String>[
98-
'--wasm',
99-
],
100-
);
101-
});
101+
]);
102+
} else if (target == 'canvaskit') {
103+
gnArgs.add('--wasm');
104+
} else {
105+
throw StateError('Target was not engine or canvaskit: $target');
102106
}
103-
return gnProcess;
107+
return startProcess(
108+
path.join(environment.flutterDirectory.path, 'tools', 'gn'),
109+
gnArgs,
110+
);
104111
}
105112
}
106113

107114
/// Runs `autoninja`.
108115
///
109116
/// Can be safely interrupted.
110117
class NinjaPipelineStep extends ProcessStep {
111-
NinjaPipelineStep(this.buildCanvasKit);
118+
NinjaPipelineStep({required this.target});
112119

113120
@override
114121
String get description => 'ninja';
115122

116123
@override
117124
bool get isSafeToInterrupt => true;
118125

119-
/// Whether or not to build CanvasKit.
120-
final bool buildCanvasKit;
126+
/// The target directory to build.
127+
final Directory target;
121128

122129
@override
123130
Future<ProcessManager> createProcess() {
124131
print('Running autoninja...');
125-
Future<ProcessManager> ninjaProcess = startProcess(
132+
return startProcess(
126133
'autoninja',
127134
<String>[
128135
'-C',
129-
environment.hostDebugUnoptDir.path,
136+
target.path,
130137
],
131138
);
132-
if (buildCanvasKit) {
133-
ninjaProcess = ninjaProcess.then((_) {
134-
return startProcess(
135-
'autoninja',
136-
<String>[
137-
'-C',
138-
environment.canvasKitOutDir.path,
139-
],
140-
);
141-
});
142-
}
143-
return ninjaProcess;
144139
}
145140
}

0 commit comments

Comments
 (0)