use prost_wkt_build::*; use std::{env, path::PathBuf}; fn main() -> Result<(), Box> { let out_dir = PathBuf::from(env::var("OUT_DIR")?); let descriptor_file = out_dir.join("descriptor.bin"); #[allow(unused_mut)] let mut builder = tonic_build::configure() .build_client(cfg!(feature = "client")) .build_server(cfg!(feature = "server")); #[cfg(feature = "reflection")] { builder = builder.file_descriptor_set_path(&descriptor_file); } builder .type_attribute(".", "#[derive(serde::Serialize,serde::Deserialize)]") .extern_path(".google.protobuf.Struct", "::prost_wkt_types::Struct") .extern_path(".google.protobuf.Timestamp", "::prost_wkt_types::Timestamp") .compile(&["./proto/all.proto"], &["./proto"])?; let descriptor_bytes = std::fs::read(&descriptor_file)?; let descriptor = FileDescriptorSet::decode(&descriptor_bytes[..])?; prost_wkt_build::add_serde(out_dir, descriptor); Ok(()) }