Skip to content

Commit

Permalink
fix(sgx-dcap-quoteverify-sys): successfull build with SGX_SDK unset
Browse files Browse the repository at this point in the history
If `SGX_SDK` is unset, a single `-I` argument is passed to the C
compiler, which leads to an unsuccesful build, even if the needed header
files are present in the standard include path.

Signed-off-by: Harald Hoyer <[email protected]>
  • Loading branch information
haraldh authored and lzha101 committed Jul 25, 2023
1 parent b1cdd25 commit e7604e0
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,25 @@ fn main() {
// Tell cargo to invalidate the built crate whenever the wrapper changes
println!("cargo:rerun-if-changed=bindings.h");


// The bindgen::Builder is the main entry point
// to bindgen, and lets you build up options for
// the resulting bindings.
let mut builder = bindgen::Builder::default();

// Set sdk to search path if SGX_SDK is in environment variable
let mut sdk_inc = String::from("-I");
if let Ok(val) = env::var("SGX_SDK") {
let mut sdk_inc = String::from("-I");
sdk_inc.push_str(&val);
sdk_inc.push_str("/include/");
// Include search path
builder = builder.clang_arg(sdk_inc);
}

// The bindgen::Builder is the main entry point
// to bindgen, and lets you build up options for
// the resulting bindings.
let bindings = bindgen::Builder::default()
let bindings = builder
// The input header we would like to generate
// bindings for.
.header("bindings.h")
// Include search path
.clang_arg(sdk_inc)
// Convert C enum to Rust enum
.rustified_enum("_quote3_error_t")
.rustified_enum("_sgx_ql_request_policy")
Expand Down

0 comments on commit e7604e0

Please sign in to comment.