Skip to content

Commit

Permalink
build: delete box_pointer patch for ttrpc build scripts
Browse files Browse the repository at this point in the history
Upstream ttrpc crate has fixed the usage of boxed pointers. Thus we do
not need to declare explicitly the lint error ignorance.

Signed-off-by: Xynnn007 <[email protected]>
  • Loading branch information
Xynnn007 committed Oct 3, 2024
1 parent 95521ea commit 78d6fd6
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 105 deletions.
28 changes: 0 additions & 28 deletions api-server-rest/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,23 +88,6 @@ fn main() -> std::io::Result<()> {
];
let protobuf_customized = ProtobufCustomize::default().gen_mod_rs(false);

use std::fs::File;
use std::io::{Read, Write};

fn replace_text_in_file(file_name: &str, from: &str, to: &str) -> Result<(), std::io::Error> {
let mut src = File::open(file_name)?;
let mut contents = String::new();
src.read_to_string(&mut contents).unwrap();
drop(src);

let new_contents = contents.replace(from, to);

let mut dst = File::create(file_name)?;
dst.write_all(new_contents.as_bytes())?;

Ok(())
}

Codegen::new()
.out_dir("src/ttrpc_proto")
.inputs(&protos)
Expand All @@ -118,17 +101,6 @@ fn main() -> std::io::Result<()> {
.run()
.expect("Generate ttrpc protocol code failed.");

// Fix clippy warnings of code generated from ttrpc_codegen
replace_text_in_file(
"src/ttrpc_proto/attestation_agent_ttrpc.rs",
"#![allow(box_pointers)]\n",
"",
)?;
replace_text_in_file(
"src/ttrpc_proto/confidential_data_hub_ttrpc.rs",
"#![allow(box_pointers)]\n",
"",
)?;
generate_openapi_document().expect("Generate restful OpenAPI yaml failed.");

Ok(())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file is generated by rust-protobuf 3.5.0. Do not edit
// This file is generated by rust-protobuf 3.5.1. Do not edit
// .proto file is parsed by pure
// @generated

Expand All @@ -9,7 +9,6 @@
#![allow(unused_attributes)]
#![cfg_attr(rustfmt, rustfmt::skip)]

#![allow(box_pointers)]
#![allow(dead_code)]
#![allow(missing_docs)]
#![allow(non_camel_case_types)]
Expand All @@ -23,7 +22,7 @@
/// Generated files are compatible only with the same version
/// of protobuf runtime.
const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_3_5_0;
const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_3_5_1;

// @@protoc_insertion_point(message:attestation_agent.GetEvidenceRequest)
#[derive(PartialEq,Clone,Default,Debug)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// This file is generated by ttrpc-compiler 0.6.2. Do not edit
// This file is generated by ttrpc-compiler 0.6.3. Do not edit
// @generated

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unknown_lints)]
#![allow(clipto_camel_casepy)]
#![allow(box_pointers)]
#![allow(dead_code)]
#![allow(missing_docs)]
#![allow(non_camel_case_types)]
Expand Down Expand Up @@ -64,7 +63,7 @@ impl AttestationAgentServiceClient {
}

struct GetEvidenceMethod {
service: Arc<Box<dyn AttestationAgentService + Send + Sync>>,
service: Arc<dyn AttestationAgentService + Send + Sync>,
}

#[async_trait]
Expand All @@ -75,7 +74,7 @@ impl ::ttrpc::r#async::MethodHandler for GetEvidenceMethod {
}

struct GetTokenMethod {
service: Arc<Box<dyn AttestationAgentService + Send + Sync>>,
service: Arc<dyn AttestationAgentService + Send + Sync>,
}

#[async_trait]
Expand All @@ -86,7 +85,7 @@ impl ::ttrpc::r#async::MethodHandler for GetTokenMethod {
}

struct ExtendRuntimeMeasurementMethod {
service: Arc<Box<dyn AttestationAgentService + Send + Sync>>,
service: Arc<dyn AttestationAgentService + Send + Sync>,
}

#[async_trait]
Expand All @@ -97,7 +96,7 @@ impl ::ttrpc::r#async::MethodHandler for ExtendRuntimeMeasurementMethod {
}

struct CheckInitDataMethod {
service: Arc<Box<dyn AttestationAgentService + Send + Sync>>,
service: Arc<dyn AttestationAgentService + Send + Sync>,
}

#[async_trait]
Expand All @@ -108,7 +107,7 @@ impl ::ttrpc::r#async::MethodHandler for CheckInitDataMethod {
}

struct UpdateConfigurationMethod {
service: Arc<Box<dyn AttestationAgentService + Send + Sync>>,
service: Arc<dyn AttestationAgentService + Send + Sync>,
}

#[async_trait]
Expand All @@ -119,7 +118,7 @@ impl ::ttrpc::r#async::MethodHandler for UpdateConfigurationMethod {
}

struct GetTeeTypeMethod {
service: Arc<Box<dyn AttestationAgentService + Send + Sync>>,
service: Arc<dyn AttestationAgentService + Send + Sync>,
}

#[async_trait]
Expand Down Expand Up @@ -151,7 +150,7 @@ pub trait AttestationAgentService: Sync {
}
}

pub fn create_attestation_agent_service(service: Arc<Box<dyn AttestationAgentService + Send + Sync>>) -> HashMap<String, ::ttrpc::r#async::Service> {
pub fn create_attestation_agent_service(service: Arc<dyn AttestationAgentService + Send + Sync>) -> HashMap<String, ::ttrpc::r#async::Service> {
let mut ret = HashMap::new();
let mut methods = HashMap::new();
let streams = HashMap::new();
Expand Down
5 changes: 0 additions & 5 deletions attestation-agent/kbs_protocol/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
"client: client",
"client",
)?;
replace_text_in_file(
"src/token_provider/aa/attestation_agent_ttrpc.rs",
"#![allow(box_pointers)]\n",
"",
)?;
}

Ok(())
Expand Down
10 changes: 0 additions & 10 deletions confidential-data-hub/hub/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,6 @@ fn main() {

// Fix clippy warnings of code generated from ttrpc_codegen
replace_text_in_file("src/bin/protos/api_ttrpc.rs", "client: client", "client");
replace_text_in_file(
"src/bin/protos/api_ttrpc.rs",
"#![allow(box_pointers)]\n",
"",
);
replace_text_in_file(
"src/bin/protos/keyprovider_ttrpc.rs",
"#![allow(box_pointers)]\n",
"",
);
}

#[cfg(feature = "bin")]
Expand Down
58 changes: 13 additions & 45 deletions image-rs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,21 @@
// SPDX-License-Identifier: Apache-2.0
//

fn main() -> Result<(), Box<dyn std::error::Error>> {
fn main() {
#[cfg(feature = "tonic-build")]
tonic_build::compile_protos("./protos/getresource.proto").expect("tonic build");

#[cfg(feature = "ttrpc-codegen")]
{
use std::fs::File;
use std::io::{Read, Write};

fn replace_text_in_file(
file_name: &str,
from: &str,
to: &str,
) -> Result<(), std::io::Error> {
let mut src = File::open(file_name)?;
let mut contents = String::new();
src.read_to_string(&mut contents).unwrap();
drop(src);

let new_contents = contents.replace(from, to);

let mut dst = File::create(file_name)?;
dst.write_all(new_contents.as_bytes())?;

Ok(())
}

ttrpc_codegen::Codegen::new()
.out_dir("./src/resource/kbs/ttrpc_proto")
.input("./protos/getresource.proto")
.include("./protos")
.rust_protobuf()
.customize(ttrpc_codegen::Customize {
async_all: true,
..Default::default()
})
.rust_protobuf_customize(ttrpc_codegen::ProtobufCustomize::default().gen_mod_rs(false))
.run()
.expect("ttrpc build");

// Fix clippy warnings of code generated from ttrpc_codegen
replace_text_in_file(
"src/resource/kbs/ttrpc_proto/getresource_ttrpc.rs",
"#![allow(box_pointers)]\n",
"",
)?;
}

Ok(())
ttrpc_codegen::Codegen::new()
.out_dir("./src/resource/kbs/ttrpc_proto")
.input("./protos/getresource.proto")
.include("./protos")
.rust_protobuf()
.customize(ttrpc_codegen::Customize {
async_all: true,
..Default::default()
})
.rust_protobuf_customize(ttrpc_codegen::ProtobufCustomize::default().gen_mod_rs(false))
.run()
.expect("ttrpc build");
}
5 changes: 0 additions & 5 deletions ocicrypt-rs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
"client: client",
"client",
)?;
replace_text_in_file(
"src/utils/ttrpc/keyprovider_ttrpc.rs",
"#![allow(box_pointers)]\n",
"",
)?;
}

Ok(())
Expand Down

0 comments on commit 78d6fd6

Please sign in to comment.