Reorganize some Travis builds.
[platform/upstream/libexif.git] / .travis.yml
1 # Travis CI configuration file
2
3 sudo: false
4
5 language: c
6
7 git:
8   # Set to 10 instead of 1 to avoid problems when the most recent commits have [skip ci]
9   depth: 10
10
11 # Install autopoint on Ubuntu (needed for gettext)
12 # This is ignored on bionic for some reason (see below).
13 addons:
14   apt:
15     packages:
16     - autopoint
17
18 env:
19   # More configurations are configured in the matrix section
20   matrix:
21     - CONFIG=normal
22     - CONFIG=c90
23     - CONFIG=stackprotect
24     - CONFIG=disable-nls
25   global:
26     - MAKEFLAGS='-j 2'
27
28 compiler:
29   - clang
30   - gcc
31
32 os:
33   - linux
34   - osx
35
36 matrix:
37   include:
38   - env: CONFIG=normal DIST=bionic
39     os: linux
40     dist: bionic
41     compiler: gcc
42   - env: CONFIG=normal DIST=bionic
43     os: linux
44     dist: bionic
45     compiler: clang
46   - env: CONFIG=clang6 DIST=xenial
47     os: linux
48     dist: xenial
49     compiler: clang
50     addons:
51       apt:
52         packages:
53           - autopoint
54           - clang-6.0
55   - env: CONFIG=clang8 DIST=xenial
56     os: linux
57     dist: xenial
58     compiler: clang
59     addons:
60       apt:
61         sources:
62           - llvm-toolchain-trusty-8
63           - ubuntu-toolchain-r-test
64         packages:
65           - autopoint
66           - clang-8
67   - env: CONFIG=clang9 DIST=xenial
68     os: linux
69     dist: xenial
70     compiler: clang
71     addons:
72       apt:
73         sources:
74           sourceline:
75             - deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main
76           key_url:
77             - https://apt.llvm.org/llvm-snapshot.gpg.key
78         packages:
79           - autopoint
80           - clang-9
81   - env: CONFIG=clang10 DIST=xenial
82     os: linux
83     dist: xenial
84     compiler: clang
85     addons:
86       apt:
87         sources:
88           sourceline:
89             - deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main
90           key_url:
91             - https://apt.llvm.org/llvm-snapshot.gpg.key
92         packages:
93           - autopoint
94           - clang-10
95   - env: CONFIG=gcc8 DIST=xenial
96     os: linux
97     dist: xenial
98     compiler: gcc
99     addons:
100       apt:
101         sources:
102           - ubuntu-toolchain-r-test
103         packages:
104           - autopoint
105           - g++-8
106   - env: CONFIG=gcc9 DIST=xenial
107     os: linux
108     dist: xenial
109     compiler: gcc
110     addons:
111       apt:
112         sources:
113           - ubuntu-toolchain-r-test
114         packages:
115           - autopoint
116           - g++-9
117   - env: CONFIG=arm-cross DIST=xenial
118     os: linux
119     dist: xenial
120     compiler: gcc
121     addons:
122       apt:
123         packages:
124           - autopoint
125           - gcc-4.8-arm-linux-gnueabihf
126           - libc6-dev-armhf-cross
127   - env: CONFIG=musl DIST=xenial
128     os: linux
129     dist: xenial
130     compiler: gcc
131     addons:
132       apt:
133         packages:
134           - autopoint
135           - musl-tools
136   - env: CONFIG=sanitize DIST=xenial
137     os: linux
138     dist: xenial
139     compiler: clang
140     addons:
141       apt:
142         sources:
143           sourceline:
144             - deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main
145           key_url:
146             - https://apt.llvm.org/llvm-snapshot.gpg.key
147         packages:
148           - autopoint
149           - clang-10
150           - libtool
151     # Required for -fsanitize=undefined
152     # see https://github.com/travis-ci/travis-ci/issues/9033
153     sudo: required
154   - env: CONFIG=coverage DIST=xenial
155     os: linux
156     dist: xenial
157     compiler: gcc
158     addons:
159       apt:
160         packages:
161           - autopoint
162           - libpopt-dev
163           - subversion
164     cache:
165       directories:
166         - $HOME/failmalloc
167   - env: CONFIG=normal DIST=bionic
168     arch: arm64
169     os: linux
170     dist: bionic
171     compiler: gcc
172   - env: CONFIG=normal DIST=bionic
173     arch: ppc64le
174     os: linux
175     dist: bionic
176     compiler: gcc
177
178 before_install:
179   # The apt addons section is ignored on bionic for some reason
180   - if [ "$DIST" = "bionic" ] ; then sudo apt-get install -y autopoint gettext libtool; fi
181
182 install:
183   - |
184     if [ "$CONFIG" = "coverage" ] ; then
185       set -e
186       pip install --user cpp-coveralls
187       cd "$HOME"
188       git clone --depth=1 https://github.com/libexif/libexif-testsuite.git
189       cd libexif-testsuite
190       mkdir src
191       ln -s "$TRAVIS_BUILD_DIR" src/libexif
192       ./build-config.sh
193       autoreconf -sivf
194       cd "$HOME"
195       # Failmalloc for improved test coverage
196       if [ ! -e "$HOME/failmalloc/lib/libfailmalloc.so.0" ] ; then
197         curl -fsSORL --retry 8 https://download.savannah.nongnu.org/releases/failmalloc/failmalloc-1.0.tar.gz
198         tar xaf failmalloc-1.0.tar.gz
199         cd failmalloc-1.0
200         # Fix compiling with modern glibc
201         sed -i -e 's/\(__malloc_initialize_hook\)/volatile \1/' failmalloc.c
202         # Disable failmalloc on program exit so system code can run unimpeded
203         sed -i -e '/failmalloc_init/,${/failmalloc_install/aatexit(failmalloc_uninstall);
204         }' failmalloc.c
205         ./configure --prefix="$HOME/failmalloc" --disable-dependency-tracking
206         make
207         make install
208       fi
209       cd "$TRAVIS_BUILD_DIR"
210     fi
211
212 script:
213   # Ensure brew gettext is in the PATH so autopoint is found on OS X
214   - PATH="$PATH:/usr/local/opt/gettext/bin" autoreconf -sivf
215   - if [ "$CONFIG" = "normal" ] ; then CFLAGS='-Wall -Wextra -O3'; fi
216   - if [ "$CONFIG" = "c90" ] ; then CFLAGS='-std=iso9899:1990 -D_XOPEN_SOURCE=500 -Wall -Wextra -O3'; fi
217   - if [ "$CONFIG" = "stackprotect" ] ; then CFLAGS='-g -O0 -fstack-protector-all'; fi
218   - if [ "$CONFIG" = "disable-nls" ] ; then CFLAGS='-Wall -Wextra -O3'; CONFIGURE_OPTS='--disable-nls'; fi
219   - if [ "$CONFIG" = "clang6" ] ; then CFLAGS='-Wall -Wextra -O3'; export CC=clang-6.0; fi
220   - if [ "$CONFIG" = "clang8" ] ; then CFLAGS='-Wall -Wextra -Wno-error=switch -O3'; MAKE_OPTS="CFLAGS+=-Werror CFLAGS+=${CFLAGS// / CFLAGS+=}"; export CC=clang-8; fi
221   - if [ "$CONFIG" = "clang9" ] ; then CFLAGS='-Wall -Wextra -Wno-error=switch -O3'; MAKE_OPTS="CFLAGS+=-Werror CFLAGS+=${CFLAGS// / CFLAGS+=}"; export CC=clang-9; fi
222   - if [ "$CONFIG" = "clang10" ] ; then CFLAGS='-Wall -Wextra -Wno-error=switch -O3'; MAKE_OPTS="CFLAGS+=-Werror CFLAGS+=${CFLAGS// / CFLAGS+=}"; export CC=clang-10; fi
223   - if [ "$CONFIG" = "gcc8" ] ; then CFLAGS='-Wall -Wextra -Wno-error=switch -Wno-error=implicit-fallthrough -O3'; MAKE_OPTS="CFLAGS+=-Werror CFLAGS+=${CFLAGS// / CFLAGS+=}"; export CC=gcc-8; fi
224   - if [ "$CONFIG" = "gcc9" ] ; then CFLAGS='-Wall -Wextra -Wno-error=switch -Wno-error=implicit-fallthrough -O3'; MAKE_OPTS="CFLAGS+=-Werror CFLAGS+=${CFLAGS// / CFLAGS+=}"; export CC=gcc-9; fi
225   - if [ "$CONFIG" = "arm-cross" ] ; then CFLAGS='-Wall -Wextra -O3'; export CC=arm-linux-gnueabihf-gcc-4.8; CONFIGURE_OPTS='--host=arm-linux-gnueabihf'; fi
226   - if [ "$CONFIG" = "musl" ] ; then CFLAGS='-Wall -Wextra -O3'; export CC=musl-gcc; CONFIGURE_OPTS='--disable-shared'; fi
227   - if [ "$CONFIG" = "sanitize" ] ; then CFLAGS='-g -Wall -Wextra -fsanitize=address -fsanitize=undefined -fsanitize-address-use-after-scope'; export CC=clang-10; export ASAN_OPTIONS=strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1:detect_leaks=1; fi
228   - if [ "$CONFIG" = "coverage" ] ; then cd "$HOME"/libexif-testsuite; CFLAGS=--coverage; CONFIGURE_OPTS="LDFLAGS=--coverage --with-failmalloc=$HOME/failmalloc/lib"; fi
229   - ./configure --prefix="$HOME"/install --disable-dependency-tracking CFLAGS="$CFLAGS" $CONFIGURE_OPTS || { tail -n 300 config.log; false; }
230
231   - make V=1 $MAKE_OPTS
232   # Skip tests when cross compiling.
233   - if [ "$CONFIG" != "arm-cross" ] ; then make V=1 $MAKE_OPTS check || { tail -n 300 test*/test-suite.log src/libexif/test*/test-suite.log; false; }; fi
234   - make V=1 $MAKE_OPTS install
235
236   - if [ "$CONFIG" = "coverage" ] ; then cd "$TRAVIS_BUILD_DIR"; fi
237
238 after_success:
239   - if [ "$CONFIG" = "coverage" ] ; then coveralls --build-root libexif --exclude test --exclude contrib --gcov-options '\-lp'; fi