Skip to content

[hooks] Fix pass-through dependencies#185739

Merged
auto-submit[bot] merged 3 commits into
flutter:masterfrom
dcharkes:fix-hooks-inputs-outputs
Apr 29, 2026
Merged

[hooks] Fix pass-through dependencies#185739
auto-submit[bot] merged 3 commits into
flutter:masterfrom
dcharkes:fix-hooks-inputs-outputs

Conversation

@dcharkes

@dcharkes dcharkes commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Closes:

The dependencies from build and link hooks are reported as inputs by the flutter build system to Xcode.
The assets reported from build and link hooks were reported as outputs by the Flutter build system to Xcode.
This caused issues if files just passed through hooks untouched.

We should only report files as outputs if they are actually produced by the hook. This means that if a file occurs in its inputs it should not occur in its outputs.

If linking is disabled, then the LinkHooks target must also report the dependencies of the BuildHooks, not only its outputs.

Note: This was likely only an issue for data assets, not for code assets. Code assets are either built from source or downloaded in the hook. Usually precompiled code-assets are not part of your package sources.

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Apr 29, 2026
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Apr 29, 2026
@dcharkes dcharkes force-pushed the fix-hooks-inputs-outputs branch from effc0ae to 7789e8d Compare April 29, 2026 12:13
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 29, 2026
@dcharkes dcharkes added the CICD Run CI/CD label Apr 29, 2026
@dcharkes dcharkes requested review from bkonyi and goderbauer April 29, 2026 12:30
@dcharkes dcharkes added CICD Run CI/CD and removed CICD Run CI/CD labels Apr 29, 2026
@fluttergithubbot

Copy link
Copy Markdown
Contributor

An existing Git SHA, 7789e8df54721710a7a13c3fcb6edd911182c4e0, was detected, and no actions were taken.

To re-trigger presubmits after closing or re-opeing a PR, or pushing a HEAD commit (i.e. with --force) that already was pushed before, push a blank commit (git commit --allow-empty -m "Trigger Build") or rebase to continue.

@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 29, 2026
@dcharkes dcharkes added the CICD Run CI/CD label Apr 29, 2026
@dcharkes dcharkes marked this pull request as ready for review April 29, 2026 12:34

@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 an optional output filtering mechanism in DepfileService to prevent circular dependencies in external systems like Xcode. It updates the native assets build and link hooks to utilize this filter and adds a test case to verify the fix. The review feedback suggests optimizing the filtering logic by using a Set for input paths to improve performance from O(N*M) to O(N+M).

Comment thread packages/flutter_tools/lib/src/build_system/depfile.dart Outdated
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 29, 2026
@dcharkes dcharkes added the CICD Run CI/CD label Apr 29, 2026
@dcharkes dcharkes added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 29, 2026
@auto-submit auto-submit Bot added this pull request to the merge queue Apr 29, 2026
Merged via the queue into flutter:master with commit 64c3de0 Apr 29, 2026
162 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Apr 29, 2026
BilalRehman08 pushed a commit to BilalRehman08/flutter that referenced this pull request May 22, 2026
Closes:

* flutter#186305


Fix:

* Updated
`packages/flutter_tools/lib/src/build_system/targets/native_assets.dart`
and
`packages/flutter_tools/lib/src/isolated/native_assets/native_assets.dart`
to cleanly support the tracking of build hook output files, ensuring
they are properly bundled as part of the asset bundling phase and
correctly rebuild when modified.

Test:

* Added isolated integration tests
(`packages/flutter_tools/test/integration.shard/isolated/dart_data_asset_flutter_build_test.dart`)
specifically verifying that Flutter builds rebuild correctly on macOS
and Web when hook-generated data asset files are deleted or changed.

Dependency updates:

* Upgrades the build hook and native asset package ecosystem to the
latest versions to apply the same fix in hooks_runner.
* The hooks_runner fix required a breaking change to `package:hooks`.
(We did the breaking change in a way so that further additions to
`ProtocolExtension` do not cause bring changes in the future.)

Refactors how the `LinkHooks` `Target` tracks dependencies:

* Only outputs its own DEPS as opposed to
flutter#185739
* Adding the `BuildHooks` inputs and outputs leads to extra link hook
target runs.
* To achieve that, `runFlutterSpecificLinkHooks` no longer combines the
assets and dependencies from both build and link, the combining is done
in `combineBuildAndLinkResults`.
* The `LinkHooks` still outputs the combined asset list so that
downstream targets don't have to combine the `BuildHooks` and
`LinkHooks` outputs manually.
via-guy pushed a commit to via-guy/flutter that referenced this pull request Jun 26, 2026
Closes:

* flutter#186305


Fix:

* Updated
`packages/flutter_tools/lib/src/build_system/targets/native_assets.dart`
and
`packages/flutter_tools/lib/src/isolated/native_assets/native_assets.dart`
to cleanly support the tracking of build hook output files, ensuring
they are properly bundled as part of the asset bundling phase and
correctly rebuild when modified.

Test:

* Added isolated integration tests
(`packages/flutter_tools/test/integration.shard/isolated/dart_data_asset_flutter_build_test.dart`)
specifically verifying that Flutter builds rebuild correctly on macOS
and Web when hook-generated data asset files are deleted or changed.

Dependency updates:

* Upgrades the build hook and native asset package ecosystem to the
latest versions to apply the same fix in hooks_runner.
* The hooks_runner fix required a breaking change to `package:hooks`.
(We did the breaking change in a way so that further additions to
`ProtocolExtension` do not cause bring changes in the future.)

Refactors how the `LinkHooks` `Target` tracks dependencies:

* Only outputs its own DEPS as opposed to
flutter#185739
* Adding the `BuildHooks` inputs and outputs leads to extra link hook
target runs.
* To achieve that, `runFlutterSpecificLinkHooks` no longer combines the
assets and dependencies from both build and link, the combining is done
in `combineBuildAndLinkResults`.
* The `LinkHooks` still outputs the combined asset list so that
downstream targets don't have to combine the `BuildHooks` and
`LinkHooks` outputs manually.
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