-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
116 lines (91 loc) · 3.4 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# Build Helios as follows:
#
# - make -- create non-SGX no-debug-log manifest
# - make SGX=1 -- create SGX no-debug-log manifest
# - make SGX=1 DEBUG=1 -- create SGX debug-log manifest
#
# Any of these invocations clones Helios' git repository and builds Helios in
# default configuration.
#
# Use `make clean` to remove Gramine-generated files and `make distclean` to
# additionally remove the cloned Helios git repository.
################################# CONSTANTS ###################################
# directory with arch-specific libraries, used by Helios
# the below path works for Debian/Ubuntu; for CentOS/RHEL/Fedora, you should
# overwrite this default like this: `ARCH_LIBDIR=/lib64 make`
ARCH_LIBDIR ?= /lib/$(shell $(CC) -dumpmachine)
ENCLAVE_SIZE ?= 1G
HELIOS_BRANCH ?= master
HELIOS_REPO ?= https://github.com/a16z/helios
SRCDIR = src/
ifeq ($(DEBUG),1)
GRAMINE_LOG_LEVEL = debug
else
GRAMINE_LOG_LEVEL = error
endif
.PHONY: all
all: helios helios.manifest
ifeq ($(SGX),1)
all: helios.manifest.sgx helios.sig
endif
############################## HELIOS EXECUTABLE ###############################
# Clone Helios
$(SRCDIR)/README.md:
git clone -b $(HELIOS_BRANCH) $(HELIOS_REPO) $(SRCDIR)
# Build Helios
$(SRCDIR)/target/release/helios: $(SRCDIR)/README.md
cd $(SRCDIR) && cargo build --release
################################ HELIOS MANIFEST ###############################
# The template file is a Jinja2 template and contains almost all necessary
# information to run Helios under Gramine / Gramine-SGX. We create
# helios.manifest (to be run under non-SGX Gramine) by replacing variables
# in the template file using the "gramine-manifest" script.
RA_TYPE ?= dcap
ISVPRODID ?= 0
ISVSVN ?= 0
helios.manifest: helios.manifest.template helios
gramine-manifest \
-Dlog_level=$(GRAMINE_LOG_LEVEL) \
-Darch_libdir=$(ARCH_LIBDIR) \
-Dentrypoint="./helios" \
-Dra_type=$(RA_TYPE) \
-Disvprodid=$(ISVPRODID) \
-Disvsvn=$(ISVSVN) \
-Denclave_size=$(ENCLAVE_SIZE) \
$< >$@
# Manifest for Gramine-SGX requires special "gramine-sgx-sign" procedure. This
# procedure measures all Helios trusted files, adds the measurement to the
# resulting manifest.sgx file (among other, less important SGX options) and
# creates helios.sig (SIGSTRUCT object).
# Make on Ubuntu <= 20.04 doesn't support "Rules with Grouped Targets" (`&:`),
# see the gramine helloworld example for details on this workaround.
helios.manifest.sgx helios.sig: sgx_sign
@:
.INTERMEDIATE: sgx_sign
sgx_sign: helios.manifest
gramine-sgx-sign \
--manifest $< \
--output $<.sgx
########################### COPIES OF EXECUTABLES #############################
# Helios build process creates the final executable as build/bin/helios. For
# simplicity, copy it into our root directory.
helios: $(SRCDIR)/target/release/helios
cp $< $@
############################## RUNNING TESTS ##################################
.PHONY: check
check: all
./run-tests.sh > TEST_STDOUT 2> TEST_STDERR
@grep -q "Success 1/4" TEST_STDOUT
@grep -q "Success 2/4" TEST_STDOUT
@grep -q "Success 3/4" TEST_STDOUT
@grep -q "Success 4/4" TEST_STDOUT
ifeq ($(SGX),1)
@grep -q "Success SGX quote" TEST_STDOUT
endif
################################## CLEANUP ####################################
.PHONY: clean
clean:
$(RM) helios *.manifest *.manifest.sgx *.sig *.args OUTPUT* *.PID TEST_STDOUT TEST_STDERR
.PHONY: distclean
distclean: clean
$(RM) -rf $(SRCDIR)