-
Notifications
You must be signed in to change notification settings - Fork 7
/
setup_main_files.sh
executable file
·154 lines (133 loc) · 6.45 KB
/
setup_main_files.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
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
#!/bin/bash
################################################################################
#
# This file is used to setup symbolic links for main files that are used with
# the benchmark depending on the configuration of the benchmark. Check the
# README.md file in main_files directory for more details
#
################################################################################
################################## VARIABLS ##################################
CURR_DIR=`dirname \`readlink -f $0\``
MBED_OS='os-lib/mbed-os'
MBED_FEATURES='os-lib/mbed-os/features'
EXAMPLES='examples'
EXAMPLES_DIR=${CURR_DIR}/${EXAMPLES}
BENCHMARKS='benchmarks'
OS_BENCHMARKS='benchmarks/mbed-os-benchmarks'
SECURE_DATA_OS_BENCHMARKS='benchmarks/secure_data_OS-benchmarks'
SECURE_DATA_BM_BENCHMARKS='benchmarks/secure_data_SDK-benchmarks'
MBED_OS_DIR=${CURR_DIR}/${MBED_OS}
FEATURES_DIR=${CURR_DIR}/${MBED_FEATURES}
BENCHMARKS_DIR=${CURR_DIR}/${BENCHMARKS}
OS_BENCHMARKS_DIR=${CURR_DIR}/${OS_BENCHMARKS}
SECURE_DATA_OS_BENCHMARKS_DIR=${CURR_DIR}/${SECURE_DATA_OS_BENCHMARKS}
SECURE_DATA_BM_BENCHMARKS_DIR=${CURR_DIR}/${SECURE_DATA_BM_BENCHMARKS}
MBED_LIB_DIR='lib/mbed-libs/FEATURES'
LIB_DIR=${CURR_DIR}/${MBED_LIBS}
# Path to lwip for the BAREMETAL version
BAREMETAL_LWIPSRC_PATH='lib/mbed-libs/BAREMETAL_LWIP/lwip'
# The symlink we would like to add
BAREMETAL_LWIPSRC_DIR=${CURR_DIR}/${BAREMETAL_LWIPSRC_PATH}
# Actual path to LWIP in the FEATURE_LWIP directory
FEATURE_LWIP_LWIPSRC_PATH='os-lib/mbed-os/features/FEATURE_LWIP/lwip-interface/lwip'
FEATURE_LWIP_LWIPSRC_DIR=${CURR_DIR}/${FEATURE_LWIP_LWIPSRC_PATH}
# path to main file for secure_data benchmarks
SECURE_DATA_MAIN_FILE_PATH='main_files/securedata_main.cpp'
SECURE_DATA_MAIN_FILE=${CURR_DIR}/${SECURE_DATA_MAIN_FILE_PATH}
# path to main file for other benchmarks
GENERAL_MAIN_FILE_PATH='main_files/main.cpp'
GENERAL_MAIN_FILE=${CURR_DIR}/${GENERAL_MAIN_FILE_PATH}
SYM_LINK='ln -sTf'
################################## SETUP ##################################
echo "-------------------------------------------------------------------------"
echo "[*] Setting symlinks to main files for each benchmark"
# Loop through the benchmarks and create mbed-os symlinks
for benchmark_type in ${BENCHMARKS_DIR}/*; do
if [ -d "$benchmark_type" ]; then
echo "[+] name: "${benchmark_type}
#-----------------------------------------------------------------------
# secure data (OS) benchmarks
#-----------------------------------------------------------------------
if [ "$benchmark_type" == "$SECURE_DATA_OS_BENCHMARKS_DIR" ]; then
for benchmark in ${benchmark_type}/*; do
if [ -d "$benchmark" ]; then
# remove main.cpp and symlink for watchdog_main.cpp
if rm ${benchmark}/main.cpp
then
echo " [+] removed main.cpp from ${benchmark_type}/${benchmark}"
else
echo " [+] No file named main.cpp found in ${benchmark_type}/${benchmark}"
fi
# add symlink
if ${SYM_LINK} ${SECURE_DATA_MAIN_FILE} ${benchmark}/securedata_main.cpp
then
echo " [+] Added symlink for main.cpp at: ${benchmark}/main.cpp"
else
echo " [-] ERROR: Failed to add symlink for main.cpp at: ${benchmark}/main.cpp"
fi
fi
done
#-----------------------------------------------------------------------
# secure data (BM) benchmarks
#-----------------------------------------------------------------------
elif [ "$benchmark_type" == "$SECURE_DATA_BM_BENCHMARKS_DIR" ]; then
for benchmark in ${benchmark_type}/*; do
if [ -d "$benchmark" ]; then
# remove main.cpp and symlink for watchdog_main.cpp
if rm ${benchmark}/main.cpp
then
echo " [+] removed main.cpp from ${benchmark_type}/${benchmark}"
else
echo " [+] No file named main.cpp found in ${benchmark_type}/${benchmark}"
fi
# add symlink
if ${SYM_LINK} ${SECURE_DATA_MAIN_FILE} ${benchmark}/securedata_main.cpp
then
echo " [+] Added symlink for main.cpp at: ${benchmark}/main.cpp"
else
echo " [-] ERROR: Failed to add symlink for main.cpp at: ${benchmark}/main.cpp"
fi
fi
done
#-----------------------------------------------------------------------
# Other benchmarks
#-----------------------------------------------------------------------
else
for benchmark in ${benchmark_type}/*; do
if [ -d "$benchmark" ]; then
# remove main.cpp and symlink for watchdog_main.cpp
if rm ${benchmark}/main.cpp
then
echo " [+] removed main.cpp from ${benchmark_type}/${benchmark}"
else
echo " [+] No file named main.cpp found in ${benchmark_type}/${benchmark}"
fi
# add symlink
if ${SYM_LINK} ${GENERAL_MAIN_FILE} ${benchmark}/main.cpp
then
echo " [+] Added symlink for main.cpp at: ${benchmark}/main.cpp"
else
echo " [-] ERROR: Failed to add symlink for main.cpp at: ${benchmark}/main.cpp"
fi
fi
done
fi
fi
done
# create main symlink for example templates
for benchmark_type in ${EXAMPLES_DIR}/*; do
if [ -d "$benchmark_type" ]; then
echo "[+] name: "${benchmark_type}
for benchmark in ${benchmark_type}/*; do
if [ -d "$benchmark" ]; then
if ${SYM_LINK} ${GENERAL_MAIN_FILE} ${benchmark}/main.cpp
then
echo " [+] Added main.cpp symlink in:"${benchmark}
else
echo " [-] ERROR: Failed to add main.cpp symlink in:"${benchmark}
fi
fi
done
fi
done
echo "-------------------------------------------------------------------------"