-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·96 lines (81 loc) · 1.57 KB
/
test.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
#! env bash
TPUTRESET=$(tput sgr0 2> /dev/null)
GREEN=$(tput setaf 2 2> /dev/null)
GREY=$(tput setaf 7 2> /dev/null)
RED=$(tput setaf 9 2> /dev/null)
YELLOW=$(tput setaf 11 2> /dev/null)
function green_echo
{
echo -e $GREEN$@$TPUTRESET
}
function grey_echo
{
echo -e "$GREY$@$TPUTRESET"
}
function red_echo
{
echo -e $RED$@$TPUTRESET
}
SCRIPT_LOCATION=$(readlink -f $0)
BASEDIR=$(dirname $SCRIPT_LOCATION)
COMPILER=gcc
function invoke_conan_build
{
conan_cmd=$(cat <<-END
conan test $BASEDIR
--build=missing
--settings:build build_type=$1
--settings:host build_type=$1
$2
$3
mfsm/*
END
)
green_echo "Invoking conan"
grey_echo "$conan_cmd"
$conan_cmd
}
function invoke_conan
{
case $COMPILER in
clang)
profs=(linux clang) ;;
gcc)
profs=(linux gnu) ;;
esac
profs_h=$(printf -- "-pr:h $BASEDIR/conan_profiles/%s " "${profs[@]}")
profs_b=$(printf -- "-pr:b $BASEDIR/conan_profiles/%s " "${profs[@]}")
invoke_conan_build "Debug" "$profs_h" "$profs_b"
invoke_conan_build "Release" "$profs_h" "$profs_b"
}
USAGE_STR="usage: $0 [-c|--compiler <gcc|clang>] [-h|--help]"
function usage_die()
{
red_echo $USAGE_STR
exit 1
}
function usage_help()
{
green_echo $USAGE_STR
exit 0
}
GETOPT_CMD=\
$(getopt \
-o c:h \
-l compiler:,help \
-n $0 -- $@)
if [ $? -ne 0 ]; then
usage_die
fi
while true; do
case $1 in
-c|--compiler)
case $2 in
gcc|clang) COMPILER=$2 ;;
*) usage_die ;;
esac; shift 2 ;;
-h|--help) usage_help ;;
*) break ;;
esac
done
invoke_conan