Skip to content

[record_use] Run build hooks and link hooks in separate targets#184880

Merged
auto-submit[bot] merged 3 commits into
flutter:masterfrom
dcharkes:record-use-split-build-and-link
Apr 20, 2026
Merged

[record_use] Run build hooks and link hooks in separate targets#184880
auto-submit[bot] merged 3 commits into
flutter:masterfrom
dcharkes:record-use-split-build-and-link

Conversation

@dcharkes

@dcharkes dcharkes commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

Bug:

Splits the build and link hooks into separate Targets so that the build hooks can run concurrently with gen_kernel, dart2js, and dart2wasm.

Caching tests added:

  • Changing Dart code and recorded uses causes no build hooks rerun but link hooks rerun.
  • Changing Dart code but no recorded uses casus no link hooks rerun.
  • Changing build hooks (or its dependencies) causes build hooks to rerun, but not link hooks to rerun of the outputs of the build hooks didn't change.
  • Changing the build hook outputs causes the link hooks to rerun.

Fixes the test case:

  • Properly adds the dependencies to both the build and link hook.

Also refactors the targets to better naming:

  • DartBuild -> BuildHooks (name dart_build -> build_hooks)
  • DartLink -> LinkHooks (name dart_link -> link_hooks)

And simplifies the amount of targets:

  • removed the ForNative and ForWeb variants and made the targets a bit more configurable instead.

@github-actions github-actions Bot added tool Affects the "flutter" command-line tool. See also t: labels. a: desktop Running on desktop team-android Owned by Android platform team team-ios Owned by iOS platform team team-macos Owned by the macOS platform team team-windows Owned by the Windows platform team team-linux Owned by the Linux platform team labels Apr 10, 2026
@dcharkes dcharkes added the CICD Run CI/CD label Apr 12, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 13, 2026
@dcharkes dcharkes added the CICD Run CI/CD label Apr 13, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 13, 2026
@dcharkes dcharkes added the CICD Run CI/CD label Apr 13, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 13, 2026
@dcharkes dcharkes added CICD Run CI/CD and removed CICD Run CI/CD labels Apr 13, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 14, 2026
@dcharkes dcharkes force-pushed the record-use-split-build-and-link branch from b371b21 to 324f275 Compare April 14, 2026 10:02
@github-actions github-actions Bot removed the a: desktop Running on desktop label Apr 14, 2026
@dcharkes dcharkes added the CICD Run CI/CD label Apr 14, 2026
@dcharkes dcharkes added CICD Run CI/CD and removed CICD Run CI/CD labels Apr 14, 2026
@dcharkes dcharkes force-pushed the record-use-split-build-and-link branch from 9dbd3e2 to 979f805 Compare April 14, 2026 14:09
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 14, 2026
@dcharkes dcharkes added the CICD Run CI/CD label Apr 14, 2026
@dcharkes dcharkes force-pushed the record-use-split-build-and-link branch from 979f805 to 29a6180 Compare April 14, 2026 14:20
@dcharkes dcharkes added CICD Run CI/CD and removed CICD Run CI/CD labels Apr 14, 2026
@github-actions github-actions Bot added the a: desktop Running on desktop label Apr 14, 2026
@dcharkes dcharkes force-pushed the record-use-split-build-and-link branch from a6c698b to 2ede37c Compare April 16, 2026 09:04
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 16, 2026
@dcharkes dcharkes added the CICD Run CI/CD label Apr 16, 2026

@goderbauer goderbauer 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, but please let someone from flutter_tools also have a look at this.

@dcharkes dcharkes force-pushed the record-use-split-build-and-link branch from 2ede37c to 59ec3b6 Compare April 17, 2026 13:52
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 17, 2026
@dcharkes dcharkes added the CICD Run CI/CD label Apr 17, 2026
bkonyi
bkonyi previously approved these changes Apr 17, 2026

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

LGTM overall with some nits.

}
final FlutterNativeAssetsBuildRunner buildRunner =
_buildRunner ?? await createFlutterNativeAssetsBuildRunner(environment);
final ({SerializedBuildResults results, List<Uri> dependencies}) record =

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.

Consider destructuring this here instead of creating variables later:

final (SerializedBuildResults :results, List<Uri> :dependencies) = await runFlutterSpecificBuildHooks(...);


final buildStart = DateTime.now();

final ({SerializedBuildResults results, List<Uri> dependencies}) buildRecord =

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.

Same comment here WRT destructuring inline.

return (results: const <String, Map<String, Object?>>{}, dependencies: const <Uri>[]);
}

final (

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.

With destructuring, you can omit the LHS name if you're going to assign its value to a variable of the same name:

final (
  List<AssetBuildTarget> :targets,
  BuildMode :buildMode,
  bool :linkingEnabled,
) = await _setupHooks(
  environmentDefines: environmentDefines,
  buildRunner: buildRunner,
  targetPlatform: targetPlatform,
  fileSystem: fileSystem,
  buildCodeAssets: buildCodeAssets,
  buildDataAssets: buildDataAssets,
);

}
final buildStart = DateTime.now();
final (
targets: List<AssetBuildTarget> targets,

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.

Ditto.

linkResult = await _link(buildRunner, extensions, buildResult, recordedUsesFile);

if (target is CodeAssetTarget) {
codeAssets.addAll(

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.

Nit: consider cascading these calls on codeAssets and dataAssets.

@dcharkes dcharkes force-pushed the record-use-split-build-and-link branch from 59ec3b6 to cd9a427 Compare April 20, 2026 09:16
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 20, 2026
@dcharkes dcharkes added the CICD Run CI/CD label Apr 20, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 20, 2026
@dcharkes dcharkes added the CICD Run CI/CD label Apr 20, 2026
@dcharkes dcharkes requested review from bkonyi and goderbauer April 20, 2026 10:22

@goderbauer goderbauer 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

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

LGTM!

@dcharkes dcharkes added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 20, 2026
@auto-submit auto-submit Bot added this pull request to the merge queue Apr 20, 2026
Merged via the queue into flutter:master with commit 4a5dc26 Apr 20, 2026
167 checks passed
@Piinks Piinks mentioned this pull request Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: desktop Running on desktop CICD Run CI/CD team-android Owned by Android platform team team-ios Owned by iOS platform team team-linux Owned by the Linux platform team team-macos Owned by the macOS platform team team-windows Owned by the Windows 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.

4 participants