Unverified Commit a3a350df authored by Jason Simmons's avatar Jason Simmons Committed by GitHub

devicelab: replace the FLUTTER_ENGINE environment variable with the new local engine flags (#36969)

parent 9b150f13
...@@ -36,11 +36,10 @@ Future<TaskResult> createFlutterRunTask() async { ...@@ -36,11 +36,10 @@ Future<TaskResult> createFlutterRunTask() async {
final List<String> options = <String>[ final List<String> options = <String>[
'-t', runTestSource.absolute.path, '-d', device.deviceId, '-t', runTestSource.absolute.path, '-d', device.deviceId,
]; ];
setLocalEngineOptionIfNecessary(options);
await inDirectory<void>(flutterGalleryDir, () async { await inDirectory<void>(flutterGalleryDir, () async {
startProcess( startProcess(
path.join(flutterDirectory.path, 'bin', 'flutter'), path.join(flutterDirectory.path, 'bin', 'flutter'),
<String>['run', ...options], flutterCommandArgs('run', options),
environment: null, environment: null,
); );
final Completer<void> finished = Completer<void>(); final Completer<void> finished = Completer<void>();
......
...@@ -13,8 +13,6 @@ import 'package:path/path.dart' as path; ...@@ -13,8 +13,6 @@ import 'package:path/path.dart' as path;
import 'package:process/process.dart'; import 'package:process/process.dart';
import 'package:stack_trace/stack_trace.dart'; import 'package:stack_trace/stack_trace.dart';
import 'adb.dart';
/// Virtual current working directory, which affect functions, such as [exec]. /// Virtual current working directory, which affect functions, such as [exec].
String cwd = Directory.current.path; String cwd = Directory.current.path;
...@@ -347,17 +345,21 @@ Future<String> eval( ...@@ -347,17 +345,21 @@ Future<String> eval(
return output.toString().trimRight(); return output.toString().trimRight();
} }
Future<int> flutter(String command, { List<String> flutterCommandArgs(String command, List<String> options) {
List<String> options = const <String>[], return <String>[
bool canFail = false, // as in, whether failures are ok. False means that they are fatal.
Map<String, String> environment,
}) {
final List<String> args = <String>[
command, command,
if (localEngine != null) ...<String>['--local-engine', localEngine], if (localEngine != null) ...<String>['--local-engine', localEngine],
if (localEngineSrcPath != null) ...<String>['--local-engine-src-path', localEngineSrcPath], if (localEngineSrcPath != null) ...<String>['--local-engine-src-path', localEngineSrcPath],
...options, ...options,
]; ];
}
Future<int> flutter(String command, {
List<String> options = const <String>[],
bool canFail = false, // as in, whether failures are ok. False means that they are fatal.
Map<String, String> environment,
}) {
final List<String> args = flutterCommandArgs(command, options);
return exec(path.join(flutterDirectory.path, 'bin', 'flutter'), args, return exec(path.join(flutterDirectory.path, 'bin', 'flutter'), args,
canFail: canFail, environment: environment); canFail: canFail, environment: environment);
} }
...@@ -369,12 +371,7 @@ Future<String> evalFlutter(String command, { ...@@ -369,12 +371,7 @@ Future<String> evalFlutter(String command, {
Map<String, String> environment, Map<String, String> environment,
StringBuffer stderr, // if not null, the stderr will be written here. StringBuffer stderr, // if not null, the stderr will be written here.
}) { }) {
final List<String> args = <String>[ final List<String> args = flutterCommandArgs(command, options);
command,
if (localEngine != null) ...<String>['--local-engine', localEngine],
if (localEngineSrcPath != null) ...<String>['--local-engine-src-path', localEngineSrcPath],
...options,
];
return eval(path.join(flutterDirectory.path, 'bin', 'flutter'), args, return eval(path.join(flutterDirectory.path, 'bin', 'flutter'), args,
canFail: canFail, environment: environment, stderr: stderr); canFail: canFail, environment: environment, stderr: stderr);
} }
...@@ -593,39 +590,6 @@ Uri parseServiceUri(String line, { ...@@ -593,39 +590,6 @@ Uri parseServiceUri(String line, {
return matches.isEmpty ? null : Uri.parse(matches[0].group(0)); return matches.isEmpty ? null : Uri.parse(matches[0].group(0));
} }
/// If FLUTTER_ENGINE environment variable is set then we need to pass
/// correct --local-engine setting too.
void setLocalEngineOptionIfNecessary(List<String> options, [String flavor]) {
if (Platform.environment['FLUTTER_ENGINE'] != null) {
if (flavor == null) {
// If engine flavor was not specified explicitly then scan options looking
// for flags that specify the engine flavor (--release, --profile or
// --debug). Default flavor to debug if no flags were found.
const Map<String, String> optionToFlavor = <String, String>{
'--release': 'release',
'--debug': 'debug',
'--profile': 'profile',
};
for (String option in options) {
flavor = optionToFlavor[option];
if (flavor != null) {
break;
}
}
flavor ??= 'debug';
}
const Map<DeviceOperatingSystem, String> osNames = <DeviceOperatingSystem, String>{
DeviceOperatingSystem.ios: 'ios',
DeviceOperatingSystem.android: 'android',
};
options.add('--local-engine=${osNames[deviceOperatingSystem]}_$flavor');
}
}
/// Checks that the file exists, otherwise throws a [FileSystemException]. /// Checks that the file exists, otherwise throws a [FileSystemException].
void checkFileExists(String file) { void checkFileExists(String file) {
if (!exists(File(file))) { if (!exists(File(file))) {
......
...@@ -25,7 +25,6 @@ TaskFunction createHotModeTest() { ...@@ -25,7 +25,6 @@ TaskFunction createHotModeTest() {
final List<String> options = <String>[ final List<String> options = <String>[
'--hot', '-d', device.deviceId, '--benchmark', '--verbose', '--resident', '--hot', '-d', device.deviceId, '--benchmark', '--verbose', '--resident',
]; ];
setLocalEngineOptionIfNecessary(options);
int hotReloadCount = 0; int hotReloadCount = 0;
Map<String, dynamic> twoReloadsData; Map<String, dynamic> twoReloadsData;
Map<String, dynamic> freshRestartReloadsData; Map<String, dynamic> freshRestartReloadsData;
...@@ -39,7 +38,7 @@ TaskFunction createHotModeTest() { ...@@ -39,7 +38,7 @@ TaskFunction createHotModeTest() {
{ {
final Process process = await startProcess( final Process process = await startProcess(
path.join(flutterDirectory.path, 'bin', 'flutter'), path.join(flutterDirectory.path, 'bin', 'flutter'),
<String>['run', ...options], flutterCommandArgs('run', options),
environment: null, environment: null,
); );
...@@ -93,7 +92,7 @@ TaskFunction createHotModeTest() { ...@@ -93,7 +92,7 @@ TaskFunction createHotModeTest() {
{ {
final Process process = await startProcess( final Process process = await startProcess(
path.join(flutterDirectory.path, 'bin', 'flutter'), path.join(flutterDirectory.path, 'bin', 'flutter'),
<String>['run', ...options], flutterCommandArgs('run', options),
environment: null, environment: null,
); );
final Completer<void> stdoutDone = Completer<void>(); final Completer<void> stdoutDone = Completer<void>();
......
...@@ -35,7 +35,6 @@ TaskFunction createMicrobenchmarkTask() { ...@@ -35,7 +35,6 @@ TaskFunction createMicrobenchmarkTask() {
'-d', '-d',
device.deviceId, device.deviceId,
]; ];
setLocalEngineOptionIfNecessary(options);
options.add(benchmarkPath); options.add(benchmarkPath);
return await _startFlutter( return await _startFlutter(
options: options, options: options,
...@@ -70,7 +69,7 @@ Future<Process> _startFlutter({ ...@@ -70,7 +69,7 @@ Future<Process> _startFlutter({
bool canFail = false, bool canFail = false,
Map<String, String> environment, Map<String, String> environment,
}) { }) {
final List<String> args = <String>['run', ...options]; final List<String> args = flutterCommandArgs('run', options);
return startProcess(path.join(flutterDirectory.path, 'bin', 'flutter'), args, environment: environment); return startProcess(path.join(flutterDirectory.path, 'bin', 'flutter'), args, environment: environment);
} }
......
...@@ -335,7 +335,6 @@ class CompileTest { ...@@ -335,7 +335,6 @@ class CompileTest {
options.add('android-arm'); options.add('android-arm');
break; break;
} }
setLocalEngineOptionIfNecessary(options);
final String compileLog = await evalFlutter('build', options: options); final String compileLog = await evalFlutter('build', options: options);
watch.stop(); watch.stop();
...@@ -357,7 +356,6 @@ class CompileTest { ...@@ -357,7 +356,6 @@ class CompileTest {
final Stopwatch watch = Stopwatch(); final Stopwatch watch = Stopwatch();
int releaseSizeInBytes; int releaseSizeInBytes;
final List<String> options = <String>['--release']; final List<String> options = <String>['--release'];
setLocalEngineOptionIfNecessary(options);
final Map<String, dynamic> metrics = <String, dynamic>{}; final Map<String, dynamic> metrics = <String, dynamic>{};
switch (deviceOperatingSystem) { switch (deviceOperatingSystem) {
...@@ -405,7 +403,6 @@ class CompileTest { ...@@ -405,7 +403,6 @@ class CompileTest {
await flutter('clean'); await flutter('clean');
final Stopwatch watch = Stopwatch(); final Stopwatch watch = Stopwatch();
final List<String> options = <String>['--debug']; final List<String> options = <String>['--debug'];
setLocalEngineOptionIfNecessary(options);
switch (deviceOperatingSystem) { switch (deviceOperatingSystem) {
case DeviceOperatingSystem.ios: case DeviceOperatingSystem.ios:
options.insert(0, 'ios'); options.insert(0, 'ios');
......
...@@ -19,12 +19,11 @@ TaskFunction createRunWithoutLeakTest(dynamic dir) { ...@@ -19,12 +19,11 @@ TaskFunction createRunWithoutLeakTest(dynamic dir) {
final List<String> options = <String>[ final List<String> options = <String>[
'-d', device.deviceId, '--verbose', '-d', device.deviceId, '--verbose',
]; ];
setLocalEngineOptionIfNecessary(options);
int exitCode; int exitCode;
await inDirectory<void>(dir, () async { await inDirectory<void>(dir, () async {
final Process process = await startProcess( final Process process = await startProcess(
path.join(flutterDirectory.path, 'bin', 'flutter'), path.join(flutterDirectory.path, 'bin', 'flutter'),
<String>['run', ...options], flutterCommandArgs('run', options),
environment: null, environment: null,
); );
final Completer<void> stdoutDone = Completer<void>(); final Completer<void> stdoutDone = Completer<void>();
......
...@@ -19,7 +19,6 @@ TaskFunction createWebDevModeTest() { ...@@ -19,7 +19,6 @@ TaskFunction createWebDevModeTest() {
final List<String> options = <String>[ final List<String> options = <String>[
'--hot', '-d', 'chrome', '--verbose', '--resident', '--target=lib/main.dart', '--hot', '-d', 'chrome', '--verbose', '--resident', '--target=lib/main.dart',
]; ];
setLocalEngineOptionIfNecessary(options);
int hotRestartCount = 0; int hotRestartCount = 0;
await inDirectory<void>(flutterDirectory, () async { await inDirectory<void>(flutterDirectory, () async {
rmTree(_editedFlutterGalleryDir); rmTree(_editedFlutterGalleryDir);
...@@ -37,7 +36,7 @@ TaskFunction createWebDevModeTest() { ...@@ -37,7 +36,7 @@ TaskFunction createWebDevModeTest() {
await packagesGet.exitCode; await packagesGet.exitCode;
final Process process = await startProcess( final Process process = await startProcess(
path.join(flutterDirectory.path, 'bin', 'flutter'), path.join(flutterDirectory.path, 'bin', 'flutter'),
<String>['run', ...options], flutterCommandArgs('run', options),
environment: <String, String>{ environment: <String, String>{
'FLUTTER_WEB': 'true', 'FLUTTER_WEB': 'true',
}, },
...@@ -96,7 +95,7 @@ TaskFunction createWebDevModeTest() { ...@@ -96,7 +95,7 @@ TaskFunction createWebDevModeTest() {
{ {
final Process process = await startProcess( final Process process = await startProcess(
path.join(flutterDirectory.path, 'bin', 'flutter'), path.join(flutterDirectory.path, 'bin', 'flutter'),
<String>['run', ...options], flutterCommandArgs('run', options),
environment: <String, String>{ environment: <String, String>{
'FLUTTER_WEB': 'true', 'FLUTTER_WEB': 'true',
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment