Added an ARM cross-compile build to Travis.
[platform/upstream/libexif.git] / .travis.yml
1 # Travis CI configuration file
2
3 sudo: false
4
5 language: c
6
7 git:
8   depth: 1
9
10 # Install autopoint on Ubuntu (needed for gettext)
11 addons:
12   apt:
13     packages:
14     - autopoint
15
16 env:
17   # More configurations are configured in the matrix section
18   matrix:
19     - CONFIG=normal
20     - CONFIG=c90
21     - CONFIG=stackprotect
22   global:
23     - MAKEFLAGS='-j 2'
24
25 compiler:
26   - clang
27   - gcc
28
29 os:
30   - linux
31   - osx
32
33 matrix:
34   include:
35   - os: linux
36     addons:
37       apt:
38         sources:
39           - llvm-toolchain-trusty-6.0
40           - ubuntu-toolchain-r-test
41         packages:
42           - autopoint
43           - clang-6.0
44     compiler: clang
45     env:
46       - CONFIG=clang6
47   - os: linux
48     addons:
49       apt:
50         sources:
51           - ubuntu-toolchain-r-test
52         packages:
53           - autopoint
54           - g++-8
55     compiler: gcc
56     env:
57       - CONFIG=gcc8
58   - os: linux
59     addons:
60       apt:
61         packages:
62           - autopoint
63           - gcc-4.8-arm-linux-gnueabihf
64           - libc6-dev-armhf-cross
65     compiler: gcc
66     env:
67       - CONFIG=arm-cross
68   - os: linux
69     addons:
70       apt:
71         sources:
72           - llvm-toolchain-trusty-6.0
73           - ubuntu-toolchain-r-test
74         packages:
75           - autopoint
76           - clang-6.0
77           - libtool
78     compiler: clang
79     # Required for -fsanitize=undefined
80     # see https://github.com/travis-ci/travis-ci/issues/9033
81     sudo: required
82     env:
83       - CONFIG=sanitize
84   - os: linux
85     addons:
86       apt:
87         packages:
88           - autopoint
89           - libpopt-dev
90           - subversion
91     compiler: gcc
92     cache:
93       directories:
94         - $HOME/failmalloc
95     env:
96       - CONFIG=coverage
97
98 install:
99   - |
100     if [ "$CONFIG" = "coverage" ] ; then
101       set -e
102       pip install --user cpp-coveralls
103       cd "$HOME"
104       git clone --depth=1 https://github.com/libexif/libexif-testsuite.git
105       cd libexif-testsuite
106       mkdir src
107       ln -s "$TRAVIS_BUILD_DIR" src/libexif
108       ./build-config.sh
109       autoreconf -sivf
110       cd "$HOME"
111       # Failmalloc for improved test coverage
112       if [ ! -e "$HOME/failmalloc/lib/libfailmalloc.so.0" ] ; then
113         curl -fsSORL https://download.savannah.nongnu.org/releases/failmalloc/failmalloc-1.0.tar.gz
114         tar xaf failmalloc-1.0.tar.gz
115         cd failmalloc-1.0
116         sed -i -e 's/\(__malloc_initialize_hook\)/volatile \1/' failmalloc.c
117         ./configure --prefix="$HOME/failmalloc"
118         make
119         make install
120       fi
121       cd "$TRAVIS_BUILD_DIR"
122     fi
123
124 script:
125   # Ensure brew gettext is in the PATH so autopoint is found on OS X
126   - PATH="$PATH:/usr/local/opt/gettext/bin" autoreconf -sivf
127   - if [ "$CONFIG" = "normal" ] ; then CFLAGS='-Wall -Wextra -O3'; fi
128   - if [ "$CONFIG" = "c90" ] ; then CFLAGS='-std=iso9899:1990 -D_XOPEN_SOURCE=500 -Wall -Wextra -O3'; fi
129   - if [ "$CONFIG" = "stackprotect" ] ; then CFLAGS='-g -O0 -fstack-protector-all'; fi
130   - if [ "$CONFIG" = "clang6" ] ; then CFLAGS='-Wall -Wextra -O3'; export CC=clang-6.0; fi
131   - if [ "$CONFIG" = "gcc8" ] ; then CFLAGS='-Wall -Wextra -O3'; export CC=gcc-8; fi
132   - if [ "$CONFIG" = "arm-cross" ] ; then CFLAGS='-Wall -Wextra -O3'; export CC=arm-linux-gnueabihf-gcc-4.8; CONFIGURE_OPTS='--host=arm-linux-gnueabihf'; fi
133   - if [ "$CONFIG" = "sanitize" ] ; then CFLAGS='-g -Wall -Wextra -fsanitize=address -fsanitize=undefined'; export CC=clang-6.0; fi
134   - if [ "$CONFIG" = "coverage" ] ; then cd "$HOME"/libexif-testsuite; CFLAGS=--coverage; CONFIGURE_OPTS="LDFLAGS=--coverage --with-failmalloc=$HOME/failmalloc/lib" ; fi
135   - ./configure --prefix="${HOME}"/install CFLAGS="$CFLAGS" $CONFIGURE_OPTS || { tail -300 config.log; false; }
136
137   - make V=1
138   # Skip tests when cross compiling.
139   - if [ "$CONFIG" != "arm-cross" ] ; then make V=1 check || { tail -300 test*/test-suite.log; false; }; fi
140   - make V=1 install
141
142   - if [ "$CONFIG" = "coverage" ] ; then cd "$TRAVIS_BUILD_DIR"; fi
143
144 after_success:
145   - if [ "$CONFIG" = "coverage" ] ; then coveralls --build-root libexif --exclude test --exclude contrib --gcov-options '\-lp'; fi