Template repository for building a new Minigraf language binding.
| File | Purpose |
|---|---|
Cargo.toml |
Rust shim crate — depends on minigraf core, produces a cdylib |
src/lib.rs |
UniFFI scaffolding with comments at every extension point |
src/uniffi_bindgen.rs |
Entry point for the uniffi-bindgen CLI binary |
.github/workflows/ci.yml |
CI: cargo test, then package, consumer test and readme-sync |
.github/workflows/package.yml |
The only place artifacts are built (placeholder: the cdylib) |
.github/workflows/verify-published.yml |
Post-publish consumer test from the registry; opens a release-broken issue on failure |
consumer-test/run.sh |
Installs the artifacts into an empty project and runs the quick start and the contract |
consumer-test/readme_sync.py |
Checks that the README quick start is what the consumer test runs (canonical copy) |
- Click Use this template on GitHub to create your repo under
project-minigraf/<language>. - Update
Cargo.toml: rename the crate, pinminigrafexactly to the version you're targeting (minigraf = "=2.x.y"). Bindings map errors viaminigraf::MinigrafError::category(); its message carries the stable error code ([PRS-001] ...). - Run
cargo testto verify the Rust layer compiles and tests pass. - Add your language tooling (e.g.
java/,android/,Sources/, etc.). - Generate language bindings with
uniffi-bindgen:cargo build --release cargo run --bin uniffi-bindgen -- generate \ --library target/release/libminigraf_ffi.<so|dylib|dll> \ --language <kotlin|swift|python|...> \ --out-dir <output-dir>/
- Fill in the packaging and the consumer test (next section).
- Add a
release.ymlthat receives thecore-releaserepository_dispatch event from the minigraf cascade, pins the newminigrafversion inCargo.toml, commits, tags, and publishes your artifact, wired as described below.
Every binding proves, on every PR and in every release, that its package installs and
works the way a user installs it. Search for TODO(binding) to find every placeholder.
package.ymlbuilds each artifact exactly as it is published, stamped with theversioninput (0.0.0-cion PRs), checks its contents (native library, generated bindings,LICENSE-MIT,LICENSE-APACHE) and uploads it asdist-<name>. Nothing else builds release artifacts.consumer-test/run.sh local <dist> <version>installs those artifacts into a fresh temporary project with the package manager, then runsconsumer-test/quickstart.<ext>(the README quick start) and a contract test: in memory, file-backed with a reopen, the error type with its code, and the installed version.registry <version>does the same from the public registry, waiting up to 10 minutes for the version to appear. Resolve the dist path beforecd, and pass relative paths to tools on Windows.README.mdgets a## Quick startsection. readme-sync takes its first code block and requires every non-blank line, trimmed, to appear in the same order inconsumer-test/quickstart.<ext>. The consumer may add imports, a wrapper and assertions around them. Set the file name inci.yml. If the README covers more than one package, pass the section heading as a third argument.ci.yml: oneconsumerleg per platform you publish for, downloading the matchingdist-<name>.release.yml:- the
testjob callsci.ymlwith the pinnedshaasrefand the release version asversion, so the artifacts are built and consumer-tested before anything is tagged; publishdownloadsdist-*from the same run and uploads exactly those files, never a rebuild, and skips a version the registry already has, so re-runs are safe;- a last job calls
verify-published.ymlwith the version and the release tag.
- the
verify-published.yml: the same matrix in registry mode. On failure it opens (or comments on) an issue labelledrelease-broken, and the run fails. Run it by hand withgh workflow run verify-published.yml -f version=<x.y.z>.
The canonical readme_sync.py lives here; copy it unchanged.
UniFFI's setup_scaffolding!() macro generates extern "C" symbols in the final cdylib
crate. Re-exporting from a crate that already called it causes duplicate symbol errors at
link time. Always embed the scaffolding in your own crate and depend on minigraf core
directly. See the existing binding repos (minigraf-python, minigraf-java, etc.) for
complete examples.
MIT OR Apache-2.0