Skip to content
This repository was archived by the owner on Jun 21, 2020. It is now read-only.

Commit 123e346

Browse files
committed
Added bindgen to Makefile and updated the EDL
1 parent ea02f41 commit 123e346

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

enigma-core/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ $(Signed_RustEnclave_Name): $(RustEnclave_Name)
139139
@echo "SIGN => $@"
140140

141141
.PHONY: enclave
142-
enclave:
142+
enclave: $(Enclave_EDL_Files)
143143
mkdir -p ./lib
144144
$(MAKE) -C ./enclave/ CARGO_FLAGS=$(App_Rust_Flags) Rust_target_dir=$(Rust_target_dir)
145145

enigma-core/enclave/Makefile

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@
22
Rust_Enclave_Name := libenclave.a
33
Rust_Enclave_Files := $(wildcard src/*.rs)
44

5-
.PHONY: all
5+
BINDGEN_OUTPUT_FILE := src/auto_ffi.rs
6+
BINDGEN_RAW_LINES := "\#![allow(dead_code)] use enigma_types::*; use sgx_types::*;"
7+
BINDGEN_CLANG_FLAGS := -I/opt/sgxsdk/include -I$(HOME)/sgx/edl
8+
BINDGEN_FLAGS := --default-enum-style=rust --rust-target=nightly \
9+
--no-recursive-whitelist --use-array-pointers-in-arguments \
10+
--whitelist-function ocall_.* --raw-line $(BINDGEN_RAW_LINES)
611

7-
all: $(Rust_Enclave_Name)
12+
13+
all: bindgen $(Rust_Enclave_Name)
814

915
$(Rust_Enclave_Name): $(Rust_Enclave_Files)
1016
ifeq ($(XARGO_SGX), 1)
@@ -13,4 +19,12 @@ ifeq ($(XARGO_SGX), 1)
1319
else
1420
cargo build $(CARGO_FLAGS)
1521
cp ./target/$(Rust_target_dir)/libenigmacoreenclave.a ../lib/libenclave.a
16-
endif
22+
endif
23+
24+
25+
.PHONY: bindgen
26+
bindgen: Enclave_t.h
27+
cargo build -p enigma-types # Meant to make sure `enigma-types.h` already exists and can be included.
28+
echo $(BINDGEN_RAW_LINES)
29+
bindgen Enclave_t.h $(BINDGEN_FLAGS) -- $(BINDGEN_CLANG_FLAGS) > $(BINDGEN_OUTPUT_FILE)
30+
rustfmt $(BINDGEN_OUTPUT_FILE)

0 commit comments

Comments
 (0)