-
Notifications
You must be signed in to change notification settings - Fork 0
/
vault.sh
executable file
·70 lines (59 loc) · 1.9 KB
/
vault.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
#!/bin/bash
set -e
################################################################
# Replace the variables #
################################################################
NAME=sel4test
VAULT_DIR=`dirname $0`
OUTPUT_DIR=$KEYSTONE_SDK_DIR/../buildroot_overlay/root/$NAME
SEL4_KERNEL=build/kernel/kernel.elf
PACKAGE_FILES="build/projects/sel4test/apps/sel4test-driver/sel4test-driver \
host/runner \
$SEL4_KERNEL"
PACKAGE_SCRIPT="./runner sel4test-driver kernel.elf"
################################################################
# Sanity Check #
################################################################
# check if KEYSTONE_SDK_DIR is set
if [[ $KEYSTONE_SDK_DIR = "" ]]; then
echo "KEYSTONE_SDK_DIR is not set"
exit 1
fi
if [[ ! -d $KEYSTONE_SDK_DIR ]]; then
echo "Invalid KEYSTONE_SDK_DIR '$KEYSTONE_SDK_DIR'"
exit 1
fi
# check if riscv tools are in PATH
if ! (
$(command -v riscv64-unknown-elf-g++ > /dev/null) &&
$(command -v riscv64-unknown-elf-gcc > /dev/null)
); then
echo "riscv tools are not in PATH"
exit 1
fi
# check if OUTPUT_DIR is set
if [[ $OUTPUT_DIR = "" ]]; then
echo "OUTPUT_DIR is not set"
exit 1
fi
################################################################
# Build Enclave #
################################################################
# create a build directory
OUTPUT_FILES_DIR=$OUTPUT_DIR/files
mkdir -p $OUTPUT_FILES_DIR
# build the app
pushd $VAULT_DIR
make -C host
mkdir -p build
cd build
../init-build.sh -DPLATFORM=spike -DRISCV64=TRUE
ninja
cd ..
for output in $PACKAGE_FILES; do
cp $output $OUTPUT_FILES_DIR
done
popd
# create vault archive & remove output files
makeself --noprogress "$OUTPUT_FILES_DIR" "$OUTPUT_DIR/$NAME.ke" "Keystone vault archive" $PACKAGE_SCRIPT
#rm -rf $OUTPUT_FILES_DIR