tonin-build
build.rs helper that wraps tonic-build with tonin conventions. Every tonin service calls it from its own build.rs to compile .proto files into gRPC client + server stubs.
Part of the tonin framework.
Usage
Add it as a build-dependency in your service's Cargo.toml:
[]
= "0.1"
Then call compile from build.rs, passing the protos to compile and the include paths to resolve import statements against:
The generated code lands in OUT_DIR and is pulled into the service with tonic::include_proto!("<package>") in main.rs.
What it does
- Drives
tonic_build::configure().compile_protos(...)— both client and server stubs are generated by default (prost codegen). - The
TONIN_CODECenv var is reserved for a future codegen path:- unset or
prost— runstonic-build(this is what happens today, every build). buffa— reserved for a plannedprotoc-gen-microplugin. Setting it today logs a notice to stderr and falls back totonic-buildso scaffolds keep working.
- unset or
- Requires
protoconPATH. Services that want to opt out of proto compilation (e.g. forcargo checkon a machine without protoc) typically gate the call on aTONIN_SKIP_PROTOCenv var, as shown above.
Include paths follow tonic-build / protoc semantics: every directory you want import statements resolved against must be listed.
See also
- tonin — umbrella crate re-exporting the runtime
- tonin-core —
Servicebuilder, traits, transport, telemetry - micro — CLI that scaffolds services with a ready-to-use
build.rs
Licensed under the Apache License, Version 2.0.