2020-10-15 17:04:10 -07:00
|
|
|
fn main() -> Result<(), std::io::Error> {
|
2022-08-02 15:37:28 -07:00
|
|
|
const PROTOC_ENVAR: &str = "PROTOC";
|
|
|
|
if std::env::var(PROTOC_ENVAR).is_err() {
|
2022-08-08 08:42:12 -07:00
|
|
|
#[cfg(not(windows))]
|
2022-08-02 15:37:28 -07:00
|
|
|
std::env::set_var(PROTOC_ENVAR, protobuf_src::protoc());
|
|
|
|
}
|
|
|
|
|
2021-07-10 12:50:55 -07:00
|
|
|
let proto_base_path = std::path::PathBuf::from("proto");
|
|
|
|
let proto_files = ["confirmed_block.proto", "transaction_by_addr.proto"];
|
|
|
|
let mut protos = Vec::new();
|
|
|
|
for proto_file in &proto_files {
|
|
|
|
let proto = proto_base_path.join(proto_file);
|
2023-08-24 12:44:19 -07:00
|
|
|
println!("cargo:rerun-if-changed={}", proto.display());
|
2021-07-10 12:50:55 -07:00
|
|
|
protos.push(proto);
|
|
|
|
}
|
2020-10-15 17:04:10 -07:00
|
|
|
|
|
|
|
tonic_build::configure()
|
|
|
|
.build_client(true)
|
|
|
|
.build_server(false)
|
2021-12-01 15:28:50 -08:00
|
|
|
.type_attribute(
|
|
|
|
"TransactionErrorType",
|
2022-08-31 14:07:29 -07:00
|
|
|
"#[cfg_attr(test, derive(enum_iterator::Sequence))]",
|
2021-12-01 15:28:50 -08:00
|
|
|
)
|
|
|
|
.type_attribute(
|
|
|
|
"InstructionErrorType",
|
2022-08-31 14:07:29 -07:00
|
|
|
"#[cfg_attr(test, derive(enum_iterator::Sequence))]",
|
2021-12-01 15:28:50 -08:00
|
|
|
)
|
2021-07-10 12:50:55 -07:00
|
|
|
.compile(&protos, &[proto_base_path])
|
2020-10-15 17:04:10 -07:00
|
|
|
}
|