[][src]Function brpc_build::compile_protos

pub fn compile_protos<P>(protos: &[P], includes: &[P]) -> Result<()> where
    P: AsRef<Path>, 

Compile .proto files into Rust files during a Cargo build.

The generated .rs files will be written to the Cargo OUT_DIR directory, suitable for use with the include! macro.

This function should be called in a project's build.rs.

Arguments

protos - Paths to .proto files to compile. Any transitively [imported][3] .proto files will automatically be included.

includes - Paths to directories in which to search for imports. Directories will be searched in order. The .proto files passed in protos must be found in one of the provided include directories.

It's expected that this function call be unwraped in a build.rs; there is typically no reason to gracefully recover from errors during a build.

Example build.rs

fn main() {
    brpc_build::compile_protos(&["src/echo.proto",],
                                &["src"]).unwrap();
}