[hooks] Fix pass-through dependencies#185739
Conversation
effc0ae to
7789e8d
Compare
|
An existing Git SHA, To re-trigger presubmits after closing or re-opeing a PR, or pushing a HEAD commit (i.e. with |
There was a problem hiding this comment.
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).
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.
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.
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.