-
Notifications
You must be signed in to change notification settings - Fork 16
Prepare some small changes for SGX attestation #163
Conversation
3581f7e
to
6aca85b
Compare
6aca85b
to
41de671
Compare
build.rs
Outdated
protobuf_codegen_pure::Codegen::new() | ||
.out_dir("src/protobuf") | ||
.inputs(&["src/protobuf/aesm-proto.proto"]) | ||
.include("src/protobuf") | ||
.run() | ||
.expect("Protobuf codegen failed"); | ||
|
||
Command::new("mv") | ||
.current_dir(&Path::new(CRATE).join("src/protobuf")) | ||
.arg("aesm_proto.rs") | ||
.arg("mod.rs") | ||
.status() | ||
.unwrap_or_else(|_| panic!("Could not rename aesm proto file")); | ||
|
||
let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap()); | ||
let out_dir_bin = out_dir.join("bin"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protobuf_codegen_pure::Codegen::new() | |
.out_dir("src/protobuf") | |
.inputs(&["src/protobuf/aesm-proto.proto"]) | |
.include("src/protobuf") | |
.run() | |
.expect("Protobuf codegen failed"); | |
Command::new("mv") | |
.current_dir(&Path::new(CRATE).join("src/protobuf")) | |
.arg("aesm_proto.rs") | |
.arg("mod.rs") | |
.status() | |
.unwrap_or_else(|_| panic!("Could not rename aesm proto file")); | |
let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap()); | |
let out_dir_bin = out_dir.join("bin"); | |
let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap()); | |
let out_dir_proto = out_dir.join("protos"); | |
match std::fs::create_dir(&out_dir_proto) { | |
Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => {} | |
Err(e) => { | |
eprintln!("Can't create {:#?} : {:#?}", out_dir_proto, e); | |
std::process::exit(1); | |
} | |
Ok(_) => {} | |
} | |
protobuf_codegen_pure::Codegen::new() | |
.out_dir(&out_dir_proto) | |
.inputs(&["src/protobuf/aesm-proto.proto"]) | |
.include("src/protobuf") | |
.customize(protobuf_codegen_pure::Customize { | |
gen_mod_rs: Some(true), | |
..Default::default() | |
}) | |
.run() | |
.expect("Protobuf codegen failed"); | |
let out_dir_bin = out_dir.join("bin"); |
We should not generate code into the current source code tree. Better generate into $OUT_DIR.
See also:
stepancheg/rust-protobuf#324
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I'm looking for info on gen_mod_rs
but it's not very obvious. I assume it lets you name the output mod.rs
, which is what I was trying to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I see from the link this is how it's normally done: "And for now, you may generate that mod.rs in OUT_DIR file from build.rs, and include generated mod.rs from the src directory."
src/protobuf/mod.rs
Outdated
//! This is a placeholder file for the Rust stuctures generated from | ||
//! aesm-proto.proto during build. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//! This is a placeholder file for the Rust stuctures generated from | |
//! aesm-proto.proto during build. | |
//! Provides all generated protobuf modules | |
include!(concat!(env!("OUT_DIR"), "/protos/mod.rs")); |
This then includes the generated protobuf modules.
You will then have to use crate::protobuf::aesm_proto
.
This update includes changes to attestation types that make them usable in the SGX shim. Signed-off-by: Lily Sturmann <lsturman@redhat.com>
This generates a Rust file from Intel's aesm-proto.proto that can be used as a module to communicate with the AESM daemon. Signed-off-by: Lily Sturmann <lsturman@redhat.com>
41de671
to
983b239
Compare
I pulled the error handling for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not confirm the correctness of Intel's proto file
We will need an updated version of the SGX dependency and we'll need to use Intel's
aesm-proto
file to generate Rust structures during build.