This repository was archived by the owner on Apr 4, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathbuild.rs
More file actions
46 lines (40 loc) · 2.09 KB
/
Copy pathbuild.rs
File metadata and controls
46 lines (40 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// build.rs
use std::path::Path;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Declare the build_protos cfg flag for cargo check-cfg
println!("cargo::rustc-check-cfg=cfg(build_protos)");
// Tell Cargo to rerun this build script if migrations change
println!("cargo:rerun-if-changed=migrations");
// Rerun if proto definitions change
println!("cargo:rerun-if-changed=vendor/snapchain/proto/definitions");
let proto_dir = "vendor/snapchain/proto/definitions";
// Only compile protos if the submodule exists (not available in crates.io package)
// When publishing to crates.io, use the pre-generated src/proto.gen.rs instead
if Path::new(proto_dir).exists() {
println!("cargo:rustc-cfg=build_protos");
tonic_prost_build::configure()
.type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]")
// Add an attribute to silence large_enum_variant warnings in generated code
.type_attribute(".", "#[allow(clippy::large_enum_variant)]")
.build_server(false)
.compile_protos(
&[
"vendor/snapchain/proto/definitions/admin_rpc.proto",
"vendor/snapchain/proto/definitions/blocks.proto",
"vendor/snapchain/proto/definitions/gossip.proto",
"vendor/snapchain/proto/definitions/hub_event.proto",
"vendor/snapchain/proto/definitions/message.proto",
"vendor/snapchain/proto/definitions/node_state.proto",
"vendor/snapchain/proto/definitions/onchain_event.proto",
"vendor/snapchain/proto/definitions/request_response.proto",
"vendor/snapchain/proto/definitions/rpc.proto",
"vendor/snapchain/proto/definitions/sync_trie.proto",
"vendor/snapchain/proto/definitions/username_proof.proto",
],
&[proto_dir],
)?;
} else {
println!("cargo:warning=Proto submodule not found, using pre-generated src/proto.gen.rs");
}
Ok(())
}