Skip to content

[flutter_tools] Share Depfile in flutter_tools_core and make BuildTarget.targetPlatform optional - #194965

Merged
auto-submit[bot] merged 47 commits into
flutter:masterfrom
bkonyi:ft-ext-build-depfile-and-optional-platform
Nov 25, 2026
Merged

auto-submit[bot] merged 47 commits into
flutter:masterfrom
bkonyi:ft-ext-build-depfile-and-optional-platform

Conversation

@bkonyi

@bkonyi bkonyi commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Description

  • Adds pure-Dart Depfile (inputs, outputs, parse, and format) to package:flutter_tools_core and delegates DepfileService parsing/formatting in package:flutter_tools to core.Depfile (with allowMalformed support on DepfileService.parse).
  • Adds depfiles to ExtensionAssembleTarget, AssembleTarget, and ExtensionTarget, normalizing extension-produced .d files in ExtensionTarget.build and logging an error (while disabling incremental build caching instead of failing the build) if a declared depfile is missing or malformed.
  • Makes ExtensionBuildTarget.targetPlatform and BuildTarget.targetPlatform optional (String?) as a stopgap for platform-agnostic custom build targets until [flutter_tools] Support target-platform agnostic BuildTargets in tool extensions #194810.

Part of #190755
Part of #190752
Part of #194810

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.

bkonyi added 28 commits October 8, 2026 02:48
… targets

Extends `BuildService` and `package:flutter_tools_core` to support `flutter assemble` targets contributed by tool extensions (`ExtensionAssembleTarget`, `ExtensionTarget`, `ExtensionBuildContext`, `Source`, `Artifact`, `HostArtifact`, and `Target`), allowing extension targets to participate in the build graph alongside built-in targets.
Keep host Source and Target untouched in flutter_tools and convert extension Sources inside ExtensionAssembleTarget, reverting changes to built-in targets and Source.fromProject.
…le integration

- Prefix extension source and artifact types (`ExtensionSource`, `ExtensionArtifact`, `ExtensionHostArtifact`) and make `ExtensionSource` a sealed class.
- Keep `BuildMode` in `flutter_tools_core/lib/src/build.dart` and replace `SimpleTarget` with `BuiltInTargets` string constants.
- Revert host `build_system.dart` changes and rely on `-o` for `flutter assemble` output directories.
- Lazily query extension build targets in `AssembleCommand` only when a requested target is not built in, and remove duplicate Linux target entries.
- Trim AOT prototype targets and fix error handling and output draining in `flutter_tools_extension_linux_prototype`.
…rgetArtifacts

- Ignore `Exception` from `TargetPlatform.fromName(target.targetPlatform)` in `resolveExtensionTargetArtifacts` so custom embedder target platforms work without throwing `ToolExit`.
- Use `continue;` instead of `break;` on `ExtensionPatternSource` in `resolveExtensionTargetArtifacts`.
- Update unit and hermetic tests in `extension_test.dart` and `tool_extensions_build_test.dart`.
…ension PR reviews

- Prefix failure messages in `ExtensionAssembleTarget.build` with the target name and handle empty `errorMessage`.
- Remove `export 'src/build.dart';` from `flutter_tools_extension_linux_prototype.dart` so only `linuxExtensionEntryPoint` is exported.
- Expand Dartdoc on `targetPlatform`, `outputDir`, and `ExtensionSource.pattern`, and include all fields in `ExtensionBuildTarget.toString()`.
…lative extension outputDir

- Define `DependencyResolverCallback` for `ExtensionAssembleTarget._dependencyResolver`.
- Resolve relative `outputDir` paths against `projectDir` in `resolveExtensionOutputDir`.
…xpand source Dartdoc

- Replace top-level `k*Placeholder` constants with `BuiltInPlaceholders`.
- Add `See also:` cross-links on `ExtensionArtifact`, `ExtensionHostArtifact`, `ExtensionSource.pattern`, and `ExtensionPatternSource`.
- Expand Dartdoc on `ExtensionArtifactSource`, `ExtensionHostArtifactSource`, `ExtensionBuildTarget.outputs`, and `ExtensionBuildTarget.outputDir`.
…ild-remaining-slice

# Conflicts:
#	packages/flutter_tools/lib/src/commands/assemble.dart
…7c-assemble-host-integration

# Conflicts:
#	packages/flutter_tools/lib/src/build_system/targets/extension.dart
#	packages/flutter_tools/lib/src/commands/assemble.dart
#	packages/flutter_tools/lib/src/commands/build.dart
#	packages/flutter_tools/packages/flutter_tools_core/lib/src/build.dart
#	packages/flutter_tools/packages/flutter_tools_extension/lib/src/build.dart
#	packages/flutter_tools/test/commands.shard/hermetic/tool_extensions_build_test.dart
#	packages/flutter_tools/test/general.shard/build_system/targets/extension_test.dart
…ctory URIs

Removes legacy BuildService.getBuildTargets and BuildService.build methods in favor of buildTargets and assembleTargets, normalizes directory URIs in ExtensionBuildContext to end with a trailing slash, and asserts JSON-RPC INVALID_PARAMS (-32602) on both build and assemble handlers.
…7c-assemble-host-integration

# Conflicts:
#	packages/flutter_tools/test/commands.shard/hermetic/tool_extensions_build_test.dart
… ExtensionTarget

Passes the resolved targetPlatform from ExtensionAssembleTarget as the fallback platform when mapping ExtensionArtifactSource to Source.artifact in _toHostSource, and adds test coverage for unknown dependency resolution in AssembleCommand.
…7c-assemble-host-integration

# Conflicts:
#	packages/flutter_tools/lib/src/build_system/targets/extension.dart
#	packages/flutter_tools/lib/src/experimental/extension_build_manager.dart
#	packages/flutter_tools/test/commands.shard/hermetic/tool_extensions_build_test.dart
…UTPUT_DIR}

Makes outputDir required on ExtensionBuildTarget and BuildTarget, requires name, description, and outputDir during JSON deserialization, and updates resolveExtensionOutputDir to resolve {OUTPUT_DIR} from the configured build directory.

Part of flutter#190755
…7c-assemble-host-integration

# Conflicts:
#	packages/flutter_tools/test/commands.shard/hermetic/tool_extensions_build_test.dart
Updates extension build target tests to specify outputDir with {OUTPUT_DIR} and verifies resolveExtensionOutputDir placeholder validation.

Part of flutter#190755
…ild-remaining-slice

# Conflicts:
#	packages/flutter_tools/packages/flutter_tools_core/lib/src/build.dart
#	packages/flutter_tools/packages/flutter_tools_extension/lib/src/build.dart
#	packages/flutter_tools/packages/flutter_tools_extension_linux_prototype/test/linux_build_test.dart
…aDefines, and make BuildTarget.targetPlatform optional

Adds pure-Dart ExtensionDepfile parsing and formatting in package:flutter_tools_core (and delegates DepfileService in flutter_tools to it), adds depfiles support to ExtensionAssembleTarget/AssembleTarget/ExtensionTarget, adds ExtensionBuildResult.extraDefines to propagate dynamic build defines to downstream assemble targets, and makes ExtensionBuildTarget.targetPlatform and BuildTarget.targetPlatform optional for platform-agnostic build targets.

Part of flutter#190755

Part of flutter#190752

Fixes flutter#194810
@bkonyi bkonyi added the CICD Run CI/CD label Oct 21, 2026
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Oct 21, 2026
Addresses review feedback on PR flutter#194965:

- Renames `ExtensionDepfile` to `RawDepfile` since it is shared with built-in `DepfileService` targets.

- Moves extension-specific depfile documentation onto `ExtensionAssembleTarget.depfiles` and `AssembleTarget.depfiles`, and drops backslash-newline line continuation handling until needed.

- Clears stale declared depfiles before `ExtensionTarget.build` runs, and logs an error (deleting malformed depfiles to disable incremental build caching without failing the build) when a declared depfile is missing or invalid.

Part of flutter#190755
Part of flutter#190752
Part of flutter#194810
Addresses follow-up review feedback on PR flutter#194965:

- Renames `RawDepfile` to `Depfile` in `package:flutter_tools_core`.

- Replaces `DepfileService.resolve` with `DepfileService.parse(File file, {bool allowMalformed = true, Directory? baseDirectory})` and passes `allowMalformed: false` in `ExtensionTarget.build`.

- Clarifies in `ExtensionBuildTarget.targetPlatform` and `BuildTarget.targetPlatform` `TODO` comments that the property will be replaced by supported target platforms on `BuildTarget` and a selected target platform on `ExtensionBuildContext`.

Part of flutter#190755
Part of flutter#190752
Part of flutter#194810
Removes `ExtensionBuildResult.extraDefines` and the `Environment.defines` mutation in `ExtensionTarget.build`, since mutating `Environment.defines` while running assemble targets bypasses build-directory cache hashing and skipped incremental builds.

Part of flutter#190755
Part of flutter#190752
Part of flutter#194810
@bkonyi bkonyi changed the title [flutter_tools] Share DepfileService in flutter_tools_core, add extraDefines, and make BuildTarget.targetPlatform optional [flutter_tools] Share DepfileService in flutter_tools_core and make BuildTarget.targetPlatform optional Nov 16, 2026
@bkonyi
bkonyi requested a review from loic-sharma November 16, 2026 22:12
@bkonyi bkonyi added the t: extensions Issues related to Flutter Tools extensions label Nov 18, 2026
Updates the Dartdoc on `ExtensionAssembleTarget.depfiles` and `AssembleTarget.depfiles` to clarify that depfile names share the build directory, must be unique across built-in Flutter tool targets and all active extensions, and should be prefixed with the target platform or extension name (for example, `'linux_build.d'`) to avoid conflicts.

No new tests added because this is a documentation-only change.

Part of flutter#190755
Part of flutter#190752
Part of flutter#194810
@bkonyi
bkonyi requested a review from loic-sharma November 20, 2026 05:05
loic-sharma
loic-sharma previously approved these changes Nov 20, 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 questions

Clarifies in `ExtensionTarget.build` why declared depfiles are deleted before invoking an external extension target (unlike built-in targets) and updates `ExtensionAssembleTarget.depfiles` and `AssembleTarget.depfiles` Dartdoc to drop the `Depfile.parse` read-back reference and document pre-build host deletion.

No new tests are added because this commit only updates comments and Dartdoc; existing tests in `extension_test.dart` cover omitted depfiles on rebuild.

Part of flutter#190755

Part of flutter#190752
///
/// A valid depfile name must be non-empty, must not be `'.'` or `'..'`, and
/// must not contain `/` or `\` path separators.
static bool isValidDepfileName(String name) =>

@loic-sharma loic-sharma Nov 24, 2026 •

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.

Neon bubbled up we should reject : as 'C:foo.d' passed to buildDir.childFile(...) resolves outside buildDir. Feel free to fix this in a follow-up PR.

@loic-sharma loic-sharma changed the title [flutter_tools] Share DepfileService in flutter_tools_core and make BuildTarget.targetPlatform optional [flutter_tools] Share Depfile in flutter_tools_core and make BuildTarget.targetPlatform optional Nov 24, 2026
@loic-sharma

Copy link
Copy Markdown
Member

@bkonyi FYI I updated PR title to Depfile since we renamed the flutter_tools_core type.

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 25, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Nov 25, 2026
Merged via the queue into flutter:master with commit 4d52c1d Nov 25, 2026
22 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 25, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Nov 25, 2026
Roll Flutter from b75c5b30406a to 06f1c24345a2 (37 revisions)

flutter/flutter@b75c5b3...06f1c24

2026-11-25 [email protected] Roll Skia from a60d883b3fe3 to e84ecd98d9f2 (2 revisions) (flutter/flutter#197375)
2026-11-25 [email protected] Roll Skia from ca229e319550 to a60d883b3fe3 (4 revisions) (flutter/flutter#197371)
2026-11-25 [email protected] Roll Skia from 6f75212e5a23 to ca229e319550 (2 revisions) (flutter/flutter#197369)
2026-11-25 [email protected] Roll Skia from 75d95595f14e to 6f75212e5a23 (1 revision) (flutter/flutter#197364)
2026-11-25 [email protected] [Windows] Fix Korean 3-beolsik IME dropping space, digits and punctuation (flutter/flutter#194270)
2026-11-25 [email protected] [flutter_tools] Strip embedded credentials from repository URLs (flutter/flutter#197219)
2026-11-25 [email protected] [flutter_tools] Add structured extension.log notifications for tool extensions (flutter/flutter#196714)
2026-11-25 [email protected] [flutter_tools] Share Depfile in flutter_tools_core and make BuildTarget.targetPlatform optional (flutter/flutter#194965)
2026-11-25 [email protected] Reply null asynchronously to ignored web platform messages and unskip missing-asset tests (flutter/flutter#197267)
2026-11-25 [email protected] Roll Dart SDK from 87f515c52de9 to 5202130a51b8 (1 revision) (flutter/flutter#197363)
2026-11-25 [email protected] [web] Retain queued scene pictures via ContainerLayer render pinning (flutter/flutter#196748)
2026-11-25 [email protected] [flutter_tools] Include dependency manifests in copyAssets depfile (flutter/flutter#196596)
2026-11-25 [email protected] Print the Intel Mac deprecation warning on every command (flutter/flutter#194071)
2026-11-25 [email protected] Roll Skia from 243c0dc9f662 to 75d95595f14e (2 revisions) (flutter/flutter#197351)
2026-11-25 [email protected] iOS: Ignore platform messages after the engine is destroyed (flutter/flutter#197310)
2026-11-24 [email protected] Bump customer tests to pick up material_ui cache extent test updates (flutter/flutter#197266)
2026-11-24 [email protected] [flutter_tools] Use refreshed FlutterVersion for flutter doctor feature flags (flutter/flutter#196944)
2026-11-24 [email protected] [flutter_tools] Do not crash if buildXcodeProject temporary directory is deleted before cleanup (flutter/flutter#195918)
2026-11-24 [email protected] Fix some `parameter_assignments` warnings (flutter/flutter#196815)
2026-11-24 [email protected] [flutter_tools] Extract PlatformDebuggingOptions and move WebDebugConfig (flutter/flutter#197229)
2026-11-24 [email protected] Fix desktop apps installing to the system prefix after a failed build (flutter/flutter#196482)
2026-11-24 [email protected] [flutter_tools] Write flutter test native_assets.json outside targetDir (flutter/flutter#196300)
2026-11-24 [email protected] iOS: Check the presented composition order in platform view tests (flutter/flutter#197302)
2026-11-24 [email protected] Run the shared Vulkan embedder tests under Impeller as well as Skia (flutter/flutter#193004)
2026-11-24 [email protected] Roll Fuchsia Linux SDK from BOgXtIYxLYcCkRou2... to HtAKfFLbfAQ6g96RY... (flutter/flutter#197334)
2026-11-24 [email protected] Roll Skia from b3dec9325fe1 to 243c0dc9f662 (6 revisions) (flutter/flutter#197333)
2026-11-24 [email protected] [flutter_tools] Delete globals.dart and context_runner.dart (flutter/flutter#196095)
2026-11-24 [email protected] Update viewInsets docs for translucent and rounded system UI (flutter/flutter#196355)
2026-11-24 [email protected] [flutter_tools] Check that dartaotruntime can run before starting the frontend server (flutter/flutter#194206)
2026-11-24 [email protected] [framework] Fix DraggableScrollableSheet '_hold == null' assertion when touch lifts during snap (flutter/flutter#195771)
2026-11-24 [email protected] [web] Release ImageSource on GC and fix Picture finalizer cycles (flutter/flutter#197245)
2026-11-24 [email protected] [flutter_tools] Fix web compiler output tracking in web builds (flutter/flutter#196563)
2026-11-24 [email protected] Upgrade CI to Xcode 27.2 (flutter/flutter#196807)
2026-11-24 [email protected] Roll Packages from 5b93485 to f455dfa (6 revisions) (flutter/flutter#197316)
2026-11-24 [email protected] [Linux] Fix deadlock presenting to a Wayland subsurface (flutter/flutter#196945)
2026-11-24 [email protected] Roll Skia from 2140958ee284 to b3dec9325fe1 (1 revision) (flutter/flutter#197309)
2026-11-24 [email protected] Roll Fuchsia Test Scripts from oEU515sDqSTvD8Spx... to GPtykFNizlaauBqzs... (flutter/flutter#197313)

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

...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD t: extensions Issues related to Flutter Tools extensions 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