Skip to content

Commit

Permalink
tweak installation
Browse files Browse the repository at this point in the history
  • Loading branch information
Fan Zhang committed Nov 15, 2017
1 parent 413f642 commit eeae37e
Show file tree
Hide file tree
Showing 83 changed files with 25,212 additions and 1,320 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,8 @@ $RECYCLE.BIN/

.idea
cmake-build-debug

*_u.c
*_u.h
*_t.c
*_t.h
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# need 3.0 for multiple line strings
cmake_minimum_required(VERSION 3.0)
project(mbedtls_SGX "C")
project(mbedtls_SGX "C" "CXX")

set(MBEDTLS_VERSION 2.6.0)

Expand Down
9 changes: 9 additions & 0 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
get_filename_component(MBEDTLS_SGX_ROOT_DIR ".." REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")

set(MBEDTLS_SGX_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}-${MBEDTLS_VERSION})
set(MBEDTLS_SGX_INCLUDE_DIR ${MBEDTLS_SGX_ROOT}/include)
set(MBEDTLS_SGX_LIBRARY_DIR ${MBEDTLS_SGX_ROOT}/libs)
set(MBEDTLS_SGX_LIB_U ${MBEDTLS_SGX_LIBRARY_DIR}/libmbedtls_SGX_u.a)
set(MBEDTLS_SGX_LIB_T ${MBEDTLS_SGX_LIBRARY_DIR}/libmbedtls_SGX_t.a)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

add_subdirectory(untrusted)
add_subdirectory(enclave)
26 changes: 10 additions & 16 deletions example/enclave/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
set(SOURCE_FILES
Enclave_t.c
Enclave_t.h
ecalls.cpp
Log.c
pprint.c
s_client.c
s_server.c
ssl_conn_hdlr.cpp
)
ssl_conn_hdlr.cpp)

add_definitions(-DENCLAVE_STD_ALT)

Expand All @@ -18,11 +16,9 @@ add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/Enclave_t.c
COMMAND ${SGX_EDGER8R} --trusted Enclave.edl
--search-path ${SGX_SDK}/include
--search-path ${MBEDTLS_SGX_ROOT_DIR}/lib
--search-path ${CMAKE_CURRENT_SOURCE_DIR}
--search-path ${MBEDTLS_SGX_LIBRARY_DIR}
COMMENT "Generating Enclave_t.{c,h}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )

add_library(enclave SHARED ${SOURCE_FILES})

Expand All @@ -31,30 +27,28 @@ include_directories(
${SGX_SDK}/include
${SGX_SDK}/include/tlibc
${SGX_SDK}/include/stlport
${MBEDTLS_SGX_ROOT_DIR}/include
${MBEDTLS_SGX_INCLUDE_DIR}
)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SGX_COMMON_CFLAGS} -nostdinc -fvisibility=hidden -fpie -fstack-protector")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS} -std=c++03 -nostdinc++")

set(LIB_MBEDTLS_PATH "${MBEDTLS_LIB_DIR}/libmbedtls_sgx_t.a")

set_target_properties(enclave PROPERTIES PREFIX "")

target_link_libraries(enclave "${SGX_COMMON_CFLAGS} \
-Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles -L${SGX_LIBRARY_PATH} \
-Wl,--whole-archive -l${SGX_TRTS_LIB} -Wl,--no-whole-archive \
-Wl,--start-group ${LIB_MBEDTLS_PATH} -lsgx_tstdc -lsgx_tstdcxx -lsgx_tcrypto -l${SGX_TSVC_LIB} -Wl,--end-group \
-Wl,--start-group ${MBEDTLS_SGX_LIB_T} -lsgx_tstdc -lsgx_tstdcxx -lsgx_tcrypto -l${SGX_TSVC_LIB} -Wl,--end-group \
-Wl,-Bstatic -Wl,-Bsymbolic -Wl,--no-undefined \
-Wl,-pie,-eenclave_entry -Wl,--export-dynamic \
-Wl,--defsym,__ImageBase=0")

add_custom_command(TARGET enclave
POST_BUILD
COMMAND ${SGX_ENCLAVE_SIGNER} sign
-key Enclave_private.pem
-config Enclave.config.xml
-enclave ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/enclave.so
-out ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/enclave.signed.so
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-key ${CMAKE_CURRENT_SOURCE_DIR}/Enclave_private.pem
-config ${CMAKE_CURRENT_SOURCE_DIR}/Enclave.config.xml
-enclave enclave.so
-out enclave.signed.so
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Signing the enclave => ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/enclave.signed.so")
2 changes: 1 addition & 1 deletion example/enclave/Enclave.edl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
enclave {
from "mbedtls_sgx.edl" import *;
from "mbedtls_SGX.edl" import *;
from "sgx_tstdc.edl" import *;
include "../common/ssl_context.h"

Expand Down
Loading

0 comments on commit eeae37e

Please sign in to comment.