forked from veracruz-project/veracruz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
190 lines (158 loc) · 6.44 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# This makefile is used within the docker image generated by docker/Dockerfile
#
# AUTHORS
#
# The Veracruz Development Team.
#
# COPYRIGHT
#
# See the `LICENSE.markdown` file in the Veracruz root directory for licensing
# and copyright information.
.PHONY: all sdk test_cases sgx-durango-test trustzone-durango-test sgx trustzone sgx-sinaloa-test sgx-sinaloa-performance sgx-veracruz-test sgx-psa-attestation tz-psa-attestationtrustzone-sinaloa-test-setting trustzone-veracruz-test-setting trustzone-env sgx-env tlaxcala trustzone-test-env clean clean-cargo-lock fmt
WARNING_COLOR := "\e[1;33m"
INFO_COLOR := "\e[1;32m"
RESET_COLOR := "\e[0m"
OPTEE_DIR_SDK ?= /work/rust-optee-trustzone-sdk/
AARCH64_OPENSSL_DIR ?= /work/rust-optee-trustzone-sdk/optee-qemuv8-3.7.0/build/openssl-1.0.2s/
AARCH64_GCC ?= $(OPTEE_DIR)/toolchains/aarch64/bin/aarch64-linux-gnu-gcc
SGX_RUST_FLAG ?= "-L/work/sgxsdk/lib64 -L/work/sgxsdk/sdk_libs"
NITRO_RUST_FLAG ?= ""
all:
@echo $(WARNING_COLOR)"Please explicitly choose a target."$(RESET_COLOR)
# Build all of the SDK and examples
sdk:
$(MAKE) -C sdk
# Generate all test policy
test_cases: sdk
$(MAKE) -C test-collateral
# Test durango for sgx, due to the use of a mocked server with a fixed port, these tests must run in a single thread
sgx-durango-test: sgx test_cases
cd durango && RUSTFLAGS=$(SGX_RUST_FLAG) cargo test --lib --features "mock sgx" -- --test-threads=1
# Test durango for sgx, due to the use of a mocked server with a fixed port, these tests must run in a single thread
trustzone-durango-test: trustzone test_cases
cd durango && cargo test --lib --features "mock tz" -- --test-threads=1
# Compile for sgx
# offset the CC OPENSSL_DIR, which might be used in compiling trustzone
sgx: sdk sgx-env
cd mexico-city-bind && RUSTFLAGS=$(SGX_RUST_FLAG) cargo build
cd sonora-bind && RUSTFLAGS=$(SGX_RUST_FLAG) cargo build
cd durango && RUSTFLAGS=$(SGX_RUST_FLAG) cargo build --lib --features sgx
nitro: sdk
pwd
RUSTFLAGS=$(NITRO_RUST_FLAG) $(MAKE) -C mexico-city nitro
RUSTFLAGS=$(NITRO_RUST_FLAG) $(MAKE) -C nitro-root-enclave
RUSTFLAGS=$(NITRO_RUST_FLAG) $(MAKE) -C nitro-root-enclave-server
# Compile for trustzone, note: source the rust-optee-trustzone-sdk/environment first, however assume `unset CC`.
trustzone: sdk trustzone-env
$(MAKE) -C mexico-city trustzone CC=$(AARCH64_GCC)
$(MAKE) -C jalisco trustzone
cd durango && RUSTFLAGS=$(SGX_RUST_FLAG) cargo build --lib --features tz
sgx-sinaloa-test: sgx test_cases
cd sinaloa-test \
&& RUSTFLAGS=$(SGX_RUST_FLAG) cargo test --features sgx \
&& RUSTFLAGS=$(SGX_RUST_FLAG) cargo test test_debug --features sgx -- --ignored --test-threads=1
sgx-sinaloa-test-dry-run: sgx test_cases
cd sinaloa-test \
&& RUSTFLAGS=$(SGX_RUST_FLAG) cargo test --features sgx --no-run
sgx-sinaloa-performance: sgx test_cases
cd sinaloa-test \
&& RUSTFLAGS=$(SGX_RUST_FLAG) cargo test test_performance_ --features sgx -- --ignored
sgx-veracruz-test-dry-run: sgx test_cases
cd veracruz-test \
&& RUSTFLAGS=$(SGX_RUST_FLAG) cargo test --features sgx --no-run
sgx-veracruz-test: sgx test_cases
cd veracruz-test \
&& RUSTFLAGS=$(SGX_RUST_FLAG) cargo test --features sgx
sgx-psa-attestation: sgx-env
cd psa-attestation && cargo build --features sgx
tz-psa-attestation: trustzone-env
cd psa-attestation && cargo build --target aarch64-unknown-linux-gnu --features tz
trustzone-sinaloa-test: trustzone test_cases trustzone-test-env
cd sinaloa-test \
&& export OPENSSL_DIR=$(AARCH64_OPENSSL_DIR) \
&& cargo test --target aarch64-unknown-linux-gnu --no-run --features tz -- --test-threads=1 \
&& ./cp_sinaloa_test_tz.sh
chmod u+x run_sinaloa_test_tz.sh
./run_sinaloa_test_tz.sh
trustzone-veracruz-test: trustzone test_cases trustzone-test-env
cd veracruz-test \
&& export OPENSSL_DIR=$(AARCH64_OPENSSL_DIR) \
&& cargo test --target aarch64-unknown-linux-gnu --no-run --features tz -- --test-threads=1 \
&& ./cp_veracruz_tz.sh
chmod u+x run_veracruz_test_tz.sh
./run_veracruz_test_tz.sh
trustzone-test-env: tz_test.sh run_tz_test.sh
chmod u+x $^
nitro-sinaloa-test: nitro test_cases
cd sinaloa-test \
&& RUSTFLAGS=$(NITRO_RUST_FLAG) cargo test --features nitro \
&& RUSTFLAGS=$(NITRO_RUST_FLAG) cargo test test_debug --features nitro,debug -- --ignored --test-threads=1
cd sinaloa-test \
&& ./nitro_terminate.sh
cd ./sinaloa-test \
&& ./nitro_ec2_terminate_root.sh
nitro-sinaloa-test-dry-run: nitro test_cases
cd sinaloa-test \
&& RUSTFLAGS=$(NITRO_RUST_FLAG) cargo test --features sgx --no-run
nitro-sinaloa-performance: nitro test_cases
cd sinaloa-test \
&& RUSTFLAGS=$(NITRO_RUST_FLAG) cargo test test_performance_ --features nitro -- --ignored
cd sinaloa-test \
&& ./nitro_terminate.sh
cd ./sinaloa-test \
&& ./nitro_ec2_terminate_root.sh
nitro-veracruz-test-dry-run: nitro test_cases
cd veracruz-test \
&& RUSTFLAGS=$(SGX_RUST_FLAG) cargo test --features nitro --no-run
nitro-veracruz-test: nitro test_cases
cd veracruz-test \
&& RUSTFLAGS=$(SGX_RUST_FLAG) cargo test --features nitro
cd sinaloa-test \
&& ./nitro_terminate.sh
cd ./sinaloa-test \
&& ./nitro_ec2_terminate_root.sh
nitro-psa-attestation:
cd psa-attestation && cargo build --features nitro
trustzone-env:
unset CC
rustup target add aarch64-unknown-linux-gnu arm-unknown-linux-gnueabihf
rustup component add rust-src
chmod u+x tz_test.sh
sgx-env:
unset CC
clean:
cd mexico-city-bind && cargo clean
cd sonora-bind && cargo clean
cd psa-attestation && cargo clean
cd tabasco && cargo clean
cd baja && cargo clean
cd veracruz-utils && cargo clean
cd sinaloa-test && cargo clean
cd veracruz-test && cargo clean
cd nitro-root-enclave-server && cargo clean
$(MAKE) clean -C mexico-city
$(MAKE) clean -C jalisco
$(MAKE) clean -C sinaloa
$(MAKE) clean -C test-collateral
$(MAKE) clean -C sonora
$(MAKE) clean -C sdk
$(MAKE) clean -C nitro-root-enclave
# NOTE: this target deletes ALL cargo.lock.
clean-cargo-lock:
$(MAKE) clean -C sdk
rm -f $(addsuffix /Cargo.lock,baja execution-engine colima durango jalisco mexico-city-bind mexico-city psa-attestation sinaloa-test sinaloa sonora-bind sonora tabasco veracruz-test veracruz-util)
fmt:
cd baja && cargo fmt
cd execution-engine && cargo fmt
cd colima && cargo fmt
cd durango && cargo fmt
cd jalisco && cargo fmt
cd mexico-city && cargo fmt
cd psa-attestation && cargo fmt
cd sinaloa-test && cargo fmt
cd sinaloa && cargo fmt
cd veracruz-test && cargo fmt
cd veracruz-utils && cargo fmt
cd sonora && cargo fmt
cd tabasco && cargo fmt
$(MAKE) -C sdk fmt