File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,6 +6,9 @@ The `build.rs` script in this library depends upon the
66[ Protocol Buffers compiler] [ protoc ] . Be sure that ` protoc ` is installed and
77available within your ` PATH ` .
88
9+ If you enable the off-by-default ` protobuf-protox ` feature, the build uses
10+ ` protox ` instead and does not require ` protoc ` .
11+
912[ protoc ] : https://docs.rs/prost-build/latest/prost_build/#sourcing-protoc
1013
1114## Python Dependencies
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ documentation = "https://docs.rs/prometheus-client"
1313[features ]
1414default = []
1515protobuf = [" dep:prost" , " dep:prost-types" , " dep:prost-build" ]
16+ protobuf-protox = [" protobuf" , " dep:protox" ]
1617
1718# This feature provides additional APIs for testing downstream code using
1819# `prometheus-client`.
@@ -50,6 +51,7 @@ http-body-util = "0.1.1"
5051
5152[build-dependencies ]
5253prost-build = { version = " 0.14" , optional = true }
54+ protox = { version = " 0.9.1" , optional = true }
5355
5456[[bench ]]
5557name = " baseline"
Original file line number Diff line number Diff line change 1- use std:: io :: Result ;
1+ use std:: error :: Error ;
22
3- fn main ( ) -> Result < ( ) > {
3+ fn main ( ) -> Result < ( ) , Box < dyn Error > > {
44 #[ cfg( feature = "protobuf" ) ]
5- prost_build:: compile_protos (
6- & [ "src/encoding/proto/openmetrics_data_model.proto" ] ,
7- & [ "src/encoding/proto/" ] ,
8- ) ?;
5+ compile_protos ( ) ?;
6+
7+ Ok ( ( ) )
8+ }
9+
10+ #[ cfg( feature = "protobuf" ) ]
11+ fn compile_protos ( ) -> Result < ( ) , Box < dyn Error > > {
12+ let protos = [ "src/encoding/proto/openmetrics_data_model.proto" ] ;
13+ let includes = [ "src/encoding/proto/" ] ;
14+
15+ #[ cfg( feature = "protobuf-protox" ) ]
16+ prost_build:: compile_fds ( protox:: compile ( protos, includes) ?) ?;
17+
18+ #[ cfg( not( feature = "protobuf-protox" ) ) ]
19+ prost_build:: compile_protos ( & protos, & includes) ?;
920
1021 Ok ( ( ) )
1122}
You can’t perform that action at this time.
0 commit comments