Skip to content

[flutter_tools] Add BuildService and flutter build support for tool extensions - #193748

Merged
auto-submit[bot] merged 9 commits into
flutter:masterfrom
bkonyi:ft-ext-step07a-build-target-slice
Oct 8, 2026
Merged

auto-submit[bot] merged 9 commits into
flutter:masterfrom
bkonyi:ft-ext-step07a-build-target-slice

Conversation

@bkonyi

@bkonyi bkonyi commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Adds BuildService, ExtensionBuildTarget, ExtensionBuildResult, and ExtensionBuildManager to allow tool extensions to register custom flutter build <target> subcommands and execute builds over RPC.

Part of #190692

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].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

…xtensions

Adds `BuildService`, `ExtensionBuildTarget`, `ExtensionBuildResult`, and `ExtensionBuildManager` to allow tool extensions to register custom `flutter build <target>` subcommands and execute builds over RPC.

Part of flutter#190692
@bkonyi
bkonyi requested a review from a team as a code owner October 3, 2026 02:27
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Oct 3, 2026
@github-actions github-actions Bot added tool Affects the "flutter" command-line tool. See also t: labels. team-linux Owned by the Linux platform team labels Oct 3, 2026

@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 introduces support for custom build targets in Flutter tool extensions by adding an ExtensionBuildManager that queries active extensions for build targets and dynamically registers them as subcommands under flutter build. It also defines the core data models and service interfaces in flutter_tools_core and flutter_tools_extension, along with a prototype Linux implementation and integration tests. Feedback focuses on improving robustness and efficiency, including parallelizing target queries to prevent blocking, handling initialization errors gracefully during target retrieval and build execution, using collection-if for cleaner serialization of build results, and adding trace logging when custom subcommands conflict with existing ones.

bkonyi added 3 commits October 5, 2026 18:47
…ldService

- Simplify JSON-RPC map matching to use `Map<String, Object?>` directly in `ExtensionBuildManager.build` and `ExtensionBuildTarget.listFromJson`.
- Wrap `_extensionManager.ensureInitialized()` in `try-catch` in `ExtensionBuildManager` and parallelize `build.getBuildTargets` RPC queries across connections via `Future.wait`.
- Skip targets with empty names and log a trace message when skipping conflicting build subcommands.
- Add Dartdoc comments to `ExtensionBuildSubCommand`.
…coverage for BuildService

- Destructure `toolDependencies` in `executable.dart` and pass `toolDependencies.featureFlags` instead of the ambient `featureFlags` getter.
- Return per-connection target lists from `Future.wait` in `ExtensionBuildManager.getBuildTargets` and iterate deterministically in connection order, skipping duplicate target names.
- Use `_logger.printTrace` for initialization and RPC diagnostics in `ExtensionBuildManager` to avoid duplicate error output on `throwToolExit`.
- Expand hermetic and RPC dispatch unit tests in `tool_extensions_build_test.dart` and `linux_build_test.dart`.
…se record in getBuildTargets

- Move `initializeDynamicOptions()` from `ExtensionArgParserMixin` to `FlutterCommand` and remove `with ExtensionArgParserMixin` from `BuildCommand`.
- Return `(ExtensionConnection, List<ExtensionBuildTarget>)` records from `Future.wait` in `ExtensionBuildManager.getBuildTargets` and destructure in a `for-in` loop.
@bkonyi
bkonyi requested a review from loic-sharma October 6, 2026 18:14

@loic-sharma loic-sharma left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall this looks good to me 👍

bkonyi added 2 commits October 7, 2026 11:01
…nd remove build timeout

- Construct `ExtensionBuildManager` in `ToolDependencies.bootstrap` and pass `toolDependencies.extensionBuildManager` to `BuildCommand` in `generateCommands`.

- Make `ExtensionConnection.sendRequest` accept a nullable `Duration? timeout` and pass `null` from `ExtensionBuildManager.build` so long-running custom builds do not time out.
loic-sharma
loic-sharma previously approved these changes Oct 7, 2026

@loic-sharma loic-sharma left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM modulo nits

@bkonyi
bkonyi requested a review from a team as a code owner October 7, 2026 18:56
@github-actions github-actions Bot added the team-ios Owned by iOS platform team label Oct 7, 2026
…tests

Adds `extensionBuildManager` to `FakeToolDependencies` in `args_test.dart` and `test/src/fakes.dart` so `generateCommands` does not throw `UnimplementedError: extensionBuildManager`.
@bkonyi
bkonyi requested a review from loic-sharma October 7, 2026 19:20

@loic-sharma loic-sharma left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks great!

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 7, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Oct 8, 2026
Merged via the queue into flutter:master with commit a8cb261 Oct 8, 2026
34 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 8, 2026
suryaKommana2662 pushed a commit to suryaKommana2662/flutter that referenced this pull request Oct 29, 2026
…xtensions (flutter#193748)

Adds `BuildService`, `ExtensionBuildTarget`, `ExtensionBuildResult`, and
`ExtensionBuildManager` to allow tool extensions to register custom
`flutter build <target>` subcommands and execute builds over RPC.

Part of flutter#190692

## 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].
- [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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD team-ios Owned by iOS platform team team-linux Owned by the Linux platform team tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants