Skip to content

[boring] Move package:boring to dart-lang/tools (4/4): use package:prebuilt_code_assets - #2617

Draft
mosuem wants to merge 2 commits into
mainfrom
boring/4-prebuilt-code-assets
Draft

mosuem wants to merge 2 commits into
mainfrom
boring/4-prebuilt-code-assets

Conversation

@mosuem

@mosuem mosuem commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Part 4 of 4 of moving package:boring to dart-lang/tools. For an overview, see #2614. This PR is mosuem/boring#7.

It replaces the hook helpers for fetching, verifying, building, and linking with package:prebuilt_code_assets. That package implements the same build modes and tree shaking for any package with prebuilt native code. What's specific to package:boring now lives in lib/src/hook_helpers/library.dart: the release configuration and the CMake build.

  • tool/precompile_binaries.dart and tool/regenerate_hashes.dart now use the package's CLI runners. The options are the same, so boring_binaries.yaml doesn't change.
  • test/tree_shaking_test.dart now uses the package's ELF helpers.
  • The dependencies that only the replaced helpers used are gone. dart_dependency_validator.yaml is removed, because nothing needs ignoring anymore.

Open question. package:prebuilt_code_assets is a 0.1.x package from mosuem/prebuilt_code_assets. It has no publisher, and pub.dev doesn't detect its license. Its hook code runs on the machine of everyone who depends on package:boring, so it should probably move to a dart-lang repository and publisher first. #2615 and #2616 can land without this PR.

@mosuem
mosuem added this pull request to stack #2618 September 29, 2026 13:23
@mosuem mosuem changed the title [boring] Use package:prebuilt_code_assets in the build and link hooks [boring] Move package:boring to dart-lang/tools (4/4): use package:prebuilt_code_assets Sep 29, 2026
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Package publishing

Package Version Status Publish tag (post-merge)
package:boring ⭐ 0.4.2-wip WIP (no publish necessary)
  • 18 already published.
  • 24 WIP (no publish necessary).

Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

@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 refactors the build and link hooks of package:boring to use package:prebuilt_code_assets, significantly reducing boilerplate code for fetching prebuilt binaries, building from source with CMake, tree-shaking, and managing release hashes. The tests and CLI tools have also been updated to use shared utilities from the new package. The review feedback suggests a minor improvement in pkgs/boring/lib/src/hook_helpers/library.dart to avoid a conceptual circular dependency by calling boringReleaseConfig(version) directly instead of referencing the global boringLibrary instance.

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

PR Health

Coverage ⚠️
File Coverage
pkgs/boring/hook/build.dart 💔 Not covered
pkgs/boring/hook/link.dart 💔 Not covered
pkgs/boring/lib/src/hook_helpers/hashes.dart 💔 Not covered
pkgs/boring/lib/src/hook_helpers/library.dart 💔 Not covered
pkgs/boring/tool/precompile_binaries.dart 💔 Not covered
pkgs/boring/tool/regenerate_hashes.dart 💔 Not covered

This check for test coverage is informational (issues shown here will not fail the PR).

This check can be disabled by tagging the PR with skip-coverage-check.

License Headers ✔️
// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

Files
no missing headers

All source files should start with a license header.

Unrelated files missing license headers
Files
pkgs/html/test/differential_test.dart
pkgs/html/test/dom_parsing_test.dart
pkgs/html/test/mxss_test.dart
pkgs/html/test/noah_ark_clause_limit_test.dart

This check can be disabled by tagging the PR with skip-license-check.

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
boring Breaking 0.4.1 0.4.2-wip 0.4.2-wip ✔️

This check can be disabled by tagging the PR with skip-breaking-check.

Unused Dependencies ✔️
Package Status
boring ✔️ All dependencies utilized correctly.

For details on how to fix these, see dependency_validator.

This check can be disabled by tagging the PR with skip-unused-dependencies-check.

API leaks ⚠️

The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.

Package Leaked API symbol Leaking sources
boring self._SymbolAddresses bindings/boringssl.g.dart::SymbolAddresses
bindings/boringssl.g.dart::addresses
boring self.__va_list_tag bindings/boringssl.g.dart::BIO_vsnprintf::args
bindings/boringssl.g.dart::OPENSSL_vasprintf::args
boring self.__locale_struct bindings/boringssl.g.dart::locale_t

This check can be disabled by tagging the PR with skip-leaking-check.

Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

This check can be disabled by tagging the PR with skip-changelog-check.

@mosuem
mosuem force-pushed the boring/4-prebuilt-code-assets branch from 497fe69 to 80e6a01 Compare September 29, 2026 14:01
@mosuem
mosuem force-pushed the boring/4-prebuilt-code-assets branch from 80e6a01 to 20ec155 Compare September 30, 2026 10:48
@mosuem
mosuem force-pushed the boring/4-prebuilt-code-assets branch 2 times, most recently from de2d1f6 to 8f6e8fe Compare September 30, 2026 12:26
@mosuem
mosuem force-pushed the boring/4-prebuilt-code-assets branch from 8f6e8fe to 1c4d61b Compare September 30, 2026 12:31
@mosuem
mosuem force-pushed the boring/4-prebuilt-code-assets branch from 1c4d61b to a8d8e0f Compare September 30, 2026 12:49
@mosuem
mosuem force-pushed the boring/4-prebuilt-code-assets branch 2 times, most recently from 1afa2e4 to 9541079 Compare September 30, 2026 14:18
@mosuem
mosuem force-pushed the boring/4-prebuilt-code-assets branch from 9541079 to e9980d3 Compare October 7, 2026 09:35
mosuem added 2 commits October 9, 2026 08:54
hook/build.dart gains the `fetch` (default), `checkout` and `local`
build modes, configured under `hooks.user_defines.boring`. `fetch`
downloads the library of the pinned release and verifies it against the
SHA-256 hashes in lib/src/hook_helpers/hashes.dart, falling back to the
CMake build if there is none.

When linking is enabled, the build hook provides a static library, and
hook/link.dart links a dynamic library with only the functions that the
application uses, as recorded by the Dart compiler for the @RecordUse()
bindings. In the `fetch` mode, it falls back to the prebuilt dynamic
library if linking fails, for example without a C toolchain for the
target when cross-compiling.

- The hashes are computed with package:crypto.
- test/tree_shaking_test.dart builds the example natively and for
  linux-arm64, with and without a cross toolchain. The `test` job
  installs one on each OS.
- Pushing a `boring-binaries-v<version>` tag triggers the
  boring_binaries.yaml workflow, which builds the release libraries and
  attaches them to that pre-release. tool/regenerate_hashes.dart then
  pins their SHA-256 hashes.

The hashes and download URLs still point at the 0.4.1 release of
github.com/mosuem/boring until the first release from this repository.
Replace the hook helpers for fetching, verifying, building and linking
with package:prebuilt_code_assets, which implements the same build modes
and tree shaking for any package with prebuilt native code. What is
specific to package:boring, the release configuration and the CMake
build, is in lib/src/hook_helpers/library.dart, which both hooks and
the release tools share.

- tool/precompile_binaries.dart and tool/regenerate_hashes.dart use the
  package's CLI runners with the same options, so the binaries workflow
  is unchanged.
- test/tree_shaking_test.dart uses its ELF helpers.
- Drop the dependencies only the replaced helpers used, and with them
  dart_dependency_validator.yaml, which is no longer needed.
@mosuem
mosuem force-pushed the boring/4-prebuilt-code-assets branch from e9980d3 to 7ba2f75 Compare October 9, 2026 06:54
@mosuem
mosuem removed this pull request from stack #2618 October 12, 2026 09:08
@mosuem
mosuem added this pull request to stack #2661 October 12, 2026 09:09
@brianquinlan

Copy link
Copy Markdown
Contributor

Have you talked to @dcharkes about package: prebuilt_code_assets? I think that it should have a path to being officially supported by that Dart team or we shouldn't use it.

Base automatically changed from boring/3-prebuilt-link-hook to main October 23, 2026 05:18
@dcharkes

dcharkes commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Have you talked to @dcharkes about package: prebuilt_code_assets? I think that it should have a path to being officially supported by that Dart team or we shouldn't use it.

The native interop team does not want to own it on it on dart-lang/native. We feel like it's an dart-lang/ecosystem package. Dart-lang/native owns the low-level building blocks. How those building blocks are stitched together is an ecosystem question. And we don't have the capacity to maintain it.

(Separately, it makes some decisions that we don't agree with, such as hosting on github artifacts.)

For the full review see: dart-lang/native#3719

I do agree we maybe want a package in this direction, otherwise every package needs to reinvent the wheel. But until that time maybe duplicating the code is the cleaner solution because it doesn't commit us to maintaining some public API and agreeing on a bunch of design decisions.

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants