storage-proto: Rework source generation (#18584)

(cherry picked from commit 899b09872b)

Co-authored-by: Trent Nelson <trent@solana.com>
This commit is contained in:
mergify[bot]
2021-07-11 03:33:56 +00:00
committed by GitHub
parent 6abd5fbc3e
commit c5374095e6
6 changed files with 14 additions and 23 deletions

View File

@@ -1,24 +1,16 @@
fn main() -> Result<(), std::io::Error> {
let manifest_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let out_dir = manifest_dir.join("proto");
let proto_files = manifest_dir.join("src");
std::fs::create_dir_all(out_dir.clone())?;
println!("Protobuf directory: {}", proto_files.display());
println!("output directory: {}", out_dir.display());
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);
println!("cargo::rerun-if-changed={}", proto.display());
protos.push(proto);
}
tonic_build::configure()
.build_client(true)
.build_server(false)
.format(true)
.out_dir(&out_dir)
.compile(
&[
proto_files.join("confirmed_block.proto"),
proto_files.join("transaction_by_addr.proto"),
],
&[proto_files],
)
.compile(&protos, &[proto_base_path])
}