[web] Support -j to use goma in felt build (flutter/engine#13259)

This commit is contained in:
Mouad Debbar 2019-10-21 15:23:19 -07:00 committed by GitHub
parent 95911a8b6c
commit da68e322c6
2 changed files with 33 additions and 4 deletions

View File

@ -23,6 +23,13 @@ felt build --watch
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>`
## Speeding up your builds
You can speed up your builds by using more CPU cores. Pass `-j` to specify the desired level of parallelism, like so:
```
felt build [-w] -j 100
```
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.
## Running web engine tests
To run all tests:
```

View File

@ -20,6 +20,11 @@ class BuildCommand extends Command<bool> {
abbr: 'w',
help: 'Run the build in watch mode so it rebuilds whenever a change'
'is made.',
)
..addOption(
'ninja-jobs',
abbr: 'j',
help: 'Number of parallel jobs to use in the ninja build.',
);
}
@ -31,12 +36,21 @@ class BuildCommand extends Command<bool> {
bool get isWatchMode => argResults['watch'];
int getNinjaJobCount() {
final String ninjaJobsArg = argResults['ninja-jobs'];
if (ninjaJobsArg != null) {
return int.tryParse(ninjaJobsArg);
}
return null;
}
@override
FutureOr<bool> run() async {
final int ninjaJobCount = getNinjaJobCount();
final FilePath libPath = FilePath.fromWebUi('lib');
final Pipeline buildPipeline = Pipeline(steps: <PipelineStep>[
gn,
ninja,
() => ninja(ninjaJobCount),
]);
await buildPipeline.start();
@ -67,11 +81,17 @@ Future<void> gn() {
}
// TODO(mdebbar): Make the ninja step interruptable in the pipeline.
Future<void> ninja() {
print('Running ninja...');
Future<void> ninja(int ninjaJobs) {
if (ninjaJobs == null) {
print('Running ninja (with default ninja parallelization)...');
} else {
print('Running ninja (with $ninjaJobs parallel jobs)...');
}
return runProcess('ninja', <String>[
'-C',
environment.hostDebugUnoptDir.path,
if (ninjaJobs != null) ...['-j', '$ninjaJobs'],
]);
}
@ -106,8 +126,10 @@ class Pipeline {
await _currentStepFuture;
}
status = PipelineStatus.done;
} catch (_) {
} catch (error, stackTrace) {
status = PipelineStatus.error;
print('Error in the pipeline: $error');
print(stackTrace);
} finally {
_currentStepFuture = null;
}