Skip to content

Commit

Permalink
Improve build.rs (#535)
Browse files Browse the repository at this point in the history
  • Loading branch information
rkuris authored Feb 16, 2024
1 parent dd7ef9d commit 3c69b74
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions grpc-testtool/build.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
// Copyright (C) 2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE.md for licensing terms.

use std::path::PathBuf;

fn main() -> Result<(), Box<dyn std::error::Error>> {
tonic_build::compile_protos("proto/sync/sync.proto")?;
tonic_build::compile_protos("proto/rpcdb/rpcdb.proto")?;
tonic_build::compile_protos("proto/process-server/process-server.proto")?;
// we want to import these proto files
let import_protos = ["sync", "rpcdb", "process-server"];

let protos: Box<[PathBuf]> = import_protos
.into_iter()
.map(|proto| PathBuf::from(format!("proto/{proto}/{proto}.proto")))
.collect();

// go through each proto and build it, also let cargo know we rerun this if the file changes
for proto in protos.iter() {
tonic_build::compile_protos(proto)?;

// this improves recompile times; we only rerun tonic if any of these files change
println!("cargo:rerun-if-changed={}", proto.display());
}

Ok(())
}

0 comments on commit 3c69b74

Please sign in to comment.