Skip to content

[hooks] Use prebuilt/ instead of assets/ in prebuilt_assets_example - #3671

Merged
dcharkes merged 1 commit into
mainfrom
prebuilt-dir
Sep 18, 2026
Merged

dcharkes merged 1 commit into
mainfrom
prebuilt-dir

Conversation

@dcharkes

Copy link
Copy Markdown
Collaborator

Updates prebuilt_assets_example (along with its CI workflow and the doc comment in package:hooks) to store prebuilt dynamic libraries in prebuilt/ instead of assets/.

Motivation

  1. Avoid colliding with committed static/data assets in assets/:

    • A scan of the top 100 most popular packages on pub.dev shows that assets/ (plural) is the established convention for committed static/data assets (used in 28 of the top 100 packages and 60 of their GitHub repositories, versus 0 using asset/).
    • Putting prebuilt binaries that are built in CI into assets/ requires .gitignore-ing assets/, which collides if a package also has checked-in static/data files in assets/.
    • Furthermore, if assets/ is declared in pubspec.yaml (e.g., under flutter: assets:) or auto-discovered by data asset tooling, placing .so/.dylib/.dll binaries for all target OS/architectures inside assets/ (or assets/prebuilt/) risks accidentally bundling every platform's binary into the application as a data asset alongside the CodeAsset.
  2. Avoid .pubignore pitfalls with build/:

    • Using build/prebuilt/ requires un-ignoring /build/ first (!/build/, /build/*, !/build/prebuilt/) because /build/ is in .gitignore by default, which is error-prone and risks publishing local build artifacts if not carefully configured.
  3. Alignment with Dart's singular directory layout & other language ecosystems:

    • Dart package layout: Matches Dart's singular top-level directory naming (lib/, bin/, test/, tool/, example/, doc/, hook/).
    • Node.js / npm (prebuildify & node-gyp-build): The closest 1-to-1 equivalent to dart pub publish + hook/build.dart is npm's native addon workflow, which publishes a single .tgz archive containing multi-platform binaries built in CI, gitignored in source control, and un-ignored for npm publish under prebuilds/<platform>-<arch>/, with an install hook that uses the prebuilt binary when present or falls back to compiling from source.
    • Rust / Cargo (-sys crates) & Android NDK: Rust -sys crates that ship precompiled binaries in .crate archives and Android NDK toolchains (prebuilt/<os>-<arch>/) use prebuilt/.
    • Why not dist/: While TypeScript/npm packages ship compiled JS entrypoints in dist/, in Python (python -m build -> dist/*.whl) and web tooling dist/ is the local output directory for release archives rather than a directory inside the published package.

…ple`

Updates `prebuilt_assets_example` (along with its CI workflow and the doc comment in `package:hooks`) to store prebuilt dynamic libraries in `prebuilt/` instead of `assets/`.

### Motivation

1. **Avoid colliding with committed static/data assets in `assets/`:**
   - A scan of the top 100 most popular packages on `pub.dev` shows that `assets/` (plural) is the established convention for committed static/data assets (used in 28 of the top 100 packages and 60 of their GitHub repositories, versus 0 using `asset/`).
   - Putting prebuilt binaries that are built in CI into `assets/` requires `.gitignore`-ing `assets/`, which collides if a package also has checked-in static/data files in `assets/`.
   - Furthermore, if `assets/` is declared in `pubspec.yaml` (e.g., under `flutter: assets:`) or auto-discovered by data asset tooling, placing `.so`/`.dylib`/`.dll` binaries for all target OS/architectures inside `assets/` (or `assets/prebuilt/`) risks accidentally bundling every platform's binary into the application as a data asset alongside the `CodeAsset`.

2. **Avoid `.pubignore` pitfalls with `build/`:**
   - Using `build/prebuilt/` requires un-ignoring `/build/` first (`!/build/`, `/build/*`, `!/build/prebuilt/`) because `/build/` is in `.gitignore` by default, which is error-prone and risks publishing local build artifacts if not carefully configured.

3. **Alignment with Dart's singular directory layout & other language ecosystems:**
   - **Dart package layout:** Matches Dart's singular top-level directory naming (`lib/`, `bin/`, `test/`, `tool/`, `example/`, `doc/`, `hook/`).
   - **Node.js / npm (`prebuildify` & `node-gyp-build`):** The closest 1-to-1 equivalent to `dart pub publish` + `hook/build.dart` is npm's native addon workflow, which publishes a single `.tgz` archive containing multi-platform binaries built in CI, gitignored in source control, and un-ignored for `npm publish` under `prebuilds/<platform>-<arch>/`, with an install hook that uses the prebuilt binary when present or falls back to compiling from source.
   - **Rust / Cargo (`-sys` crates) & Android NDK:** Rust `-sys` crates that ship precompiled binaries in `.crate` archives and Android NDK toolchains (`prebuilt/<os>-<arch>/`) use `prebuilt/`.
   - **Why not `dist/`:** While TypeScript/npm packages ship compiled JS entrypoints in `dist/`, in Python (`python -m build` -> `dist/*.whl`) and web tooling `dist/` is the local output directory for release archives rather than a directory inside the published package.
@dcharkes
dcharkes requested a review from jonasfj September 18, 2026 12:17
@github-actions github-actions Bot added type-infra A repository infrastructure change or enhancement package:hooks labels Sep 18, 2026
@github-actions

github-actions Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

PR Health

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
hooks Non-Breaking 2.2.0 2.2.1-wip 2.2.1-wip ✔️

This check can be disabled by tagging the PR with skip-breaking-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

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

@codecov

codecov Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.91%. Comparing base (73bd0b7) to head (ac5ca84).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3671   +/-   ##
=======================================
  Coverage   59.91%   59.91%           
=======================================
  Files         307      307           
  Lines       29464    29464           
=======================================
  Hits        17652    17652           
  Misses      11812    11812           
Flag Coverage Δ
native_pkgs_macos 84.37% <ø> (ø)
native_pkgs_ubuntu 82.63% <ø> (ø)
native_pkgs_windows 86.97% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
code_assets 95.72% <ø> (ø)
data_assets 91.56% <ø> (ø)
ffi 100.00% <ø> (ø)
ffigen 91.41% <ø> (ø)
hooks 78.44% <ø> (ø)
hooks_runner 89.76% <ø> (ø)
jni 11.89% <ø> (ø)
jni_flutter ∅ <ø> (∅)
jni_util ∅ <ø> (∅)
jnigen 82.77% <ø> (ø)
json_syntax_generator ∅ <ø> (∅)
native_test_helpers 85.71% <ø> (ø)
native_toolchain_c 95.94% <ø> (ø)
objective_c 79.53% <ø> (ø)
pub_formats ∅ <ø> (∅)
record_use 81.48% <ø> (ø)
swift2objc 92.95% <ø> (ø)
swiftgen 80.80% <ø> (ø)
test_case_selector 97.28% <ø> (ø)
Files with missing lines Coverage Δ
pkgs/hooks/lib/src/config.dart 74.92% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dcharkes
dcharkes merged commit 876145f into main Sep 18, 2026
59 of 60 checks passed
@dcharkes
dcharkes deleted the prebuilt-dir branch September 18, 2026 13:23
copybara-service Bot pushed a commit to dart-lang/sdk that referenced this pull request Sep 22, 2026
Revisions updated by `dart tools/rev_sdk_deps.dart`.

dartdoc (https://github.com/dart-lang/dartdoc/compare/df2f2cd..c68debc):
  c68debcb  Mon Sep 21 11:07:33 2026 +0200  Sarah Zakarias  Adapt the {@example} code fence to the example content (dart-lang/dartdoc#4285)

ecosystem (https://github.com/dart-lang/ecosystem/compare/1bdafd8..16dca7a):
  16dca7a  Mon Sep 21 08:04:10 2026 -0700  Kevin Moore  fix(firehose): keep dart_apitool crash details in logs and sanitize breaking table row (dart-lang/ecosystem#461)

http (https://github.com/dart-lang/http/compare/35769ba..d8e8e9c):
  d8e8e9c  Mon Sep 21 18:26:27 2026 +0900  DubaiChewyCookie  fix(http2): bound peer-controlled streams and headers (dart-lang/http#1958)
  286037b  Thu Sep 17 17:12:02 2026 -0700  Brian Quinlan  chore(http2): prepare to release 3.1.0 (dart-lang/http#1987)
  a067c94  Wed Sep 16 15:57:52 2026 -0700  Brian Quinlan  fix(cupertino_http): possible URLRequest memory leaks (dart-lang/http#1989)
  0d15438  Thu Sep 17 00:43:43 2026 +0300  Ellet  chore(ok_http): Built-in Kotlin and resolve AGP 9 warnings (dart-lang/http#1973)

native (https://github.com/dart-lang/native/compare/a88aaaf..f628b26):
  f628b26f0  Mon Sep 21 23:21:05 2026 +0200  Daco Harkes  [hooks] Add unit tests for `ProtocolExtension` defaults and `build`/`link` error paths (dart-lang/native#3668)
  474a93f39  Mon Sep 21 08:01:13 2026 +0500  Muhammad Anas Naveed  [jni][jnigen] Update Groovy Gradle property assignments (dart-lang/native#3678)
  4434b7f3c  Mon Sep 21 10:31:09 2026 +1000  Liam Appelbe  [jni] Ignore coverage of generated files (dart-lang/native#3665)
  b66dfdeae  Mon Sep 21 10:27:27 2026 +1000  Liam Appelbe  [objective_c] Use `objc_retainAutoreleasedReturnValue` (dart-lang/native#3664)
  541121b4b  Fri Sep 18 17:30:03 2026 +0200  Daco Harkes  [record_use] Add status and coverage badges to `README.md` (dart-lang/native#3675)
  b97663824  Fri Sep 18 17:25:10 2026 +0200  Daco Harkes  [hooks] Prepare `prebuilt_assets_example` v0.1.2 for release (dart-lang/native#3672)
  876145f0c  Fri Sep 18 15:23:34 2026 +0200  Daco Harkes  [hooks] Use `prebuilt/` instead of `assets/` in `prebuilt_assets_example` (dart-lang/native#3671)
  73bd0b7b3  Fri Sep 18 12:58:36 2026 +0200  Daco Harkes  [hooks] Prepare `prebuilt_assets_example` v0.1.1 for release (dart-lang/native#3669)
  4e0f1983f  Fri Sep 18 11:40:30 2026 +0200  Daco Harkes  [hooks] Add example for bundling prebuilt assets in `pub publish` (dart-lang/native#3637)
  22d7cf8da  Fri Sep 18 09:28:25 2026 +0200  Daco Harkes  [native_test_helpers] Add unit tests for `yamlToJson` and `findPackageRoot` (dart-lang/native#3662)
  74e631a8b  Fri Sep 18 09:28:25 2026 +0200  Daco Harkes  [hooks] Add unit tests for `link` API and `MetadataAsset` (dart-lang/native#3661)
  3428cb968  Fri Sep 18 09:28:24 2026 +0200  Daco Harkes  [data_assets] Add unit tests for `LinkOutput` data asset extensions (dart-lang/native#3660)
  0e4eea612  Fri Sep 18 09:28:24 2026 +0200  Daco Harkes  [code_assets] Add unit tests for `testCodeBuildHook` and `CCompilerConfig` (dart-lang/native#3659)
  dc44c5383  Fri Sep 18 09:28:24 2026 +0200  Daco Harkes  [ffi] Add unit tests for `Arena` error handling and `malloc.free` (dart-lang/native#3658)
  1e1e2fb8a  Fri Sep 18 09:28:23 2026 +0200  Daco Harkes  [native_toolchain_c] Default `linkerOptions` in `CLinker.run` and add `CLibrary` tests (dart-lang/native#3657)
  f3c066006  Fri Sep 18 09:28:23 2026 +0200  Daco Harkes  [data_assets] [hooks] [hooks_runner] [record_use] Add coverage ignore comments for debug methods (dart-lang/native#3656)
  59cd44422  Fri Sep 18 09:28:22 2026 +0200  Daco Harkes  [infra] Clean coverage directory and enable `--check-ignore` in `tool/ci.dart` (dart-lang/native#3655)
  b859d5fa8  Fri Sep 18 09:35:46 2026 +0500  Muhammad Anas Naveed  [ffigen] Default compiler options for C++ (dart-lang/native#3645)
  eb6ea1e56  Thu Sep 17 09:28:38 2026 +1000  Liam Appelbe  [ffigen][jnigen] More docs (dart-lang/native#3649)
  da786131c  Thu Sep 17 09:06:20 2026 +1000  Liam Appelbe  [ffigen][jnigen] YAML migration skills (dart-lang/native#3648)
  fc0491997  Wed Sep 16 15:37:19 2026 -0700  Brian Quinlan  [objective_c] don't use autorelease for `toNSDate` (dart-lang/native#3650)
  f7f9a4556  Wed Sep 16 17:32:47 2026 +0200  Daco Harkes  [code_assets] [hooks_runner] [native_toolchain_c] Prepare for release (dart-lang/native#3642)
  1c60c437c  Wed Sep 16 13:40:31 2026 +0200  Daco Harkes  [hooks_runner] Restore non-breaking `KernelAssetPath.toJson` and add `toJsonForTarget` (dart-lang/native#3643)
  7667162b3  Wed Sep 16 11:46:18 2026 +0200  Daco Harkes  [infra] Use `dependency_validator` in `tool/ci.dart` (dart-lang/native#3646)
  f6d153d01  Tue Sep 15 19:32:08 2026 -0700  Brian Quinlan  [objective_c] Fix potential leaks in converts (dart-lang/native#3647)
  cb2c62331  Wed Sep 16 11:32:42 2026 +1000  Liam Appelbe  [ffigen] Remove YAML from readmes (dart-lang/native#3633)
  22e835728  Wed Sep 16 09:49:02 2026 +1000  Liam Appelbe  [jnigen] Remove yaml from readme (dart-lang/native#3634)
  eb444eee2  Wed Sep 16 09:48:04 2026 +1000  Liam Appelbe  [infra] Add and fix `unawaited_futures` and `discarded_futures` lints (dart-lang/native#3639)
  0f419f0d2  Wed Sep 16 09:47:44 2026 +1000  Liam Appelbe  [infra] Switch from coveralls to codecov (dart-lang/native#3626)

shelf (https://github.com/dart-lang/shelf/compare/f36dd68..e5c8dc6):
  e5c8dc6  Tue Sep 15 18:15:41 2026 -0700  Kevin Moore  fix(shelf_static): ignore suffix ranges selecting zero bytes (dart-lang/shelf#541)

test (https://github.com/dart-lang/test/compare/c80d53d..9946c95):
  9946c955  Mon Sep 21 12:31:54 2026 -0700  Nate Bosch  Fix a race in the frontend server client fake (dart-lang/test#2762)
  48c3fdf6  Fri Sep 18 18:52:52 2026 -0700  Nate Bosch  Fix race conditions during test load (dart-lang/test#2761)
  5d74864b  Fri Sep 18 16:25:57 2026 -0700  Nate Bosch  Remove mentions of Travis (dart-lang/test#2760)
  5c4d9b25  Fri Sep 18 12:49:00 2026 -0700  Nate Bosch  Use consistent *Checks naming for prints (dart-lang/test#2759)
  f927df26  Fri Sep 18 12:15:49 2026 -0700  Kevin Moore  feat(checks): add prints expectations (`#2742`) (dart-lang/test#2743)
  347a5af2  Fri Sep 18 12:09:15 2026 -0700  Nate Bosch  Add an example for every matcher (dart-lang/test#2757)
  6358dbb3  Thu Sep 17 15:10:08 2026 -0700  Nate Bosch  Add an example for every checks expectation, and fix the bugs they exposed (dart-lang/test#2756)
  88202adc  Thu Sep 17 14:13:30 2026 +0200  Sigurd Meldgaard  New flag --shard-by-suite

tools (https://github.com/dart-lang/tools/compare/1b0c3bb..3614ce0):
  3614ce06  Fri Sep 18 10:07:20 2026 -0700  Kevin Moore  chore(unified_analytics): remove dart:mirrors usage in test/event_test.dart (dart-lang/tools#2602)
  7550ce13  Fri Sep 18 07:56:44 2026 -0700  Kevin Moore  chore(markdown): remove dart:mirrors usage in tool/stats_lib.dart (dart-lang/tools#2600)

[email protected]

Change-Id: Ide262779269adab780d314d80c9f82b97a79391f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/552741
Commit-Queue: Nate Bosch <[email protected]>
Reviewed-by: Brian Quinlan <[email protected]>
Hassnaa9 pushed a commit to Hassnaa9/native that referenced this pull request Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package:hooks skip-changelog-check type-infra A repository infrastructure change or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants