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

Commit

Permalink
Added bindgen to Makefile and updated the EDL
Browse files Browse the repository at this point in the history
  • Loading branch information
elichai committed May 28, 2019
1 parent ea02f41 commit 123e346
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion enigma-core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ $(Signed_RustEnclave_Name): $(RustEnclave_Name)
@echo "SIGN => $@"

.PHONY: enclave
enclave:
enclave: $(Enclave_EDL_Files)
mkdir -p ./lib
$(MAKE) -C ./enclave/ CARGO_FLAGS=$(App_Rust_Flags) Rust_target_dir=$(Rust_target_dir)

Expand Down
20 changes: 17 additions & 3 deletions enigma-core/enclave/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@
Rust_Enclave_Name := libenclave.a
Rust_Enclave_Files := $(wildcard src/*.rs)

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

all: $(Rust_Enclave_Name)

all: bindgen $(Rust_Enclave_Name)

$(Rust_Enclave_Name): $(Rust_Enclave_Files)
ifeq ($(XARGO_SGX), 1)
Expand All @@ -13,4 +19,12 @@ ifeq ($(XARGO_SGX), 1)
else
cargo build $(CARGO_FLAGS)
cp ./target/$(Rust_target_dir)/libenigmacoreenclave.a ../lib/libenclave.a
endif
endif


.PHONY: bindgen
bindgen: Enclave_t.h
cargo build -p enigma-types # Meant to make sure `enigma-types.h` already exists and can be included.
echo $(BINDGEN_RAW_LINES)
bindgen Enclave_t.h $(BINDGEN_FLAGS) -- $(BINDGEN_CLANG_FLAGS) > $(BINDGEN_OUTPUT_FILE)
rustfmt $(BINDGEN_OUTPUT_FILE)

0 comments on commit 123e346

Please sign in to comment.