Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion tools/engine_tool/lib/src/build_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:io' as io show Directory;

import 'package:engine_build_configs/engine_build_configs.dart';
import 'package:path/path.dart' as p;

import 'environment.dart';
import 'logger.dart';
Expand Down Expand Up @@ -63,13 +66,30 @@ void debugCheckBuilds(List<Build> builds) {
}

/// Build the build target in the environment.
Future<int> runBuild(Environment environment, Build build) async {
Future<int> runBuild(
Environment environment,
Build build, {
List<String> extraGnArgs = const <String>[],
}) async {
// If RBE config files aren't in the tree, then disable RBE.
final String rbeConfigPath = p.join(
environment.engine.srcDir.path,
'flutter',
'build',
'rbe',
);
final List<String> gnArgs = <String>[
...extraGnArgs,
if (!io.Directory(rbeConfigPath).existsSync()) '--no-rbe',
];

final BuildRunner buildRunner = BuildRunner(
platform: environment.platform,
processRunner: environment.processRunner,
abi: environment.abi,
engineSrcDir: environment.engine.srcDir,
build: build,
extraGnArgs: gnArgs,
runTests: false,
);

Expand Down
13 changes: 12 additions & 1 deletion tools/engine_tool/lib/src/commands/build_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ final class BuildCommand extends CommandBase {
config.name: config.gn.join(' '),
},
);
argParser.addFlag(
rbeFlag,
defaultsTo: true,
help: 'RBE is enabled by default when available. Use --no-rbe to '
'disable it.',
);
}

/// List of compatible builds.
Expand All @@ -45,14 +51,19 @@ final class BuildCommand extends CommandBase {
@override
Future<int> run() async {
final String configName = argResults![configFlag] as String;
final bool useRbe = argResults![rbeFlag] as bool;
final Build? build =
builds.where((Build build) => build.name == configName).firstOrNull;
if (build == null) {
environment.logger.error('Could not find config $configName');
return 1;
}

final List<String> extraGnArgs = <String>[
if (!useRbe) '--no-rbe',
];

// TODO(loic-sharma): Fetch dependencies if needed.
return runBuild(environment, build);
return runBuild(environment, build, extraGnArgs: extraGnArgs);
}
}
1 change: 1 addition & 0 deletions tools/engine_tool/lib/src/commands/flags.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ const String builderFlag = 'builder';
const String configFlag = 'config';
const String dryRunFlag = 'dry-run';
const String quietFlag = 'quiet';
const String rbeFlag = 'rbe';
const String runTestsFlag = 'run-tests';
const String verboseFlag = 'verbose';
15 changes: 13 additions & 2 deletions tools/engine_tool/lib/src/commands/run_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ final class RunCommand extends CommandBase {
build.name: build.gn.join(' '),
},
);
argParser.addFlag(
rbeFlag,
defaultsTo: true,
help: 'RBE is enabled by default when available. Use --no-rbe to '
'disable it.',
);
}

/// List of compatible builds.
Expand Down Expand Up @@ -142,15 +148,20 @@ final class RunCommand extends CommandBase {
return 1;
}

final bool useRbe = argResults![rbeFlag] as bool;
final List<String> extraGnArgs = <String>[
if (!useRbe) '--no-rbe',
];

// First build the host.
int r = await runBuild(environment, hostBuild);
int r = await runBuild(environment, hostBuild, extraGnArgs: extraGnArgs);
if (r != 0) {
return r;
}

// Now build the target if it isn't the same.
if (hostBuild.name != build.name) {
r = await runBuild(environment, build);
r = await runBuild(environment, build, extraGnArgs: extraGnArgs);
if (r != 0) {
return r;
}
Expand Down
Loading