-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
17 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(()) | ||
} |