Function prost_build::compile_protos
[−]
[src]
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. See the Cargo build.rs
code generation example for more
info.
This function should be called in a project's build.rs
.
Arguments
protos
- Paths to .proto
files to compile. Any transitively imported .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.
Errors
This function can fail for a number of reasons:
- Failure to locate or download
protoc
. - Failure to parse the
.proto
s. - Failure to locate an imported
.proto
.
It's expected that this function call be unwrap
ed in a build.rs
; there is typically no
reason to gracefully recover from errors during a build.
Example build.rs
extern crate prost_build;
fn main() {
prost_build::compile_protos(&["src/frontend.proto", "src/backend.proto"],
&["src"]).unwrap();
}