fn main() -> Result<(), Box<dyn std::error::Error>> {
    let protoc = protoc_bin_vendored::protoc_bin_path()?;
    std::env::set_var("PROTOC", protoc);

    let proto_root = "proto";
    let core_proto = "proto/mubit/v1/core.proto";
    let control_proto = "proto/mubit/v1/control.proto";

    println!("cargo:rerun-if-changed={core_proto}");
    println!("cargo:rerun-if-changed={control_proto}");

    tonic_build::configure()
        .build_server(false)
        .build_client(true)
        .type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]")
        .compile_protos(&[core_proto, control_proto], &[proto_root])?;

    Ok(())
}
