[et] build and run commands disable RBE with a flag or when not available (flutter/engine#51404)
This commit is contained in:
@@ -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';
|
||||
@@ -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,
|
||||
);
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -45,6 +51,7 @@ 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) {
|
||||
@@ -52,7 +59,11 @@ final class BuildCommand extends CommandBase {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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.
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import 'package:engine_tool/src/commands/command_runner.dart';
|
||||
import 'package:engine_tool/src/environment.dart';
|
||||
import 'package:engine_tool/src/logger.dart';
|
||||
import 'package:litetest/litetest.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:platform/platform.dart';
|
||||
import 'package:process_fakes/process_fakes.dart';
|
||||
import 'package:process_runner/process_runner.dart';
|
||||
@@ -20,15 +21,6 @@ import 'package:process_runner/process_runner.dart';
|
||||
import 'fixtures.dart' as fixtures;
|
||||
|
||||
void main() {
|
||||
final Engine engine;
|
||||
try {
|
||||
engine = Engine.findWithin();
|
||||
} catch (e) {
|
||||
io.stderr.writeln(e);
|
||||
io.exitCode = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
final BuilderConfig linuxTestConfig = BuilderConfig.fromJson(
|
||||
path: 'ci/builders/linux_test_config.json',
|
||||
map: convert.jsonDecode(fixtures.testConfig('Linux'))
|
||||
@@ -54,7 +46,20 @@ void main() {
|
||||
'win_test_config': winTestConfig,
|
||||
};
|
||||
|
||||
(Environment, List<List<String>>) linuxEnv(Logger logger) {
|
||||
(Environment, List<List<String>>) linuxEnv(
|
||||
Logger logger, {
|
||||
bool withRbe = false,
|
||||
}) {
|
||||
final io.Directory rootDir = io.Directory.systemTemp.createTempSync('et');
|
||||
final TestEngine engine = TestEngine.createTemp(rootDir: rootDir);
|
||||
if (withRbe) {
|
||||
io.Directory(path.join(
|
||||
engine.srcDir.path,
|
||||
'flutter',
|
||||
'build',
|
||||
'rbe',
|
||||
)).createSync(recursive: true);
|
||||
}
|
||||
final List<List<String>> runHistory = <List<String>>[];
|
||||
return (
|
||||
Environment(
|
||||
@@ -64,13 +69,17 @@ void main() {
|
||||
operatingSystem: Platform.linux,
|
||||
resolvedExecutable: io.Platform.resolvedExecutable),
|
||||
processRunner: ProcessRunner(
|
||||
processManager: FakeProcessManager(onStart: (List<String> command) {
|
||||
runHistory.add(command);
|
||||
return FakeProcess();
|
||||
}, onRun: (List<String> command) {
|
||||
runHistory.add(command);
|
||||
return io.ProcessResult(81, 0, '', '');
|
||||
}),
|
||||
processManager: FakeProcessManager(
|
||||
canRun: (Object? exe, {String? workingDirectory}) => true,
|
||||
onStart: (List<String> command) {
|
||||
runHistory.add(command);
|
||||
return FakeProcess();
|
||||
},
|
||||
onRun: (List<String> command) {
|
||||
runHistory.add(command);
|
||||
return io.ProcessResult(81, 0, '', '');
|
||||
},
|
||||
),
|
||||
),
|
||||
logger: logger,
|
||||
),
|
||||
@@ -78,83 +87,182 @@ void main() {
|
||||
);
|
||||
}
|
||||
|
||||
void cleanupEnv(Environment env) {
|
||||
try {
|
||||
env.engine.srcDir.parent.deleteSync(recursive: true);
|
||||
} catch (_) {
|
||||
// Ignore failure to clean up.
|
||||
}
|
||||
}
|
||||
|
||||
test('can find host runnable build', () async {
|
||||
final Logger logger = Logger.test();
|
||||
final (Environment env, _) = linuxEnv(logger);
|
||||
final List<Build> result = runnableBuilds(env, configs);
|
||||
expect(result.length, equals(6));
|
||||
expect(result[0].name, equals('build_name'));
|
||||
try {
|
||||
final List<Build> result = runnableBuilds(env, configs);
|
||||
expect(result.length, equals(8));
|
||||
expect(result[0].name, equals('build_name'));
|
||||
} finally {
|
||||
cleanupEnv(env);
|
||||
}
|
||||
});
|
||||
|
||||
test('build command invokes gn', () async {
|
||||
final Logger logger = Logger.test();
|
||||
final (Environment env, List<List<String>> runHistory) = linuxEnv(logger);
|
||||
final ToolCommandRunner runner = ToolCommandRunner(
|
||||
environment: env,
|
||||
configs: configs,
|
||||
);
|
||||
final int result = await runner.run(<String>[
|
||||
'build',
|
||||
'--config',
|
||||
'build_name',
|
||||
]);
|
||||
expect(result, equals(0));
|
||||
expect(runHistory.length, greaterThanOrEqualTo(1));
|
||||
expect(runHistory[0].length, greaterThanOrEqualTo(1));
|
||||
expect(runHistory[0][0], contains('gn'));
|
||||
try {
|
||||
final ToolCommandRunner runner = ToolCommandRunner(
|
||||
environment: env,
|
||||
configs: configs,
|
||||
);
|
||||
final int result = await runner.run(<String>[
|
||||
'build',
|
||||
'--config',
|
||||
'build_name',
|
||||
]);
|
||||
expect(result, equals(0));
|
||||
expect(runHistory.length, greaterThanOrEqualTo(1));
|
||||
expect(runHistory[0].length, greaterThanOrEqualTo(1));
|
||||
expect(runHistory[0][0], contains('gn'));
|
||||
} finally {
|
||||
cleanupEnv(env);
|
||||
}
|
||||
});
|
||||
|
||||
test('build command invokes ninja', () async {
|
||||
final Logger logger = Logger.test();
|
||||
final (Environment env, List<List<String>> runHistory) = linuxEnv(logger);
|
||||
final ToolCommandRunner runner = ToolCommandRunner(
|
||||
environment: env,
|
||||
configs: configs,
|
||||
);
|
||||
final int result = await runner.run(<String>[
|
||||
'build',
|
||||
'--config',
|
||||
'build_name',
|
||||
]);
|
||||
expect(result, equals(0));
|
||||
expect(runHistory.length, greaterThanOrEqualTo(2));
|
||||
expect(runHistory[1].length, greaterThanOrEqualTo(1));
|
||||
expect(runHistory[1][0], contains('ninja'));
|
||||
try {
|
||||
final ToolCommandRunner runner = ToolCommandRunner(
|
||||
environment: env,
|
||||
configs: configs,
|
||||
);
|
||||
final int result = await runner.run(<String>[
|
||||
'build',
|
||||
'--config',
|
||||
'build_name',
|
||||
]);
|
||||
expect(result, equals(0));
|
||||
expect(runHistory.length, greaterThanOrEqualTo(2));
|
||||
expect(runHistory[1].length, greaterThanOrEqualTo(1));
|
||||
expect(runHistory[1][0], contains('ninja'));
|
||||
} finally {
|
||||
cleanupEnv(env);
|
||||
}
|
||||
});
|
||||
|
||||
test('build command invokes generator', () async {
|
||||
final Logger logger = Logger.test();
|
||||
final (Environment env, List<List<String>> runHistory) = linuxEnv(logger);
|
||||
final ToolCommandRunner runner = ToolCommandRunner(
|
||||
environment: env,
|
||||
configs: configs,
|
||||
);
|
||||
final int result = await runner.run(<String>[
|
||||
'build',
|
||||
'--config',
|
||||
'build_name',
|
||||
]);
|
||||
expect(result, equals(0));
|
||||
expect(runHistory.length, greaterThanOrEqualTo(3));
|
||||
expect(
|
||||
runHistory[2],
|
||||
containsStringsInOrder(<String>['python3', 'gen/script.py']),
|
||||
);
|
||||
try {
|
||||
final ToolCommandRunner runner = ToolCommandRunner(
|
||||
environment: env,
|
||||
configs: configs,
|
||||
);
|
||||
final int result = await runner.run(<String>[
|
||||
'build',
|
||||
'--config',
|
||||
'build_name',
|
||||
]);
|
||||
expect(result, equals(0));
|
||||
expect(runHistory.length, greaterThanOrEqualTo(3));
|
||||
expect(
|
||||
runHistory[2],
|
||||
containsStringsInOrder(<String>['python3', 'gen/script.py']),
|
||||
);
|
||||
} finally {
|
||||
cleanupEnv(env);
|
||||
}
|
||||
});
|
||||
|
||||
test('build command does not invoke tests', () async {
|
||||
final Logger logger = Logger.test();
|
||||
final (Environment env, List<List<String>> runHistory) = linuxEnv(logger);
|
||||
final ToolCommandRunner runner = ToolCommandRunner(
|
||||
environment: env,
|
||||
configs: configs,
|
||||
try {
|
||||
final ToolCommandRunner runner = ToolCommandRunner(
|
||||
environment: env,
|
||||
configs: configs,
|
||||
);
|
||||
final int result = await runner.run(<String>[
|
||||
'build',
|
||||
'--config',
|
||||
'build_name',
|
||||
]);
|
||||
expect(result, equals(0));
|
||||
expect(runHistory.length, lessThanOrEqualTo(3));
|
||||
} finally {
|
||||
cleanupEnv(env);
|
||||
}
|
||||
});
|
||||
|
||||
test('build command runs rbe on an rbe build', () async {
|
||||
final Logger logger = Logger.test();
|
||||
final (Environment env, List<List<String>> runHistory) = linuxEnv(
|
||||
logger, withRbe: true,
|
||||
);
|
||||
final int result = await runner.run(<String>[
|
||||
'build',
|
||||
'--config',
|
||||
'build_name',
|
||||
]);
|
||||
expect(result, equals(0));
|
||||
expect(runHistory.length, lessThanOrEqualTo(3));
|
||||
try {
|
||||
final ToolCommandRunner runner = ToolCommandRunner(
|
||||
environment: env,
|
||||
configs: configs,
|
||||
);
|
||||
final int result = await runner.run(<String>[
|
||||
'build',
|
||||
'--config',
|
||||
'android_debug_rbe_arm64',
|
||||
]);
|
||||
expect(result, equals(0));
|
||||
expect(runHistory[0][0], contains(path.join('tools', 'gn')));
|
||||
expect(runHistory[0][4], equals('--rbe'));
|
||||
expect(runHistory[1][0], contains(path.join('reclient', 'bootstrap')));
|
||||
} finally {
|
||||
cleanupEnv(env);
|
||||
}
|
||||
});
|
||||
|
||||
test('build command does not run rbe when disabled', () async {
|
||||
final Logger logger = Logger.test();
|
||||
final (Environment env, List<List<String>> runHistory) = linuxEnv(
|
||||
logger, withRbe: true,
|
||||
);
|
||||
try {
|
||||
final ToolCommandRunner runner = ToolCommandRunner(
|
||||
environment: env,
|
||||
configs: configs,
|
||||
);
|
||||
final int result = await runner.run(<String>[
|
||||
'build',
|
||||
'--config',
|
||||
'android_debug_rbe_arm64',
|
||||
'--no-rbe',
|
||||
]);
|
||||
expect(result, equals(0));
|
||||
expect(runHistory[0][0], contains(path.join('tools', 'gn')));
|
||||
expect(runHistory[0], doesNotContainAny(<String>['--rbe']));
|
||||
expect(runHistory[1][0], contains(path.join('ninja', 'ninja')));
|
||||
} finally {
|
||||
cleanupEnv(env);
|
||||
}
|
||||
});
|
||||
|
||||
test('build command does not run rbe when rbe configs do not exist', () async {
|
||||
final Logger logger = Logger.test();
|
||||
final (Environment env, List<List<String>> runHistory) = linuxEnv(logger);
|
||||
try {
|
||||
final ToolCommandRunner runner = ToolCommandRunner(
|
||||
environment: env,
|
||||
configs: configs,
|
||||
);
|
||||
final int result = await runner.run(<String>[
|
||||
'build',
|
||||
'--config',
|
||||
'android_debug_rbe_arm64',
|
||||
]);
|
||||
expect(result, equals(0));
|
||||
expect(runHistory[0][0], contains(path.join('tools', 'gn')));
|
||||
expect(runHistory[0], doesNotContainAny(<String>['--rbe']));
|
||||
expect(runHistory[1][0], contains(path.join('ninja', 'ninja')));
|
||||
} finally {
|
||||
cleanupEnv(env);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -70,6 +70,17 @@ String testConfig(String os) => '''
|
||||
"config": "android_debug_arm64",
|
||||
"targets": ["ninja_target"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"drone_dimensions": [
|
||||
"os=$os"
|
||||
],
|
||||
"gn": ["--gn-arg", "--lto", "--no-goma", "--rbe"],
|
||||
"name": "android_debug_rbe_arm64",
|
||||
"ninja": {
|
||||
"config": "android_debug_rbe_arm64",
|
||||
"targets": ["ninja_target"]
|
||||
}
|
||||
}
|
||||
],
|
||||
"generators": {
|
||||
|
||||
@@ -93,10 +93,12 @@ void main() {
|
||||
' "build_name" config\n',
|
||||
' "host_debug" config\n',
|
||||
' "android_debug_arm64" config\n',
|
||||
' "android_debug_rbe_arm64" config\n',
|
||||
'"linux_test_config2" builder:\n',
|
||||
' "build_name" config\n',
|
||||
' "host_debug" config\n',
|
||||
' "android_debug_arm64" config\n',
|
||||
' "android_debug_rbe_arm64" config\n',
|
||||
]),
|
||||
);
|
||||
});
|
||||
@@ -125,6 +127,7 @@ void main() {
|
||||
' "build_name" config\n',
|
||||
' "host_debug" config\n',
|
||||
' "android_debug_arm64" config\n',
|
||||
' "android_debug_rbe_arm64" config\n',
|
||||
]));
|
||||
});
|
||||
|
||||
@@ -143,7 +146,7 @@ void main() {
|
||||
expect(result, equals(0));
|
||||
expect(
|
||||
logger.testLogs.length,
|
||||
equals(26),
|
||||
equals(30),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user