forked from kth-step/HolBA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.sh
executable file
·63 lines (49 loc) · 1.44 KB
/
configure.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
#!/usr/bin/env bash
# exit immediately if an error happens
set -e
OPT_DIR_PARAM=$1
# get setup directory path
HOLBA_DIR=$(dirname "${BASH_SOURCE[0]}")
HOLBA_DIR=$(readlink -f "${HOLBA_DIR}")
# source the local config.env.sh if it exists already (to not overwrite already configured variables)
set --
if [[ -f "${HOLBA_DIR}/config.env.sh" ]]; then
source "${HOLBA_DIR}/config.env.sh"
fi
# find the core and base environment variables (if undefined)
set --
source "${HOLBA_DIR}/scripts/setup/env_config_gen.sh" "${OPT_DIR_PARAM}"
##################################################################
# output file
OUTPUT_FILE="${HOLBA_DIR}/config.env.sh"
echo "Output file: ${OUTPUT_FILE}"
echo
# variables to export
declare -a vararr=(
"HOLBA_OPT_DIR"
"HOLBA_LOGS_DIR"
"HOLBA_HOL_DIR"
"HOLBA_Z3_DIR"
"HOLBA_EMBEXP_DIR"
"HOLBA_EMBEXP_LOGS"
"HOLBA_GCC_ARM8_CROSS"
)
# collect output in variable
PAD_LEN=30
#OUTPUT="#!/usr/bin/env bash"
#OUTPUT="${OUTPUT}\n"
OUTPUT="${OUTPUT}\n# please don't change the format of this file."
OUTPUT="${OUTPUT}\n# it is used for both bash and make!"
OUTPUT="${OUTPUT}\n"
for var in "${vararr[@]}"
do
var_val=$(printenv ${var} | cat)
printf -v var_pad "%${PAD_LEN}.${PAD_LEN}s" "${var}"
OUTPUT="${OUTPUT}\nexport ${var_pad}=${var_val}"
echo "Exporting ${var}"
done
OUTPUT="${OUTPUT}\n"
echo
# generate env export script for all variables
echo -e "${OUTPUT}" > "${OUTPUT_FILE}"
echo "File generated: ${OUTPUT_FILE}"