1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//! `build.rs` helper that wraps [`tonic-build`] with tonin conventions.
//!
//! Call [`compile`] from a service crate's `build.rs` with the protos to
//! compile and the include paths to resolve `import` statements against.
//! Both gRPC client and server stubs are generated; the output lands in
//! `OUT_DIR` and is pulled in with `tonic::include_proto!("<package>")`.
//!
//! # Example
//!
//! ```no_run
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Skip codegen if protoc is unavailable so the workspace still
//! // `cargo check`s without system protoc installed.
//! // Set TONIN_SKIP_PROTOC=1 to skip.
//! if std::env::var("TONIN_SKIP_PROTOC").is_ok() {
//! return Ok(());
//! }
//! tonin_build::compile(&["proto/greeter.proto"], &["proto"])
//! }
//! ```
//!
//! # Cargo.toml
//!
//! ```toml
//! [build-dependencies]
//! tonin-build = "0.1"
//! ```
//!
//! Today every call to [`compile`] routes through `tonic-build` (prost).
//! `TONIN_CODEC=buffa` is reserved for a future `protoc-gen-micro` codegen
//! plugin; setting it today logs a notice to stderr and falls back to
//! prost so scaffolds keep working unchanged. `TONIN_CODEC=prost` (or
//! unset) is the explicit / default path.
//!
//! # Sample app
//!
//! <https://github.com/Rushit/tonin/tree/main/examples/greeter/blob/main/build.rs>
//!
//! # Sibling crates
//!
//! <https://docs.rs/tonin>
//!
//! [`tonic-build`]: https://crates.io/crates/tonic-build