forked from prometheus/client_rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
36 lines (27 loc) · 1.05 KB
/
build.rs
File metadata and controls
36 lines (27 loc) · 1.05 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
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
#[cfg(any(feature = "prometheus_protobuf", feature = "openmetrics_protobuf"))]
compile_protos()?;
Ok(())
}
#[allow(clippy::vec_init_then_push)] // False positive due to feature flags
#[cfg(any(feature = "prometheus_protobuf", feature = "openmetrics_protobuf"))]
fn compile_protos() -> Result<(), Box<dyn Error>> {
let mut protos = Vec::new();
#[cfg(feature = "prometheus_protobuf")]
protos.push("src/encoding/proto/metrics.proto");
#[cfg(feature = "openmetrics_protobuf")]
protos.push("src/encoding/proto/openmetrics_data_model.proto");
let includes = ["src/encoding/proto/"];
#[cfg(feature = "protobuf-protox")]
prost_build::compile_fds(protox::compile(&protos, includes)?)?;
#[cfg(not(feature = "protobuf-protox"))]
prost_build::compile_protos(&protos, &includes)?;
for path in &protos {
println!("cargo:rerun-if-changed={}", path);
}
for path in &includes {
println!("cargo:rerun-if-changed={}", path);
}
Ok(())
}