Skip to content

Commit 6bc500c

Browse files
committed
fix(rvps): fix feature configuration and migrate to tonic-prost-build
This commit addresses two issues: 1. Starting from version 0.14.0, prost, tonic-prost, and tonic-prost-build libraries need to work together to enable protobuf compilation. This change migrates from tonic-build to tonic-prost-build in build.rs to ensure compatibility with the 0.14.x series. 2. The rvps crate's feature configuration had issues where building with default features disabled would fail. To fix this, several dependencies (prost, tonic, tonic-prost, config, tokio) are now required dependencies instead of optional ones, ensuring the crate can build even when default features are disabled. Changes: - Replace tonic-build with tonic-prost-build in build.rs - Make prost, tonic, tonic-prost, config, and tokio required dependencies - Remove these dependencies from the 'bin' feature since they are now always included Signed-off-by: Xynnn007 <[email protected]>
1 parent 14e5342 commit 6bc500c

File tree

3 files changed

+22
-21
lines changed

3 files changed

+22
-21
lines changed

rvps/Cargo.toml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2021"
66
[features]
77
default = [ "bin" ]
88
# Used to build rvps binary
9-
bin = [ "clap", "config", "env_logger", "prost", "shadow-rs", "tokio", "tonic" ]
9+
bin = [ "clap", "env_logger", "shadow-rs" ]
1010

1111
# Support in-toto provenance (not ready)
1212
in-toto =[ "path-clean", "sha2" ]
@@ -28,11 +28,11 @@ base64.workspace = true
2828
cfg-if.workspace = true
2929
chrono = { workspace = true, features = [ "serde" ] }
3030
clap = { workspace = true, optional = true }
31-
config = { workspace = true, optional = true }
31+
config.workspace = true
3232
env_logger = { workspace = true, optional = true }
3333
log.workspace = true
3434
path-clean = { version = "1.0.1", optional = true }
35-
prost = { workspace = true, optional = true }
35+
prost.workspace = true
3636
roxmltree = "0.21.1"
3737
serde.workspace = true
3838
serde_json.workspace = true
@@ -41,12 +41,13 @@ shadow-rs = { workspace = true, optional = true }
4141
sled = "0.34.7"
4242
strum.workspace = true
4343
tempfile.workspace = true
44-
tokio = { workspace = true, optional = true }
45-
tonic = { workspace = true, optional = true }
44+
tokio.workspace = true
45+
tonic.workspace = true
46+
tonic-prost.workspace = true
4647

4748
[build-dependencies]
4849
shadow-rs.workspace = true
49-
tonic-build.workspace = true
50+
tonic-prost-build.workspace = true
5051

5152
[dev-dependencies]
5253
assert-json-diff.workspace = true

rvps/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn real_main() -> Result<(), String> {
3131
}
3232

3333
#[cfg(feature = "rebuild-grpc-protos")]
34-
tonic_build::configure()
34+
tonic_prost_build::configure()
3535
.protoc_arg("--experimental_allow_proto3_optional")
3636
.out_dir("src/rvps_api")
3737
.compile_protos(&["../protos/reference.proto"], &["../protos"])

rvps/src/rvps_api/reference.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
// This file is @generated by prost-build.
2-
#[derive(Clone, PartialEq, ::prost::Message)]
2+
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
33
pub struct ReferenceValueQueryRequest {
44
#[prost(string, tag = "1")]
55
pub reference_value_id: ::prost::alloc::string::String,
66
}
7-
#[derive(Clone, PartialEq, ::prost::Message)]
7+
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
88
pub struct ReferenceValueQueryResponse {
99
#[prost(string, optional, tag = "1")]
1010
pub reference_value_results: ::core::option::Option<::prost::alloc::string::String>,
1111
}
12-
#[derive(Clone, PartialEq, ::prost::Message)]
12+
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
1313
pub struct ReferenceValueRegisterRequest {
1414
#[prost(string, tag = "1")]
1515
pub message: ::prost::alloc::string::String,
1616
}
17-
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
17+
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
1818
pub struct ReferenceValueRegisterResponse {}
1919
/// Generated client implementations.
2020
pub mod reference_value_provider_service_client {
@@ -44,7 +44,7 @@ pub mod reference_value_provider_service_client {
4444
}
4545
impl<T> ReferenceValueProviderServiceClient<T>
4646
where
47-
T: tonic::client::GrpcService<tonic::body::BoxBody>,
47+
T: tonic::client::GrpcService<tonic::body::Body>,
4848
T::Error: Into<StdError>,
4949
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
5050
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
@@ -65,12 +65,12 @@ pub mod reference_value_provider_service_client {
6565
F: tonic::service::Interceptor,
6666
T::ResponseBody: Default,
6767
T: tonic::codegen::Service<
68-
http::Request<tonic::body::BoxBody>,
68+
http::Request<tonic::body::Body>,
6969
Response = http::Response<
70-
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
70+
<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
7171
>,
7272
>,
73-
<T as tonic::codegen::Service<http::Request<tonic::body::BoxBody>>>::Error:
73+
<T as tonic::codegen::Service<http::Request<tonic::body::Body>>>::Error:
7474
Into<StdError> + std::marker::Send + std::marker::Sync,
7575
{
7676
ReferenceValueProviderServiceClient::new(InterceptedService::new(inner, interceptor))
@@ -114,7 +114,7 @@ pub mod reference_value_provider_service_client {
114114
self.inner.ready().await.map_err(|e| {
115115
tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
116116
})?;
117-
let codec = tonic::codec::ProstCodec::default();
117+
let codec = tonic_prost::ProstCodec::default();
118118
let path = http::uri::PathAndQuery::from_static(
119119
"/reference.ReferenceValueProviderService/QueryReferenceValue",
120120
);
@@ -135,7 +135,7 @@ pub mod reference_value_provider_service_client {
135135
self.inner.ready().await.map_err(|e| {
136136
tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
137137
})?;
138-
let codec = tonic::codec::ProstCodec::default();
138+
let codec = tonic_prost::ProstCodec::default();
139139
let path = http::uri::PathAndQuery::from_static(
140140
"/reference.ReferenceValueProviderService/RegisterReferenceValue",
141141
);
@@ -237,7 +237,7 @@ pub mod reference_value_provider_service_server {
237237
B: Body + std::marker::Send + 'static,
238238
B::Error: Into<StdError> + std::marker::Send + 'static,
239239
{
240-
type Response = http::Response<tonic::body::BoxBody>;
240+
type Response = http::Response<tonic::body::Body>;
241241
type Error = std::convert::Infallible;
242242
type Future = BoxFuture<Self::Response, Self::Error>;
243243
fn poll_ready(
@@ -278,7 +278,7 @@ pub mod reference_value_provider_service_server {
278278
let inner = self.inner.clone();
279279
let fut = async move {
280280
let method = QueryReferenceValueSvc(inner);
281-
let codec = tonic::codec::ProstCodec::default();
281+
let codec = tonic_prost::ProstCodec::default();
282282
let mut grpc = tonic::server::Grpc::new(codec)
283283
.apply_compression_config(
284284
accept_compression_encodings,
@@ -323,7 +323,7 @@ pub mod reference_value_provider_service_server {
323323
let inner = self.inner.clone();
324324
let fut = async move {
325325
let method = RegisterReferenceValueSvc(inner);
326-
let codec = tonic::codec::ProstCodec::default();
326+
let codec = tonic_prost::ProstCodec::default();
327327
let mut grpc = tonic::server::Grpc::new(codec)
328328
.apply_compression_config(
329329
accept_compression_encodings,
@@ -339,7 +339,7 @@ pub mod reference_value_provider_service_server {
339339
Box::pin(fut)
340340
}
341341
_ => Box::pin(async move {
342-
let mut response = http::Response::new(empty_body());
342+
let mut response = http::Response::new(tonic::body::Body::default());
343343
let headers = response.headers_mut();
344344
headers.insert(
345345
tonic::Status::GRPC_STATUS,

0 commit comments

Comments
 (0)