Expand description
Downloads protoc binaries for use in Cargo build scripts.
This crate is intended to be used in Cargo build scripts (build.rs
) with
prost-build
or
tonic-build
, so you don’t need protoc
installed to build projects that use Protocol Buffers.
§Usage
Add the dlprotoc
crate to build-dependencies
in Cargo.toml
:
[build-dependencies]
dlprotoc = "0"
In build.rs
, call download_protoc
before calling compile_protos
:
fn main() -> Result<(), Box<dyn std::error::Error>> {
dlprotoc::download_protoc()?;
prost_build::compile_protos(&["src/example.proto"], &["src/"])?;
Ok(())
}
Structs§
- Error
- The Error type returned by the dlprotoc crate.
Functions§
- download_
protoc - Downloads protoc to the
OUT_DIR
environment variable and sets thePROTOC
environment variable so prost-build or tonic-build can find it. - download_
unverified - Downloads protoc without verifying the hash. This should only be used by the dlprotoc
crate, and by the
protochashes
tool. - protoc_
hash - Hashes data using the algorithm used to verify protoc binaries (currently SHA-256). This should
only be used by the
protochashes
tool.