forked from microsoft/scitt-ccf-ledger
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·77 lines (64 loc) · 2.26 KB
/
build.sh
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
#!/bin/bash
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
set -ex
CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Release}
PLATFORM=${PLATFORM:-sgx}
CCF_UNSAFE=${CCF_UNSAFE:-OFF}
ENABLE_PREFIX_TREE=${ENABLE_PREFIX_TREE:-OFF}
BUILD_TESTS=${BUILD_TESTS:-ON}
ENABLE_CLANG_TIDY=${ENABLE_CLANG_TIDY:-OFF}
NINJA_FLAGS=${NINJA_FLAGS:-}
if [ "$PLATFORM" = "sgx" ]; then
CC=${CC:-clang-11}
CXX=${CXX:-clang++-11}
elif [ "$PLATFORM" = "virtual" ]; then
CC=${CC:-clang-15}
CXX=${CXX:-clang++-15}
else
echo "Unknown platform: $PLATFORM, must be 'sgx' or 'virtual'"
exit 1
fi
git submodule sync
git submodule update --init --recursive
root_dir=$(pwd)
install_dir=/tmp/scitt
mkdir -p $install_dir
mkdir -p build/attested-fetch
CC="$CC" CXX="$CXX" \
cmake -GNinja -B build/attested-fetch \
-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" \
-DCMAKE_INSTALL_PREFIX=$install_dir \
-DCOMPILE_TARGET="${PLATFORM}" \
"$root_dir/3rdparty/attested-fetch"
ninja -C build/attested-fetch ${NINJA_FLAGS} --verbose
ninja -C build/attested-fetch ${NINJA_FLAGS} install
if [ "$PLATFORM" = "sgx" ]; then
ATTESTED_FETCH_MRENCLAVE_HEX=$(/opt/openenclave/bin/oesign dump -e $install_dir/libafetch.enclave.so.signed | sed -n "s/mrenclave=//p")
elif [ "$PLATFORM" = "virtual" ]; then
ATTESTED_FETCH_MRENCLAVE_HEX=""
else
echo "Unknown platform: $PLATFORM, must be 'sgx' or 'virtual'"
exit 1
fi
cp "$root_dir"/app/fetch-did-web-doc.py $install_dir
# Note: LVI mitigations are disabled as this is a development build.
# See docker/ for a non-development build.
CC="$CC" CXX="$CXX" \
cmake -GNinja -B build/app \
-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" \
-DATTESTED_FETCH_MRENCLAVE_HEX="${ATTESTED_FETCH_MRENCLAVE_HEX}" \
-DCOMPILE_TARGET="${PLATFORM}" \
-DCCF_UNSAFE="${CCF_UNSAFE}" \
-DENABLE_PREFIX_TREE="${ENABLE_PREFIX_TREE}" \
-DBUILD_TESTS="${BUILD_TESTS}" \
-DLVI_MITIGATIONS=OFF \
-DCMAKE_INSTALL_PREFIX=$install_dir \
-DENABLE_CLANG_TIDY="${ENABLE_CLANG_TIDY}" \
"$root_dir/app"
ninja -C build/app ${NINJA_FLAGS} --verbose
ninja -C build/app ${NINJA_FLAGS} install
if [ "$PLATFORM" = "sgx" ]; then
echo "Dumping enclave details:"
/opt/openenclave/bin/oesign dump -e $install_dir/lib/libscitt.enclave.so.signed
fi