Skip to content

Commit f54607f

Browse files
committed
libsgxstep: Raw bindings for Rust
1 parent ce022db commit f54607f

File tree

5 files changed

+425
-0
lines changed

5 files changed

+425
-0
lines changed

sgxstep-sys/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
target/

sgxstep-sys/Cargo.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[package]
2+
name = "sgxstep-sys"
3+
version = "0.1.0"
4+
edition = "2021"
5+
links = "libsgxstep"
6+
authors = ["Daan Vanoverloop", "Jo Van Bulck"]
7+
license = "GPL-3.0"
8+
repository = "https://github.com/jovanbulck/sgx-step/"
9+
10+
[features]
11+
default = ["build"]
12+
build = ["cc", "glob"]
13+
14+
[dependencies]
15+
16+
[build-dependencies]
17+
cc = { version = "1.0", optional = true }
18+
glob = { version = "0.3", optional = true }
19+
bindgen = "0.69"
20+

sgxstep-sys/build.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
use std::{env, path::PathBuf};
2+
3+
fn main() {
4+
#[cfg(feature = "build")]
5+
{
6+
cc::Build::new()
7+
.files(
8+
glob::glob("../libsgxstep/*.c")
9+
.unwrap()
10+
.filter_map(|e| e.ok()),
11+
)
12+
.cargo_metadata(true)
13+
.compile("sgxstep");
14+
}
15+
16+
let bindings = bindgen::Builder::default()
17+
.header("wrapper.h")
18+
.clang_arg(format!(
19+
"-I{}",
20+
env::var("LIBSGXSTEP").expect("missing LIBSGXSTEP environment variable")
21+
))
22+
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
23+
.generate()
24+
.expect("Unable to generate bindings");
25+
26+
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
27+
bindings
28+
.write_to_file(out_path.join("bindings.rs"))
29+
.expect("Couldn't write bindings!");
30+
}

0 commit comments

Comments
 (0)