mirror of
https://github.com/block/buzz.git
synced 2026-10-30 22:11:36 +00:00
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>
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
- 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. - Mirror the upstream build system's compile definitions in
hook/build.dart. - Bind only the symbols the app needs. Mark calls
isLeaf: trueunless they call back into Dart, and keep callbacks in C shims so the bindings work in any isolate. - Add the package to
mobile/pubspec.yamlas apath:dependency.
Packages
buzz_secp256k1: bitcoin-core/libsecp256k1 (BIP-340 Schnorr, ECDH).