Skip to content

[flutter_tools] Supply engine host-tool paths to hooks via flutter_hook_config - #189821

Open
bdero wants to merge 1 commit into
flutter:masterfrom
bdero:bdero/hook-config-extension
Open

bdero wants to merge 1 commit into
flutter:masterfrom
bdero:bdero/hook-config-extension

Conversation

@bdero

@bdero bdero commented Jul 22, 2026

Copy link
Copy Markdown
Member

Fixes #186299

Passes a FlutterExtension (from package:flutter_hook_config, added in flutter/core-packages#19) to every build and link hook invocation. Hooks that consume engine host tools can now read input.config.flutter.impellerc and input.config.flutter.libtessellator instead of re-implementing artifact discovery, and the paths resolve through the tool's own Artifacts lookup, so --local-engine propagates to hooks instead of silently using stale cached binaries.

The extension also carries an engineVersion. hooks_runner keys the hook cache on the hook config, so hooks re-run when the SDK is upgraded even though the tool paths are unchanged. For a stock SDK this is the engine revision. Local engine builds have no revision (Environment.engineVersion is null by design), so the version is derived from the host tools' paths, sizes, and mtimes, which invalidates the hook cache when a local engine is rebuilt.

Supersedes #186300, which passed the same paths as environment variables. The typed extension participates in hook caching and needs no env-var plumbing.

Pre-launch Checklist

@bdero bdero added the tool Affects the "flutter" command-line tool. See also t: labels. label Jul 22, 2026
…ok_config

Appends a FlutterExtension to every build and link hook invocation so
hooks can read impellerc and libtessellator paths from the hook config,
resolved through the tool's own artifact lookup, including under
--local-engine. The extension's engineVersion invalidates the hook
cache on SDK upgrades and local engine rebuilds.
@bdero
bdero marked this pull request as ready for review July 29, 2026 01:09

@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 the flutter_hook_config dependency and adds support for supplying engine host-tool paths (such as impellerc and libtessellator) to build and link hooks via a new FlutterExtension. It implements createFlutterExtension to resolve these tools to absolute file URIs and derives a stable local engine version based on the tools' paths, sizes, and modification times to manage hook cache invalidation. Unit tests are added to verify this behavior. There are no review comments, and I have no feedback to provide.

@bdero
bdero force-pushed the bdero/hook-config-extension branch from 2247a94 to 4eda8e3 Compare July 29, 2026 01:12
@bdero
bdero requested review from bkonyi and dcharkes July 29, 2026 01:21
@bdero bdero added the CICD Run CI/CD label Jul 29, 2026

@dcharkes dcharkes 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.

Nice! 🥳

Comment thread pubspec.lock
sha256: af801f91e3e433a939551e601c386ee59683d045ae6148896983c75655ec79e5
url: "https://pub.dev"
source: hosted
version: "0.1.0"

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.

Since this is not 1.0. Should passing this config this be gated behind a flutter experiment flag? flutter config --enable-flutter-hooks-config

To make the the package 1.0 we should answer some questions:

  1. Is the current API future-proof? Or should things be nested (e.g. we have two artifact paths, should the be nested in an artifacts constructor and in a nested json map).
  2. Is the JSON future-proof? Do we promise to never break the JSON format ever? (If yes, okay. If no, is the package working with nullable fields e.g. it doesn't crash if it's not supplied?)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Should we just mark the package as 1.0? It's a trivial package, IMO. If we put it behind a feature flag, I can't actually use it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't see why we'd ever need to break it. Perhaps we would add more later, though. But even that would be exceedingly rare, since the current cadence of adding new executables to the archive is probably once every five years.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Mmmm on second thought... I could probably use for flutter_gpu_shaders and such. It's already using data assets anyhow (which is working wonderfully for flutter_scene by the way), which is also behind a flag. 🤷‍♂️
Maybe the flag isn't so bad. But curious what you think.

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.

A feature flag will allow us to get all the pieces in place and refactor on the go if needed. And then once the work concludes we bump to 1.0 and remove the flag. 👍

@@ -0,0 +1,64 @@
// Copyright 2014 The Flutter Authors. All rights reserved.

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.

We should probably also add an integration test in one of the existing tests that run hooks to see that the files are available.

For example in packages/flutter_tools/test/integration.shard/isolated/native_assets_flutter_run_test.dart or flutter_built_test

In the packages/flutter_tools/test/integration.shard/isolated/native_assets_test_utils.dart createTestProject you can modify the hook to throw an error on if the flutter config is not available.

(And then test both with the experiment on and off if we add an experiment flag.)

@flutter-dashboard

Copy link
Copy Markdown

This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@dcharkes dcharkes mentioned this pull request Sep 30, 2026
2 tasks done
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.

[flutter_tools] Expose Flutter engine host-tool paths to build hooks via a typed protocol extension

3 participants