-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.bash
87 lines (71 loc) · 1.91 KB
/
setup.bash
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
#!/bin/bash
CCWS_ROOT=$(dirname "${BASH_SOURCE[0]}" | xargs realpath)
PROFILES_DIR="${CCWS_ROOT}/ccws/profiles/"
if [ -z "${BUILD_PROFILE}" ];
then
BUILD_PROFILE="reldebug"
fi
if [ $# -gt 0 ]
then
BUILD_PROFILE=$1
shift
fi
SETUP_SCRIPT="${PROFILES_DIR}/build/${BUILD_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
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
# 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