use std::{env, path::PathBuf};

fn main() {
    let protoc = protoc_bin_vendored::protoc_bin_path().expect("vendored protoc must exist");
    unsafe {
        env::set_var("PROTOC", protoc);
    }
    let out_dir = PathBuf::from(env::var("OUT_DIR").expect("OUT_DIR must exist"));
    let descriptor_path = out_dir.join("echo_descriptor.bin");

    tonic_prost_build::configure()
        .build_server(true)
        .build_client(true)
        .file_descriptor_set_path(descriptor_path)
        .compile_protos(&["proto/echo.proto"], &["proto"])
        .expect("echo proto must compile");
}
