Files
buzz/mobile/packages
Tom Brow 82b2781376 fix(mobile): rebuild buzz_secp256k1 when vendored headers change (#8664)
Follow-up to #8654, from [Kalvin's review
note](https://github.com/block/buzz/pull/8654#discussion_r4407146414).

`native_toolchain_c`'s `CBuilder` registers only the listed C sources
(and files under `includes`) as build-hook dependencies. The
`buzz_secp256k1` hook lists four sources and no headers, so after an
initial build a header-only vendor update (for example
`src/modules/schnorrsig/main_impl.h`) could reuse the old library in
incremental app and test builds. The hook now also registers every `.h`
file under the vendored tree. It does not add include paths, so
compilation is unchanged.

### Validation

- With the change, editing the content of
`third_party/secp256k1/src/modules/schnorrsig/main_impl.h` makes the
next `dart test` rebuild `libbuzz_secp256k1.dylib`. Without it, the
library is reused unchanged.
- The hook output now lists all 62 vendored headers as dependencies.
- Package tests pass (27).

buzz-review-completed (Codex and security review clean; agent
verification above; build-only change, no app behavior to test)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 18:56:35 -07:00
..
…

Native packages

Local Dart packages that wrap a native C library through dart:ffi. Each one compiles its library from vendored source with a Dart build hook (hook/build.dart), so Flutter's native assets support builds it for every target (iOS, Android, and the host for flutter test). No CocoaPods, Gradle, or CMake plugin wiring is involved.

Layout

packages/<name>/
  pubspec.yaml          # depends on hooks, code_assets, native_toolchain_c, ffi
  hook/build.dart       # CBuilder.library over the vendored sources
  third_party/<lib>/    # pinned upstream subset + VENDORED.md (tag, sha256)
  src/*.c               # optional shims when the upstream API needs adapting
  lib/src/bindings.dart # @Native leaf bindings, @DefaultAsset = the hook's assetName
  lib/<name>.dart       # small typed Dart API that owns memory and validation
  test/                 # upstream test vectors where they exist

Adding a library

  1. Vendor the smallest source subset from a tagged upstream release and record the tag and tarball sha256 in third_party/<lib>/VENDORED.md. Do not edit vendored files.
  2. Mirror the upstream build system's compile definitions in hook/build.dart.
  3. Bind only the symbols the app needs. Mark calls isLeaf: true unless they call back into Dart, and keep callbacks in C shims so the bindings work in any isolate.
  4. Add the package to mobile/pubspec.yaml as a path: dependency.

Packages

  • buzz_secp256k1: bitcoin-core/libsecp256k1 (BIP-340 Schnorr, ECDH).