fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("cargo:rerun-if-changed=proto/graphql.proto");
println!("cargo:rerun-if-changed=proto/greeter.proto");
println!("cargo:rerun-if-changed=proto/federation_example.proto");
println!("cargo:rerun-if-changed=build.rs");
let generated_dir = std::path::PathBuf::from("src/generated");
std::fs::create_dir_all(&generated_dir)?;
let proto_include =
std::env::var("PROTOC_INCLUDE").unwrap_or_else(|_| "/usr/local/include".to_string());
let proto_paths = ["proto", &proto_include];
tonic_build::configure()
.build_server(true)
.build_client(true)
.out_dir(&generated_dir)
.file_descriptor_set_path(generated_dir.join("graphql_descriptor.bin"))
.compile_protos(&["proto/graphql.proto"], &proto_paths)?;
tonic_build::configure()
.out_dir(&generated_dir)
.file_descriptor_set_path(generated_dir.join("greeter_descriptor.bin"))
.compile_protos(&["proto/greeter.proto"], &proto_paths)?;
tonic_build::configure()
.build_server(true)
.build_client(true)
.out_dir(&generated_dir)
.file_descriptor_set_path(generated_dir.join("federation_example_descriptor.bin"))
.compile_protos(&["proto/federation_example.proto"], &proto_paths)?;
Ok(())
}