tree: 4d6d63f2773e9295d4cb3895e715ffc93db602a4 [search]
  1. hook/
  2. lib/
  3. src/
  4. test/
  5. tool/
  6. .gitignore
  7. .pubignore
  8. CHANGELOG.md
  9. LICENSE
  10. pubspec.yaml
  11. README.md
pkgs/hooks/example/build/prebuilt_assets_example/README.md

An example of a library that builds dynamic libraries across multiple GitHub Actions runners, pulls them all into a single GitHub Actions job (under prebuilt/), and runs dart pub publish to bundle the prebuilt dynamic libraries directly inside the published pub package.

Usage

Run tests with dart test.

When prebuilt/<target_dylib> is present (as it is in the published pub package or after running dart tool/build.dart), hook/build.dart emits a CodeAsset pointing directly to the prebuilt library inside input.packageRoot. If the prebuilt asset is not present (e.g., during local development before prebuilding) or when local_build: true is set, hook/build.dart falls back to building from source.

Code organization

  • tool/build.dart prebuilds assets into prebuilt/ and is exercised from a GitHub workflow.
  • A GitHub workflow that builds assets across a matrix of runners, downloads them all into prebuilt/ in a single job, and runs dart pub publish.
  • .gitignore ignores prebuilt/ so binaries are not committed to source control, while .pubignore overrides .gitignore for dart pub publish so that prebuilt/ is included in the published package archive.
  • hook/build.dart bundles the prebuilt asset from prebuilt/ (or falls back to building from source).
  • lib/ contains Dart code which uses the assets.