Skip to content

Commit 708c986

Browse files
Add ability to pass flags to et run (flutter#185109)
Adds `--flutter-flags` flag to `et run` that allows you to pass command line flags to the `flutter run` call it makes under the hood. For example, `et run --flutter-flags="--trace-to-file=trace.txt --verbose-system-logs"`. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [AI contribution guidelines]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 021dae4 commit 708c986

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

engine/src/flutter/tools/engine_tool/lib/src/commands/run_command.dart

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ final class RunCommand extends CommandBase {
2929
@visibleForTesting FlutterTool? flutterTool,
3030
}) {
3131
builds = BuildPlan.configureArgParser(argParser, environment, configs: configs, help: help);
32+
argParser.addMultiOption(
33+
'flutter-flags',
34+
help:
35+
'Arguments to pass to the "flutter run" command. '
36+
'This can be specified multiple times. For multiple flags, '
37+
'separate them by spaces, e.g. '
38+
'--flutter-flags="--profile --verbose".',
39+
splitCommas: false,
40+
);
3241
_flutterTool = flutterTool ?? FlutterTool.fromEnvironment(environment);
3342
}
3443

@@ -169,9 +178,16 @@ See `flutter run --help` for a listing
169178
mangledBuildName,
170179
'--local-engine-host',
171180
mangledHostBuildName,
172-
...argResults!.rest,
173181
];
174182

183+
// Add flags passed to --flutter-flags.
184+
final flutterFlags = argResults!['flutter-flags'] as List<String>;
185+
for (final flagGroup in flutterFlags) {
186+
command.addAll(flagGroup.split(' ').where((String s) => s.isNotEmpty));
187+
}
188+
189+
command.addAll(argResults!.rest);
190+
175191
// TODO(johnmccutchan): Be smart and if the user requested a profile
176192
// config, add the '--profile' flag when invoking flutter run.
177193
final ProcessRunnerResult result = await environment.processRunner.runProcess(

engine/src/flutter/tools/engine_tool/test/commands/run_command_test.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,23 @@ void main() {
369369
);
370370
});
371371

372+
test('delegates to `flutter run` with --flutter-flags', () async {
373+
await et.run([
374+
'run',
375+
'--config=android_debug_arm64',
376+
'--flutter-flags=--foo',
377+
'--flutter-flags=--bar=baz,foobar',
378+
'--flutter-flags=--flag1 --flag2',
379+
]);
380+
381+
expect(
382+
commandsRun,
383+
containsAllInOrder([
384+
containsAllInOrder(['flutter', 'run', '--foo', '--bar=baz,foobar', '--flag1', '--flag2']),
385+
]),
386+
);
387+
});
388+
372389
group('delegates to `flutter run` in mode', () {
373390
for (final mode in const ['debug', 'profile', 'release']) {
374391
test('$mode mode', () async {

0 commit comments

Comments
 (0)