diff --git a/dev/devicelab/bin/run.dart b/dev/devicelab/bin/run.dart index 9ec6b077e38..4cd54b5a6c1 100644 --- a/dev/devicelab/bin/run.dart +++ b/dev/devicelab/bin/run.dart @@ -54,10 +54,17 @@ Future main(List rawArgs) async { } final bool silent = args['silent']; + final String localEngine = args['local-engine']; + final String localEngineSrcPath = args['local-engine-src-path']; for (String taskName in _taskNames) { section('Running task "$taskName"'); - final Map result = await runTask(taskName, silent: silent); + final Map result = await runTask( + taskName, + silent: silent, + localEngine: localEngine, + localEngineSrcPath: localEngineSrcPath, + ); if (!result['success']) exitCode = 1; @@ -123,6 +130,19 @@ final ArgParser _argParser = ArgParser() 'silent', negatable: true, defaultsTo: false, + ) + ..addOption( + 'local-engine', + help: 'Name of a build output within the engine out directory, if you are ' + 'building Flutter locally. Use this to select a specific version of ' + 'the engine if you have built multiple engine targets. This path is ' + 'relative to --local-engine-src-path/out.', + ) + ..addOption( + 'local-engine-src-path', + help: 'Path to your engine src directory, if you are building Flutter ' + 'locally. Defaults to \$FLUTTER_ENGINE if set, or tries to guess at ' + 'the location based on the value of the --flutter-root option.', ); bool _listsEqual(List a, List b) { diff --git a/dev/devicelab/lib/framework/runner.dart b/dev/devicelab/lib/framework/runner.dart index e6a0fa45c21..dfaeb7f0e5a 100644 --- a/dev/devicelab/lib/framework/runner.dart +++ b/dev/devicelab/lib/framework/runner.dart @@ -23,7 +23,12 @@ const Duration taskTimeoutWithGracePeriod = Duration(minutes: 26); /// /// Running the task in [silent] mode will suppress standard output from task /// processes and only print standard errors. -Future> runTask(String taskName, { bool silent = false }) async { +Future> runTask( + String taskName, { + bool silent = false, + String localEngine, + String localEngineSrcPath, +}) async { final String taskExecutable = 'bin/tasks/$taskName.dart'; if (!file(taskExecutable).existsSync()) @@ -32,6 +37,8 @@ Future> runTask(String taskName, { bool silent = false }) a final Process runner = await startProcess(dartBin, [ '--enable-vm-service=0', // zero causes the system to choose a free port '--no-pause-isolates-on-exit', + if (localEngine != null) '-DlocalEngine=$localEngine', + if (localEngineSrcPath != null) '-DlocalEngineSrcPath=$localEngineSrcPath', taskExecutable, ]); diff --git a/dev/devicelab/lib/framework/utils.dart b/dev/devicelab/lib/framework/utils.dart index 1b0f2937027..42613a35481 100644 --- a/dev/devicelab/lib/framework/utils.dart +++ b/dev/devicelab/lib/framework/utils.dart @@ -18,6 +18,13 @@ import 'adb.dart'; /// Virtual current working directory, which affect functions, such as [exec]. String cwd = Directory.current.path; +/// The local engine to use for [flutter] and [evalFlutter], if any. +String get localEngine => const String.fromEnvironment('localEngine'); + +/// The local engine source path to use if a local engine is used for [flutter] +/// and [evalFlutter]. +String get localEngineSrcPath => const String.fromEnvironment('localEngineSrcPath'); + List _runningProcesses = []; ProcessManager _processManager = const LocalProcessManager(); @@ -339,7 +346,12 @@ Future flutter(String command, { bool canFail = false, // as in, whether failures are ok. False means that they are fatal. Map environment, }) { - final List args = [command]..addAll(options); + final List args = [ + command, + if (localEngine != null) ...['--local-engine', localEngine], + if (localEngineSrcPath != null) ...['--local-engine-src-path', localEngineSrcPath], + ...options, + ]; return exec(path.join(flutterDirectory.path, 'bin', 'flutter'), args, canFail: canFail, environment: environment); } @@ -351,7 +363,12 @@ Future evalFlutter(String command, { Map environment, StringBuffer stderr, // if not null, the stderr will be written here. }) { - final List args = [command]..addAll(options); + final List args = [ + command, + if (localEngine != null) ...['--local-engine', localEngine], + if (localEngineSrcPath != null) ...['--local-engine-src-path', localEngineSrcPath], + ...options, + ]; return eval(path.join(flutterDirectory.path, 'bin', 'flutter'), args, canFail: canFail, environment: environment, stderr: stderr); } diff --git a/dev/devicelab/pubspec.yaml b/dev/devicelab/pubspec.yaml index 2b1e441f3f2..2f56149c83c 100644 --- a/dev/devicelab/pubspec.yaml +++ b/dev/devicelab/pubspec.yaml @@ -5,7 +5,7 @@ homepage: https://github.com/flutter/flutter environment: # The pub client defaults to an <2.0.0 sdk constraint which we need to explicitly overwrite. - sdk: ">=2.0.0-dev.68.0 <3.0.0" + sdk: ">=2.2.2 <3.0.0" dependencies: args: 1.5.2