-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.bash
More file actions
89 lines (73 loc) · 2.08 KB
/
setup.bash
File metadata and controls
89 lines (73 loc) · 2.08 KB
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
#!/bin/bash
CCWS_DIR="$(dirname "${BASH_SOURCE[0]}" | xargs realpath)/ccws"
PROFILES_DIR="${CCWS_DIR}/profiles/"
export CCWS_DIR
if [ -z "${CCWS_BUILD_PROFILES}" ];
then
CCWS_BUILD_PROFILES="reldebug"
fi
if [ $# -gt 0 ]
then
CCWS_BUILD_PROFILES=$1
shift
fi
SETUP_SCRIPT="${PROFILES_DIR}/build/$(echo "${CCWS_BUILD_PROFILES}" | cut -f 1 -d ',')/setup.bash"
if [ -f "${SETUP_SCRIPT}" ]
then
if [ $# -eq 0 ]
then
# load 'test' exec profile if not overriden explicitly
if [ -z "${EXEC_PROFILE}" ]
then
EXEC_PROFILE="test"
fi
else
# comman line parameters override environment
EXEC_PROFILE="$1"
shift
while [ $# -gt 0 ]
do
EXEC_PROFILE="$1 ${EXEC_PROFILE}"
shift
done
fi
# shellcheck disable=SC2046
source "${SETUP_SCRIPT}" $(echo "${CCWS_BUILD_PROFILES}" | cut --only-delimited -f 2- -d ',' | sed 's/,/ /g');
if [ -t 0 ];
then
# ignore errors to prevent session termination if interactive
set +e
fi
# normalize
EXEC_PROFILE=$(echo "${EXEC_PROFILE}" | sed -e "s/^ *//" -e "s/ *$//" -e "s/ \+/ /g" -e "s/ /\\n/g" | grep -v "^common$" | grep -v "^vendor$" | paste -d ' ' -s)
# prepend common and append vendor specific parameters
EXEC_PROFILE="common ${EXEC_PROFILE}"
if [ -f "${PROFILES_DIR}/exec/vendor/setup.bash" ]
then
EXEC_PROFILE="${EXEC_PROFILE} vendor"
fi
EXEC_PROFILE=$(echo "${EXEC_PROFILE}" | sed -e "s/ \+/ /g")
for PROFILE in ${EXEC_PROFILE};
do
SETUP_SCRIPT="${PROFILES_DIR}/exec/${PROFILE}/setup.bash"
if [ -f "${SETUP_SCRIPT}" ]
then
source "${SETUP_SCRIPT}";
if [ -t 0 ];
then
# ignore errors to prevent session termination if interactive
set +e
fi
else
ERROR="Unknown execution profile: '$1'"
break
fi
done
else
ERROR="Unknown build profile: '${BUILD_PROFILE}'"
fi
if [ -n "${ERROR}" ]
then
echo "${ERROR}"
false
fi