diff --git a/lib/web_ui/dev/README.md b/lib/web_ui/dev/README.md index 820af336f0a19..8a1ff65f3f058 100644 --- a/lib/web_ui/dev/README.md +++ b/lib/web_ui/dev/README.md @@ -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 ` +## 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: ``` diff --git a/lib/web_ui/dev/build.dart b/lib/web_ui/dev/build.dart index 3b742e1a4116c..541710d74d191 100644 --- a/lib/web_ui/dev/build.dart +++ b/lib/web_ui/dev/build.dart @@ -20,6 +20,11 @@ class BuildCommand extends Command { 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 get isWatchMode => argResults['watch']; + int getNinjaJobCount() { + final String ninjaJobsArg = argResults['ninja-jobs']; + if (ninjaJobsArg != null) { + return int.tryParse(ninjaJobsArg); + } + return null; + } + @override FutureOr run() async { + final int ninjaJobCount = getNinjaJobCount(); final FilePath libPath = FilePath.fromWebUi('lib'); final Pipeline buildPipeline = Pipeline(steps: [ gn, - ninja, + () => ninja(ninjaJobCount), ]); await buildPipeline.start(); @@ -67,11 +81,17 @@ Future gn() { } // TODO(mdebbar): Make the ninja step interruptable in the pipeline. -Future ninja() { - print('Running ninja...'); +Future ninja(int ninjaJobs) { + if (ninjaJobs == null) { + print('Running ninja (with default ninja parallelization)...'); + } else { + print('Running ninja (with $ninjaJobs parallel jobs)...'); + } + return runProcess('ninja', [ '-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; }