build.rs 613 Bytes
Newer Older
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
1
2
3
use std::fs;

fn main() -> Result<(), Box<dyn std::error::Error>> {
4
    println!("cargo:rerun-if-changed=../../proto/generate.proto");
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
5
    fs::create_dir("src/pb").unwrap_or(());
6
7
8
9

    let mut config = prost_build::Config::new();
    config.protoc_arg("--experimental_allow_proto3_optional");

Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
10
11
12
13
14
    tonic_build::configure()
        .build_client(true)
        .build_server(false)
        .out_dir("src/pb")
        .include_file("mod.rs")
15
16
        .compile_with_config(config, &["../../proto/generate.proto"], &["../../proto"])
        .unwrap_or_else(|e| panic!("protobuf compilation failed: {e}"));
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
17
18
19

    Ok(())
}