devicelab: replace the FLUTTER_ENGINE environment variable with the new local engine flags (#36969)
This commit is contained in:
@@ -13,8 +13,6 @@ import 'package:path/path.dart' as path;
|
||||
import 'package:process/process.dart';
|
||||
import 'package:stack_trace/stack_trace.dart';
|
||||
|
||||
import 'adb.dart';
|
||||
|
||||
/// Virtual current working directory, which affect functions, such as [exec].
|
||||
String cwd = Directory.current.path;
|
||||
|
||||
@@ -347,17 +345,21 @@ Future<String> eval(
|
||||
return output.toString().trimRight();
|
||||
}
|
||||
|
||||
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 = <String>[
|
||||
List<String> flutterCommandArgs(String command, List<String> options) {
|
||||
return <String>[
|
||||
command,
|
||||
if (localEngine != null) ...<String>['--local-engine', localEngine],
|
||||
if (localEngineSrcPath != null) ...<String>['--local-engine-src-path', localEngineSrcPath],
|
||||
...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,
|
||||
canFail: canFail, environment: environment);
|
||||
}
|
||||
@@ -369,12 +371,7 @@ Future<String> evalFlutter(String command, {
|
||||
Map<String, String> environment,
|
||||
StringBuffer stderr, // if not null, the stderr will be written here.
|
||||
}) {
|
||||
final List<String> args = <String>[
|
||||
command,
|
||||
if (localEngine != null) ...<String>['--local-engine', localEngine],
|
||||
if (localEngineSrcPath != null) ...<String>['--local-engine-src-path', localEngineSrcPath],
|
||||
...options,
|
||||
];
|
||||
final List<String> args = flutterCommandArgs(command, options);
|
||||
return eval(path.join(flutterDirectory.path, 'bin', 'flutter'), args,
|
||||
canFail: canFail, environment: environment, stderr: stderr);
|
||||
}
|
||||
@@ -593,39 +590,6 @@ Uri parseServiceUri(String line, {
|
||||
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].
|
||||
void checkFileExists(String file) {
|
||||
if (!exists(File(file))) {
|
||||
|
||||
Reference in New Issue
Block a user