forked from AVSystem/Anjay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
devconfig
executable file
·128 lines (116 loc) · 3.68 KB
/
devconfig
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
#!/bin/bash
#
# Copyright 2017 AVSystem <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
rm -rf avs_commons/install
rm -rf avs_commons/git/CMakeFiles
rm -f avs_commons/git/CMakeCache.txt
if [[ -d '.git' ]]; then
echo "Updating submodules" && git submodule update --init || exit 1
fi
C_FLAGS='-g -std=c99'
EXTRA_C_FLAGS=
EXTRA_FLAGS=()
MODULE_DYNAMIC_LIBS='ON'
MODULE_STATIC_LIBS='ON'
ANJAY_VERSION=$(git rev-parse --short HEAD)
DTLS_BACKEND="mbedtls"
if valgrind --version >/dev/null 2>/dev/null; then
WITH_VALGRIND=ON
WITH_ASAN=OFF
else
WITH_VALGRIND=OFF
WITH_ASAN=ON
fi
if [[ "$ANJAY_VERSION" == "" ]]; then
ANJAY_VERSION="unknown"
fi
if ! which afl-gcc; then
if [[ -d "$HOME/tools/afl/latest" ]]; then
AFL_FUZZER_DIR="$HOME/tools/afl/latest"
fi
fi
# argument parsing
while [ $# -gt 0 ]; do
case "$1" in
'--c-flags')
shift
C_FLAGS="$1"
;;
'--fuzz-tests')
EXTRA_FLAGS[${#EXTRA_FLAGS[@]}]="-DWITH_FUZZ_TESTS=ON"
[[ "$AFL_FUZZER_DIR" ]] && EXTRA_FLAGS[${#EXTRA_FLAGS[@]}]="-DAFL_FUZZER_DIR=$AFL_FUZZER_DIR"
;;
'--with-mbedtls')
DTLS_BACKEND="mbedtls"
;;
'--with-openssl')
DTLS_BACKEND="openssl"
;;
'--with-tinydtls')
DTLS_BACKEND="tinydtls"
;;
'--without-dtls')
DTLS_BACKEND=
;;
'--with-valgrind')
WITH_ASAN=OFF
WITH_VALGRIND=ON
;;
'--with-asan')
WITH_VALGRIND=OFF
WITH_ASAN=ON
;;
'--without-memcheck')
WITH_ASAN=OFF
WITH_VALGRIND=OFF
;;
'--tiny')
EXTRA_FLAGS[${#EXTRA_FLAGS[@]}]="-DMAX_PK_OR_IDENTITY_SIZE=256"
EXTRA_FLAGS[${#EXTRA_FLAGS[@]}]="-DMAX_SERVER_PK_OR_IDENTITY_SIZE=256"
EXTRA_FLAGS[${#EXTRA_FLAGS[@]}]="-DMAX_SECRET_KEY_SIZE=128"
EXTRA_FLAGS[${#EXTRA_FLAGS[@]}]="-DMAX_OBSERVABLE_RESOURCE_SIZE=256"
EXTRA_FLAGS[${#EXTRA_FLAGS[@]}]="-DMAX_FLOAT_STRING_SIZE=64"
EXTRA_FLAGS[${#EXTRA_FLAGS[@]}]="-DMAX_DOUBLE_STRING_SIZE=64"
EXTRA_FLAGS[${#EXTRA_FLAGS[@]}]="-DMAX_URI_SEGMENT_SIZE=64"
EXTRA_FLAGS[${#EXTRA_FLAGS[@]}]="-DMAX_URI_QUERY_SEGMENT_SIZE=64"
;;
*)
EXTRA_FLAGS[${#EXTRA_FLAGS[@]}]="$1"
;;
esac
shift
done
if [ "$WITH_ASAN" == "ON" ]; then
EXTRA_C_FLAGS="${EXTRA_C_FLAGS} -fsanitize=address"
fi
# use Homebrew-installed OpenSSL on macOS if available
if brew ls --versions openssl >/dev/null 2>/dev/null; then
EXTRA_FLAGS[${#EXTRA_FLAGS[@]}]="-DOPENSSL_ROOT_DIR=/usr/local/opt/openssl"
fi
rm -f CMakeCache.txt
rm -rf CMakeFiles
cmake -D WITH_AVS_UNIT=ON \
-D WITH_DEMO=ON \
-D WITH_EXTRA_WARNINGS=ON \
-D WITH_VALGRIND=${WITH_VALGRIND} \
-D WITH_INTEGRATION_TESTS=ON \
-D DTLS_BACKEND="${DTLS_BACKEND}" \
-D AVS_LOG_WITH_TRACE=ON \
-D CMAKE_C_FLAGS="${C_FLAGS} ${EXTRA_C_FLAGS}" \
-D ANJAY_VERSION="${ANJAY_VERSION}" \
${WITH_MODULE_FLAGS} \
"${EXTRA_FLAGS[@]}" \
"$@" "`dirname "$0"`" &&
make clean