Skip to content

Commit 6a3baef

Browse files
authored
[web] Support -j to use goma in felt build (flutter#13259)
1 parent 6b721ca commit 6a3baef

2 files changed

Lines changed: 33 additions & 4 deletions

File tree

lib/web_ui/dev/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ felt build --watch
2323

2424
If you don't want to add `felt` to your path, you can still invoke it using a relative path like `./web_ui/dev/felt <command>`
2525

26+
## Speeding up your builds
27+
You can speed up your builds by using more CPU cores. Pass `-j` to specify the desired level of parallelism, like so:
28+
```
29+
felt build [-w] -j 100
30+
```
31+
If you are a Google employee, you can use an internal instance of Goma to parallelize your builds. Because Goma compiles code on remote servers, this option is effective even on low-powered laptops.
32+
2633
## Running web engine tests
2734
To run all tests:
2835
```

lib/web_ui/dev/build.dart

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ class BuildCommand extends Command<bool> {
2020
abbr: 'w',
2121
help: 'Run the build in watch mode so it rebuilds whenever a change'
2222
'is made.',
23+
)
24+
..addOption(
25+
'ninja-jobs',
26+
abbr: 'j',
27+
help: 'Number of parallel jobs to use in the ninja build.',
2328
);
2429
}
2530

@@ -31,12 +36,21 @@ class BuildCommand extends Command<bool> {
3136

3237
bool get isWatchMode => argResults['watch'];
3338

39+
int getNinjaJobCount() {
40+
final String ninjaJobsArg = argResults['ninja-jobs'];
41+
if (ninjaJobsArg != null) {
42+
return int.tryParse(ninjaJobsArg);
43+
}
44+
return null;
45+
}
46+
3447
@override
3548
FutureOr<bool> run() async {
49+
final int ninjaJobCount = getNinjaJobCount();
3650
final FilePath libPath = FilePath.fromWebUi('lib');
3751
final Pipeline buildPipeline = Pipeline(steps: <PipelineStep>[
3852
gn,
39-
ninja,
53+
() => ninja(ninjaJobCount),
4054
]);
4155
await buildPipeline.start();
4256

@@ -67,11 +81,17 @@ Future<void> gn() {
6781
}
6882

6983
// TODO(mdebbar): Make the ninja step interruptable in the pipeline.
70-
Future<void> ninja() {
71-
print('Running ninja...');
84+
Future<void> ninja(int ninjaJobs) {
85+
if (ninjaJobs == null) {
86+
print('Running ninja (with default ninja parallelization)...');
87+
} else {
88+
print('Running ninja (with $ninjaJobs parallel jobs)...');
89+
}
90+
7291
return runProcess('ninja', <String>[
7392
'-C',
7493
environment.hostDebugUnoptDir.path,
94+
if (ninjaJobs != null) ...['-j', '$ninjaJobs'],
7595
]);
7696
}
7797

@@ -106,8 +126,10 @@ class Pipeline {
106126
await _currentStepFuture;
107127
}
108128
status = PipelineStatus.done;
109-
} catch (_) {
129+
} catch (error, stackTrace) {
110130
status = PipelineStatus.error;
131+
print('Error in the pipeline: $error');
132+
print(stackTrace);
111133
} finally {
112134
_currentStepFuture = null;
113135
}

0 commit comments

Comments
 (0)