50 lines
2.0 KiB
ReStructuredText
50 lines
2.0 KiB
ReStructuredText
|
|
|
|
|
|
FRB v2
|
|
======
|
|
With flutter_rust_bridge, the Rust dependency lives in Cargo.toml, not pubspec.yaml
|
|
|
|
FRB v2 ships with Cargokit — a build helper that hooks into each platform's build
|
|
system (Gradle, Xcode, CMake) and compiles the Rust crate automatically at flutter build time.
|
|
This means:
|
|
* ccc_rust does not need a pubspec.yaml
|
|
* ccc_rust stays a pure Rust crate
|
|
* The current lum_ccc_rust entry in pubspec.yaml would be removed — it moves to rust/Cargo.toml
|
|
|
|
::
|
|
|
|
ccc_dart_plugin/
|
|
├── pubspec.yaml ← NO reference to ccc_rust here
|
|
├── rust/
|
|
│ ├── Cargo.toml ← ccc_rust referenced HERE as a Rust crate dep
|
|
│ └── src/api.rs ← thin wrappers calling ccc_rust
|
|
|
|
|
|
ccc_rust
|
|
========
|
|
The Rust crypto library remains a pure Rust crate with no Flutter or FFI-specific code.
|
|
Option 1: Build from source via Cargokit (recommended for development)
|
|
* The Rust crate references ccc_rust via a git tag in Cargo.toml
|
|
* Cargokit compiles the Rust code at build time for each platform
|
|
* No precompiled binaries are needed
|
|
|
|
Option 2: Cargokit precompiled binaries via GitHub Releases (recommended for pub.dev)
|
|
* The Rust crate is compiled into platform-specific binaries (staticlib for iOS/macOS, cdylib for Android)
|
|
* Binaries are uploaded to GitHub Releases
|
|
* Cargokit fetches the correct binary at build time based on the target platform
|
|
* This allows pub.dev users to get native performance without needing Rust or a build environment
|
|
|
|
|
|
Workflow
|
|
--------
|
|
* CI builds the Rust crate for all 5 platform targets
|
|
* CI uploads the .so/.dylib/.dll/.framework to a GitHub Release tagged with the Cargo package hash
|
|
* When consumers run flutter build, Cargokit downloads the precompiled binary instead of compiling
|
|
* If no precompiled binary exists, it falls back to source build
|
|
* Pros: Fast builds for consumers, no Rust toolchain needed, no repo bloat, built into FRB, single repo
|
|
* Cons: Requires CI pipeline to build + upload binaries
|
|
* Best for: pub.dev releases, distributing to teams without Rust installed
|
|
|
|
|