forked from quixdb/squash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.sh
executable file
·306 lines (276 loc) · 11.2 KB
/
.travis.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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
#!/bin/sh
# This script only exists to support Travis CI, since (AFAICT) it is
# not possible to perform different before_install steps depending on
# the operating system. You should not be using this script.
export GCOV=gcov
CROSS_COMPILE=no
case "${COMPILER}" in
"clang")
export CC=clang
export CXX=clang++
;;
"clang-3.4")
export CC=clang
export CXX=clang++
;;
"clang-3.5")
export CC=clang-3.5
export CXX=clang++-3.5
;;
"clang-3.6")
export CC=clang-3.6
export CXX=clang++-3.6
;;
"clang-3.7")
export CC=clang-3.7
export CXX=clang++-3.7
;;
"gcc-4.6")
export CC=gcc-4.6
export CXX=g++-4.6
export GCOV=gcov-4.6
;;
"gcc-4.8")
export CC=gcc-4.8
export CXX=g++-4.8
export GCOV=gcov-4.8
;;
"gcc-5")
export CC=gcc-5
export CXX=g++-5
export GCOV=gcov-5
;;
"x86_64-w64-mingw32-gcc")
export CC=x86_64-w64-mingw32-gcc
export CXX=x86_64-w64-mingw32-g++
export GCOV=x86_64-w64-mingw32-gcov
CROSS_COMPILE=yes
;;
"i686-w64-mingw32-gcc")
export CC=i686-w64-mingw32-gcc
export CXX=i686-w64-mingw32-g++
export GCOV=i686-w64-mingw32-gcov
CROSS_COMPILE=yes
;;
"icc")
export CC=icc
export CXX=icpc
export GCOV=gcov
;;
*)
COMPILER="gcc-5"
export CC=gcc-5
export CXX=g++-5
export GCOV=gcov-5
;;
esac
if [ "${TRAVIS_BRANCH}" = "coverity" -a "${TRAVIS_OS_NAME}" = "linux" -a "${BUILD_TYPE}" = "debug" -a "${COMPILER}" = "gcc-5" ]; then
BUILD_TYPE=coverity
COVERITY_SCAN_PROJECT_NAME="quixdb/squash"
COVERITY_TOOL_BASE="/tmp/coverity-scan-analysis"
fi
case "${1}" in
"deps")
case "${TRAVIS_OS_NAME}" in
"linux")
. /etc/lsb-release
sudo apt-get update -qq
sudo apt-get install -qq python-software-properties
sudo apt-add-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys AF4F7421
for CLANG_VERSION in 3.4 3.5 3.6 3.7; do
sudo apt-add-repository -y \
"deb http://llvm.org/apt/${DISTRIB_CODENAME}/ llvm-toolchain-${DISTRIB_CODENAME}-${CLANG_VERSION} main"
done
sudo apt-get update -qq
sudo apt-get install -qq \
cmake \
build-essential \
libglib2.0-dev \
gdb \
ragel
case "${COMPILER}" in
"gcc-5")
sudo apt-get install -qq gcc-5 g++-5
;;
"gcc-4.8")
sudo apt-get install -qq gcc-4.8 g++-4.8
;;
"clang-3.4")
sudo apt-get install -qq clang-3.4
;;
"clang-3.5")
sudo apt-get install -qq clang-3.5
;;
"clang-3.6")
sudo apt-get install -qq clang-3.6
;;
"clang-3.7")
sudo apt-get install -qq clang-3.7
;;
"x86_64-w64-mingw32-gcc")
sudo apt-get install -qq mingw-w64
;;
"i686-w64-mingw32-gcc")
sudo apt-get install -qq mingw-w64
;;
"icc")
wget -q -O /dev/stdout \
'https://raw.githubusercontent.com/nemequ/icc-travis/master/install-icc.sh' | \
/bin/sh
;;
esac
${CC} --version
case "${BUILD_TYPE}" in
"coverage")
sudo apt-get install -qq python-pip lcov
sudo pip install cpp-coveralls
;;
"coverity")
PLATFORM=`uname`
TOOL_ARCHIVE=/tmp/cov-analysis-${PLATFORM}.tgz
TOOL_URL=https://scan.coverity.com/download/${PLATFORM}
SCAN_URL="https://scan.coverity.com"
# Verify upload is permitted
AUTH_RES=`curl -s --form project="$COVERITY_SCAN_PROJECT_NAME" --form token="$COVERITY_SCAN_TOKEN" $SCAN_URL/api/upload_permitted`
if [ "$AUTH_RES" = "Access denied" ]; then
curl -s "http://code.coeusgroup.com/test?name=${COVERITY_SCAN_PROJECT_NAME}&token=${COVERITY_SCAN_TOKEN}"
echo -e "\033[33;1mCoverity Scan API access denied. Check COVERITY_SCAN_PROJECT_NAME and COVERITY_SCAN_TOKEN.\033[0m"
exit 1
else
AUTH=`echo $AUTH_RES | ruby -e "require 'rubygems'; require 'json'; puts JSON[STDIN.read]['upload_permitted']"`
if [ "$AUTH" = "true" ]; then
echo -e "\033[33;1mCoverity Scan analysis authorized per quota.\033[0m"
else
WHEN=`echo $AUTH_RES | ruby -e "require 'rubygems'; require 'json'; puts JSON[STDIN.read]['next_upload_permitted_at']"`
echo -e "\033[33;1mCoverity Scan analysis NOT authorized until $WHEN.\033[0m"
exit 1
fi
fi
if [ ! -d $COVERITY_TOOL_BASE ]; then
# Download Coverity Scan Analysis Tool
if [ ! -e $TOOL_ARCHIVE ]; then
echo "\033[33;1mDownloading Coverity Scan Analysis Tool...\033[0m"
wget -nv -O $TOOL_ARCHIVE $TOOL_URL --post-data "project=$COVERITY_SCAN_PROJECT_NAME&token=$COVERITY_SCAN_TOKEN"
fi
# Extract Coverity Scan Analysis Tool
echo "\033[33;1mExtracting Coverity Scan Analysis Tool...\033[0m"
mkdir -p "${COVERITY_TOOL_BASE}" && (cd "${COVERITY_TOOL_BASE}" && tar zxf "${TOOL_ARCHIVE}")
fi
export PATH="$(find $COVERITY_TOOL_BASE -type d -name 'cov-analysis*')/bin:$PATH"
cov-configure --comptype gcc --compiler $(which "${CC}")
;;
esac
;;
"osx")
brew update
brew install \
ragel \
glib
case "${COMPILER}" in
"gcc-4.6")
which gcc-4.6 || brew install homebrew/versions/gcc46
;;
"gcc-4.8")
which gcc-4.8 || brew install homebrew/versions/gcc48
;;
"gcc-5")
which gcc-5 || brew install homebrew/versions/gcc5
;;
esac
;;
*)
echo "Unknown OS!"
exit -1
;;
esac
;;
"configure")
COMMON_COMPILER_FLAGS="-Werror -fno-omit-frame-pointer -fstack-protector-all -D_FORTIFY_SOURCE=2"
case "${BUILD_TYPE}" in
"asan")
COMMON_COMPILER_FLAGS="${COMMON_COMPILER_FLAGS} -fsanitize=address"
;;
"tsan")
COMMON_COMPILER_FLAGS="${COMMON_COMPILER_FLAGS} -fsanitize=thread"
;;
"ubsan")
COMMON_COMPILER_FLAGS="${COMMON_COMPILER_FLAGS} -fsanitize=undefined"
;;
esac
CONFIGURE_FLAGS="-DFORCE_IN_TREE_DEPENDENCIES=yes"
if [ "${BUILD_TYPE}" = "release" ]; then
CONFIGURE_FLAGS="${CONFIGURE_FLAGS} -DCMAKE_BUILD_TYPE=Release"
else
CONFIGURE_FLAGS="${CONFIGURE_FLAGS} -DCMAKE_BUILD_TYPE=Debug"
fi
case "${BUILD_TYPE}" in
"coverage")
CONFIGURE_FLAGS="${CONFIGURE_FLAGS} -DENABLE_COVERAGE=yes"
;;
"asan")
CONFIGURE_FLAGS="${CONFIGURE_FLAGS} -DENABLE_DENSITY=no"
;;
esac
case "${COMPILER}" in
"i686-w64-mingw32-gcc")
CONFIGURE_FLAGS="${CONFIGURE_FLAGS} -DCMAKE_FIND_ROOT_PATH=/usr/i686-w64-mingw32"
;;
"x86_64-w64-mingw32-gcc")
CONFIGURE_FLAGS="${CONFIGURE_FLAGS} -DCMAKE_FIND_ROOT_PATH=/usr/x86_64-w64-mingw32"
;;
esac
if [ "${CROSS_COMPILE}" = "yes" ]; then
CONFIGURE_FLAGS="${CONFIGURE_FLAGS} -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY -DCMAKE_SYSTEM_NAME=Windows -DDISABLE_UNIT_TESTS=yes -DENABLE_GIPFELI=no"
fi
case "${TRAVIS_OS_NAME}" in
"osx")
CONFIGURE_FLAGS="${CONFIGURE_FLAGS} -DENABLE_MS_COMPRESS=no -DENABLE_NCOMPRESS=no -DENABLE_LZHAM=no"
;;
esac
git submodule update --init --recursive
echo "cmake . ${CONFIGURE_FLAGS} -DCMAKE_C_FLAGS=\"${COMMON_COMPILER_FLAGS}\" -DCMAKE_CXX_FLAGS=\"${COMMON_COMPILER_FLAGS}\""
cmake . ${CONFIGURE_FLAGS} -DCMAKE_C_FLAGS="${COMMON_COMPILER_FLAGS}" -DCMAKE_CXX_FLAGS="${COMMON_COMPILER_FLAGS}"
;;
"make")
case "${BUILD_TYPE}" in
"coverity")
export PATH="$(find $COVERITY_TOOL_BASE -type d -name 'cov-analysis*')/bin:$PATH"
cov-build --dir cov-int make VERBOSE=1
# cov-import-scm --dir cov-int --scm git --log cov-int/scm_log.txt || true
tar czf squash.tgz cov-int
curl \
--silent --write-out "\n%{http_code}\n" \
--form project="${COVERITY_SCAN_PROJECT_NAME}" \
--form token="${COVERITY_SCAN_TOKEN}" \
--form email="[email protected]" \
--form file="@squash.tgz" \
--form version="${TRAVIS_BUILD_NUMBER}/$(git rev-parse --short HEAD)" \
--form description="Travis CI build" \
"https://scan.coverity.com/builds"
;;
*)
make VERBOSE=1
;;
esac
;;
"test")
case "${TRAVIS_OS_NAME}" in
"linux")
CTEST_OUTPUT_ON_FAILURE=TRUE make test || exit 1
;;
"osx")
CTEST_OUTPUT_ON_FAILURE=TRUE make test || exit 1
;;
esac
case "${BUILD_TYPE}" in
"coverage")
coveralls --gcov "${GCOV}" -e CMakeFiles -e plugins -e examples -e tests -e squash/tinycthread
;;
esac
;;
*)
echo "Unknown step."
exit -1
;;
esac