Skip to content

Refactor createDebuggingOptions and option registrations to OptionDescriptor - #192307

Merged
auto-submit[bot] merged 7 commits into
flutter:masterfrom
kevmoo:create-debugging-options
Sep 8, 2026
Merged

auto-submit[bot] merged 7 commits into
flutter:masterfrom
kevmoo:create-debugging-options

Conversation

@kevmoo

@kevmoo kevmoo commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Migrates createDebuggingOptions() in RunCommandBase (lib/src/commands/run.dart) and associated option registration helpers in FlutterCommand (lib/src/runner/flutter_command.dart) to typed OptionDescriptor instances, continuing the CLI argument architecture modernization started in #191018, #191510, and #191760.

Summary of Changes

  • Typed Debugging Option Descriptors (DebuggingOptionDescriptors in common_options.dart):
    • Defined 35+ strongly-typed descriptors covering engine flags (enableImpeller, enableFlutterGpu, enableVulkanValidation, enableEmbedderApi, enableHcpp), tracing/profiling (traceStartup, traceSystrace, traceToFile, endlessTraceBuffer, profileMicrotasks, traceSkia, traceAllowlist, traceSkiaAllowlist, enableDartProfiling, profileStartup, cacheStartupProfile, verboseSystemLogs, purgePersistentCache), VM service/DevTools/DDS (dds, ddsPort, disableDds, enableDevTools, devToolsServerAddress, vmserviceOutFile, disableServiceAuthCodes, disableServiceOriginCheck, startPaused, dartFlags, ipv6), and runner configuration (route, enableSoftwareRendering, skiaDeterministicRendering, dartEntrypointArgs, uninstallFirst, iosProfileDebugger, useTestFonts, adbLogFiltering, testFlag).
  • Web Server & Debugging Descriptors (WebOptions in web_options.dart):
    • Added typed descriptors for webHeader, webHostname, webPort, webTlsCertPath, webTlsCertKeyPath, webServerDebugProtocol, webServerDebugBackendProtocol, webServerDebugInjectedClientProtocol, webAllowExposeUrl, webRunHeadless, webBrowserDebugPort, webEnableExpressionEvaluation, webLaunchUrl, webBrowserFlags, and crossOriginIsolation.
  • ArgParserDescriptorExtension & Automatic Expando Registry (option_descriptor.dart):
    • Added addDescriptor / addDescriptors extension methods on ArgParser for concise option registration.
    • Replaced explicit Map<String, OptionDescriptor>? registry parameter plumbing across OptionDescriptor.addTo(), OptionBundle.register(), and FlutterCommand._optionRegistry with an internal Expando<Map<String, OptionDescriptor<Object?>>> on ArgParser, ensuring automatic diamond-bundle de-duplication and conflict detection across all registration paths.
  • Tri-State bool? Semantics:
    • Used NullableFlagOptionDescriptor (defaultsTo: null) for flags whose omitted state is semantically distinct from false (enable-impeller, enable-flutter-gpu, enable-hcpp, cross-origin-isolation, ios-profile-debugger), allowing getValue(...) to preserve bool? without manual string lookups.
  • Eliminated Untyped Lookups in createDebuggingOptions():
    • Replaced 35+ untyped argParser.options.containsKey('...'), boolArg('...'), stringArg('...'), and stringsArg('...') lookups in RunCommandBase.createDebuggingOptions(), webDevServerConfigCore(), and FlutterCommand helpers (usesWebOptions, addDdsOptions, addDevToolsOptions, explicitEnableHcpp, ddsPort, devToolsServerAddress) with type-safe getValue(...), wasParsed(...), and hasOption(...) calls.

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • All existing and new tests are passing.

@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Sep 4, 2026
@kevmoo
kevmoo marked this pull request as ready for review September 4, 2026 19:30

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors command-line option registration in flutter_tools by migrating inline option and flag definitions to type-safe OptionDescriptor classes, specifically introducing DebuggingOptionDescriptors and expanding WebOptions. It simplifies the OptionBundle registration process by managing descriptor registries per ArgParser using an Expando instead of passing an explicit registry map. Feedback suggests utilizing existing const option descriptors (startPausedOption and devToolsServerAddressOption) instead of calling helper methods that instantiate new descriptors on each invocation.

Comment thread packages/flutter_tools/lib/src/commands/run.dart Outdated
Comment thread packages/flutter_tools/lib/src/runner/flutter_command.dart Outdated
Comment thread packages/flutter_tools/lib/src/web/web_options.dart
Comment thread packages/flutter_tools/lib/src/runner/options/option_descriptor.dart Outdated
@kevmoo kevmoo added the CICD Run CI/CD label Sep 5, 2026
bkonyi
bkonyi previously approved these changes Sep 8, 2026

@bkonyi bkonyi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kevmoo kevmoo added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 8, 2026

@harryterkelsen harryterkelsen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 8, 2026
@auto-submit

auto-submit Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/192307, because - The status or check suite Dashboard Checks has failed. Please fix the issues identified (or deflake) before re-applying this label.

@kevmoo kevmoo added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 8, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Sep 8, 2026
Merged via the queue into flutter:master with commit a19bd3e Sep 8, 2026
29 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 8, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Sep 9, 2026
flutter/flutter@b444e78...63b9518

2026-09-09 [email protected] Roll Packages from 9af9c60 to 36e088a (24 revisions) (flutter/flutter#192485)
2026-09-09 [email protected] Re-add Xcode and OpenJDK dependencies to macOS wasm local_engine builders (flutter/flutter#192238)
2026-09-09 [email protected] Roll Dart SDK from 77094991d1c1 to 4be1b711b4ba (5 revisions) (flutter/flutter#192453)
2026-09-09 [email protected] [material] Use super parameters in more places (flutter/flutter#192149)
2026-09-09 [email protected] [cupertino] Use super parameters in more places (flutter/flutter#192148)
2026-09-09 [email protected] [flutter_tools] Gracefully handle EROFS and write-protected file system errors (flutter/flutter#192431)
2026-09-09 [email protected] [tool] Migrate BuildIOSCommand and BuildIOSArchiveCommand to modular dependency injection (flutter/flutter#192250)
2026-09-09 [email protected] Replace more enum instances comparison to use `equality ==` instead of `identical` and update related tests (flutter/flutter#192229)
2026-09-09 [email protected] [web] Support local screenshot and golden testing in felt test (flutter/flutter#191318)
2026-09-09 [email protected] [tool] Migrate DaemonCommand and DebugAdapterCommand to modular dependency injection (flutter/flutter#190793)
2026-09-09 [email protected] [web] Support local golden testing in flutter test (flutter/flutter#191386)
2026-09-09 [email protected] [flutter_tools] Ignore widget previews outside lib/ during LSP code generation (flutter/flutter#192326)
2026-09-09 [email protected] [flutter_tools] Read package_config.json asynchronously in loadPackageConfigWithLogging (flutter/flutter#192443)
2026-09-08 [email protected] Add precacheTestImage to flutter_test and unskip web image tests (flutter/flutter#191435)
2026-09-08 [email protected] et: Fix compile_commands.json post-processing (flutter/flutter#192395)
2026-09-08 [email protected] Refactor createDebuggingOptions and option registrations to OptionDescriptor (flutter/flutter#192307)
2026-09-08 [email protected] [flutter_tools] Fix test separation between `VersionFreshnessValidator` and `FlutterVersion.checkFlutterVersionFreshness` (flutter/flutter#191593)
2026-09-08 [email protected] [tool] Migrate EmulatorsCommand to modular dependency injection (flutter/flutter#190769)
2026-09-08 [email protected] [tool] Migrate Desktop build subcommands and toolchain to modular dependency injection (flutter/flutter#190781)
2026-09-08 [email protected] [tool] Migrate Tooling and Analysis commands to modular dependency injection (flutter/flutter#190788)
2026-09-08 [email protected] Skip KGP version validation for AGP built-in Kotlin (flutter/flutter#192206)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
victorsanni pushed a commit to victorsanni/packages that referenced this pull request Sep 9, 2026
…r#12814)

flutter/flutter@b444e78...63b9518

2026-09-09 [email protected] Roll Packages from 9af9c60 to 36e088a (24 revisions) (flutter/flutter#192485)
2026-09-09 [email protected] Re-add Xcode and OpenJDK dependencies to macOS wasm local_engine builders (flutter/flutter#192238)
2026-09-09 [email protected] Roll Dart SDK from 77094991d1c1 to 4be1b711b4ba (5 revisions) (flutter/flutter#192453)
2026-09-09 [email protected] [material] Use super parameters in more places (flutter/flutter#192149)
2026-09-09 [email protected] [cupertino] Use super parameters in more places (flutter/flutter#192148)
2026-09-09 [email protected] [flutter_tools] Gracefully handle EROFS and write-protected file system errors (flutter/flutter#192431)
2026-09-09 [email protected] [tool] Migrate BuildIOSCommand and BuildIOSArchiveCommand to modular dependency injection (flutter/flutter#192250)
2026-09-09 [email protected] Replace more enum instances comparison to use `equality ==` instead of `identical` and update related tests (flutter/flutter#192229)
2026-09-09 [email protected] [web] Support local screenshot and golden testing in felt test (flutter/flutter#191318)
2026-09-09 [email protected] [tool] Migrate DaemonCommand and DebugAdapterCommand to modular dependency injection (flutter/flutter#190793)
2026-09-09 [email protected] [web] Support local golden testing in flutter test (flutter/flutter#191386)
2026-09-09 [email protected] [flutter_tools] Ignore widget previews outside lib/ during LSP code generation (flutter/flutter#192326)
2026-09-09 [email protected] [flutter_tools] Read package_config.json asynchronously in loadPackageConfigWithLogging (flutter/flutter#192443)
2026-09-08 [email protected] Add precacheTestImage to flutter_test and unskip web image tests (flutter/flutter#191435)
2026-09-08 [email protected] et: Fix compile_commands.json post-processing (flutter/flutter#192395)
2026-09-08 [email protected] Refactor createDebuggingOptions and option registrations to OptionDescriptor (flutter/flutter#192307)
2026-09-08 [email protected] [flutter_tools] Fix test separation between `VersionFreshnessValidator` and `FlutterVersion.checkFlutterVersionFreshness` (flutter/flutter#191593)
2026-09-08 [email protected] [tool] Migrate EmulatorsCommand to modular dependency injection (flutter/flutter#190769)
2026-09-08 [email protected] [tool] Migrate Desktop build subcommands and toolchain to modular dependency injection (flutter/flutter#190781)
2026-09-08 [email protected] [tool] Migrate Tooling and Analysis commands to modular dependency injection (flutter/flutter#190788)
2026-09-08 [email protected] Skip KGP version validation for AGP built-in Kotlin (flutter/flutter#192206)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
victorsanni pushed a commit to victorsanni/packages that referenced this pull request Sep 9, 2026
…r#12814)

flutter/flutter@b444e78...63b9518

2026-09-09 [email protected] Roll Packages from 9af9c60 to 36e088a (24 revisions) (flutter/flutter#192485)
2026-09-09 [email protected] Re-add Xcode and OpenJDK dependencies to macOS wasm local_engine builders (flutter/flutter#192238)
2026-09-09 [email protected] Roll Dart SDK from 77094991d1c1 to 4be1b711b4ba (5 revisions) (flutter/flutter#192453)
2026-09-09 [email protected] [material] Use super parameters in more places (flutter/flutter#192149)
2026-09-09 [email protected] [cupertino] Use super parameters in more places (flutter/flutter#192148)
2026-09-09 [email protected] [flutter_tools] Gracefully handle EROFS and write-protected file system errors (flutter/flutter#192431)
2026-09-09 [email protected] [tool] Migrate BuildIOSCommand and BuildIOSArchiveCommand to modular dependency injection (flutter/flutter#192250)
2026-09-09 [email protected] Replace more enum instances comparison to use `equality ==` instead of `identical` and update related tests (flutter/flutter#192229)
2026-09-09 [email protected] [web] Support local screenshot and golden testing in felt test (flutter/flutter#191318)
2026-09-09 [email protected] [tool] Migrate DaemonCommand and DebugAdapterCommand to modular dependency injection (flutter/flutter#190793)
2026-09-09 [email protected] [web] Support local golden testing in flutter test (flutter/flutter#191386)
2026-09-09 [email protected] [flutter_tools] Ignore widget previews outside lib/ during LSP code generation (flutter/flutter#192326)
2026-09-09 [email protected] [flutter_tools] Read package_config.json asynchronously in loadPackageConfigWithLogging (flutter/flutter#192443)
2026-09-08 [email protected] Add precacheTestImage to flutter_test and unskip web image tests (flutter/flutter#191435)
2026-09-08 [email protected] et: Fix compile_commands.json post-processing (flutter/flutter#192395)
2026-09-08 [email protected] Refactor createDebuggingOptions and option registrations to OptionDescriptor (flutter/flutter#192307)
2026-09-08 [email protected] [flutter_tools] Fix test separation between `VersionFreshnessValidator` and `FlutterVersion.checkFlutterVersionFreshness` (flutter/flutter#191593)
2026-09-08 [email protected] [tool] Migrate EmulatorsCommand to modular dependency injection (flutter/flutter#190769)
2026-09-08 [email protected] [tool] Migrate Desktop build subcommands and toolchain to modular dependency injection (flutter/flutter#190781)
2026-09-08 [email protected] [tool] Migrate Tooling and Analysis commands to modular dependency injection (flutter/flutter#190788)
2026-09-08 [email protected] Skip KGP version validation for AGP built-in Kotlin (flutter/flutter#192206)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
@kevmoo
kevmoo deleted the create-debugging-options branch September 22, 2026 05:04
flutter-zl pushed a commit to flutter-zl/flutter that referenced this pull request Oct 8, 2026
…lutter#193323)

Migrate `BuildLinuxCommand` (`build linux`) and `BuildWindowsCommand`
(`build windows`) to typed `OptionDescriptor`s and `OptionBundle`s
(following flutter#191018, flutter#191510, flutter#191760, flutter#192307, flutter#192455, flutter#192524, and
flutter#192818):

- Add `DesktopBuildOptionsBundle` in `common_options.dart`,
encapsulating `CommonBuildOptionsBundle`, `BuildModeOptionsBundle`,
`DartCompileOptionsBundle`, `BuildInfoOptions.flavor`, `splitDebugInfo`,
`obfuscate`, `extraFrontEndOptions`, `extraGenSnapshotOptions`,
`performanceMeasurementFile`, `analyzeSize`, `codeSizeDirectory`,
`trackWidgetCreation`, and `configOnly`.
- Migrate `BuildLinuxCommand` (`build_linux.dart`) to
`DesktopBuildOptionsBundle`,
`DefaultedEnumOptionDescriptor<TargetPlatform>`
(`_targetPlatformOption`), and `DefaultedStringOptionDescriptor`
(`_targetSysroot`), replacing untyped `boolArg('config-only')`,
`stringArg('target-platform')!`, and `stringArg('target-sysroot')!`
queries.
- Migrate `BuildWindowsCommand` (`build_windows.dart`) to
`DesktopBuildOptionsBundle` and
`getValue(DesktopBuildOptionsBundle.configOnly)`.
- Delete the obsolete `FlutterCommand.addCommonDesktopBuildOptions`
helper method from `flutter_command.dart` (no remaining callers in
`flutter_tools`).

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [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].
- [ ] 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants