Some checks failed
CI / check (push) Has been cancelled
The gRPC build script required a system protoc, which a fresh clone and the CI container lack (build failed with 'Could not find protoc'). Set PROTOC from protoc-bin-vendored in build.rs (unless one is already set), so cargo build works out of the box everywhere.
16 lines
775 B
Rust
16 lines
775 B
Rust
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
// Use a vendored protoc, so `cargo build` needs no system protobuf compiler
|
|
// (a fresh clone, CI, and the deploy box all build out of the box). Respect
|
|
// an explicit PROTOC if one is already set.
|
|
if std::env::var_os("PROTOC").is_none() {
|
|
std::env::set_var("PROTOC", protoc_bin_vendored::protoc_bin_path()?);
|
|
}
|
|
// Server only: the Rust side never needs to dial itself as a gRPC client.
|
|
// Django (or any other consumer) generates its own stub from proto/echo.proto.
|
|
tonic_build::configure()
|
|
.build_server(true)
|
|
.build_client(false)
|
|
.compile_protos(&["proto/echo.proto"], &["proto"])?;
|
|
println!("cargo:rerun-if-changed=proto/echo.proto");
|
|
Ok(())
|
|
}
|