summaryrefslogtreecommitdiff
path: root/.travis.yml
blob: ce0b95d6d4c214ea60f0ef9571ebd2d9d967c623 (plain)
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
# Travis CI configuration file

sudo: false

language: c

git:
  # Set to 10 instead of 1 to avoid problems when the most recent commits have [skip ci]
  depth: 10

# Install autopoint on Ubuntu (needed for gettext)
# This is ignored on bionic for some reason (see below).
addons:
  apt:
    packages:
    - autopoint

env:
  # More configurations are configured in the matrix section
  matrix:
    - CONFIG=normal
    - CONFIG=c90
    - CONFIG=stackprotect
    - CONFIG=disable-nls
  global:
    - MAKEFLAGS='-j 2'

compiler:
  - clang
  - gcc

os:
  - linux
  - osx

matrix:
  include:
  - env: CONFIG=normal DIST=bionic
    os: linux
    dist: bionic
    compiler: gcc
  - env: CONFIG=normal DIST=bionic
    os: linux
    dist: bionic
    compiler: clang
  - env: CONFIG=clang6 DIST=xenial
    os: linux
    dist: xenial
    compiler: clang
    addons:
      apt:
        packages:
          - autopoint
          - clang-6.0
  - env: CONFIG=clang8 DIST=xenial
    os: linux
    dist: xenial
    compiler: clang
    addons:
      apt:
        sources:
          - llvm-toolchain-trusty-8
        packages:
          - autopoint
          - clang-8
  - env: CONFIG=clang9 DIST=xenial
    os: linux
    dist: xenial
    compiler: clang
    addons:
      apt:
        sources:
          sourceline:
            - deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main
          key_url:
            - https://apt.llvm.org/llvm-snapshot.gpg.key
        packages:
          - autopoint
          - clang-9
  - env: CONFIG=clang10 DIST=xenial
    os: linux
    dist: xenial
    compiler: clang
    addons:
      apt:
        sources:
          sourceline:
            - deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main
          key_url:
            - https://apt.llvm.org/llvm-snapshot.gpg.key
        packages:
          - autopoint
          - clang-10
  - env: CONFIG=gcc8 DIST=xenial
    os: linux
    dist: xenial
    compiler: gcc
    addons:
      apt:
        sources:
          sourceline:
            - ppa:ubuntu-toolchain-r/test
        packages:
          - autopoint
          - g++-8
  - env: CONFIG=gcc9 DIST=xenial
    os: linux
    dist: xenial
    compiler: gcc
    addons:
      apt:
        sources:
          sourceline:
            - ppa:ubuntu-toolchain-r/test
        packages:
          - autopoint
          - g++-9
  - env: CONFIG=arm-cross DIST=xenial
    os: linux
    dist: xenial
    compiler: gcc
    addons:
      apt:
        packages:
          - autopoint
          - gcc-4.8-arm-linux-gnueabihf
          - libc6-dev-armhf-cross
  - env: CONFIG=musl DIST=xenial
    os: linux
    dist: xenial
    compiler: gcc
    addons:
      apt:
        packages:
          - autopoint
          - musl-tools
  - env: CONFIG=sanitize DIST=xenial
    os: linux
    dist: xenial
    compiler: clang
    addons:
      apt:
        sources:
          sourceline:
            - deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main
          key_url:
            - https://apt.llvm.org/llvm-snapshot.gpg.key
        packages:
          - autopoint
          - clang-10
          - libtool
    # Required for -fsanitize=undefined
    # see https://github.com/travis-ci/travis-ci/issues/9033
    sudo: required
  - env: CONFIG=coverage DIST=xenial
    os: linux
    dist: xenial
    compiler: gcc
    addons:
      apt:
        packages:
          - autopoint
          - libpopt-dev
          - subversion
    cache:
      directories:
        - $HOME/failmalloc
  - env: CONFIG=normal DIST=bionic
    arch: arm64
    os: linux
    dist: bionic
    compiler: gcc
  - env: CONFIG=normal DIST=bionic
    arch: ppc64le
    os: linux
    dist: bionic
    compiler: gcc

before_install:
  # The apt addons section is ignored on bionic for some reason
  - if [ "$DIST" = "bionic" ] ; then sudo apt-get install -y autopoint gettext libtool; fi

install:
  - |
    if [ "$CONFIG" = "coverage" ] ; then
      set -e
      pip install --user cpp-coveralls
      cd "$HOME"
      git clone --depth=1 https://github.com/libexif/libexif-testsuite.git
      cd libexif-testsuite
      mkdir src
      ln -s "$TRAVIS_BUILD_DIR" src/libexif
      ./build-config.sh
      autoreconf -sivf
      cd "$HOME"
      # Failmalloc for improved test coverage
      if [ ! -e "$HOME/failmalloc/lib/libfailmalloc.so.0" ] ; then
        curl -fsSORL --retry 8 https://download.savannah.nongnu.org/releases/failmalloc/failmalloc-1.0.tar.gz
        tar xaf failmalloc-1.0.tar.gz
        cd failmalloc-1.0
        # Fix compiling with modern glibc
        sed -i -e 's/\(__malloc_initialize_hook\)/volatile \1/' failmalloc.c
        # Disable failmalloc on program exit so system code can run unimpeded
        sed -i -e '/failmalloc_init/,${/failmalloc_install/aatexit(failmalloc_uninstall);
        }' failmalloc.c
        ./configure --prefix="$HOME/failmalloc" --disable-dependency-tracking
        make
        make install
      fi
      cd "$TRAVIS_BUILD_DIR"
    fi

script:
  # Ensure brew gettext is in the PATH so autopoint is found on OS X
  - PATH="$PATH:/usr/local/opt/gettext/bin" autoreconf -sivf
  - if [ "$CONFIG" = "normal" ] ; then CFLAGS='-Wall -Wextra -O3'; fi
  - if [ "$CONFIG" = "c90" ] ; then CFLAGS='-std=iso9899:1990 -D_XOPEN_SOURCE=500 -Wall -Wextra -O3'; fi
  - if [ "$CONFIG" = "stackprotect" ] ; then CFLAGS='-g -O0 -fstack-protector-all'; fi
  - if [ "$CONFIG" = "disable-nls" ] ; then CFLAGS='-Wall -Wextra -O3'; CONFIGURE_OPTS='--disable-nls'; fi
  - if [ "$CONFIG" = "clang6" ] ; then CFLAGS='-Wall -Wextra -O3'; export CC=clang-6.0; fi
  - if [ "$CONFIG" = "clang8" ] ; then CFLAGS='-Wall -Wextra -Wno-error=switch -O3'; MAKE_OPTS="CFLAGS+=-Werror CFLAGS+=${CFLAGS// / CFLAGS+=}"; export CC=clang-8; fi
  - if [ "$CONFIG" = "clang9" ] ; then CFLAGS='-Wall -Wextra -Wno-error=switch -O3'; MAKE_OPTS="CFLAGS+=-Werror CFLAGS+=${CFLAGS// / CFLAGS+=}"; export CC=clang-9; fi
  - if [ "$CONFIG" = "clang10" ] ; then CFLAGS='-Wall -Wextra -Wno-error=switch -O3'; MAKE_OPTS="CFLAGS+=-Werror CFLAGS+=${CFLAGS// / CFLAGS+=}"; export CC=clang-10; fi
  - 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
  - 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
  - if [ "$CONFIG" = "arm-cross" ] ; then CFLAGS='-Wall -Wextra -O3'; export CC=arm-linux-gnueabihf-gcc-4.8; CONFIGURE_OPTS='--host=arm-linux-gnueabihf'; fi
  - if [ "$CONFIG" = "musl" ] ; then CFLAGS='-Wall -Wextra -O3'; export CC=musl-gcc; CONFIGURE_OPTS='--disable-shared'; fi
  - 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
  - if [ "$CONFIG" = "coverage" ] ; then cd "$HOME"/libexif-testsuite; CFLAGS=--coverage; CONFIGURE_OPTS="LDFLAGS=--coverage --with-failmalloc=$HOME/failmalloc/lib"; fi
  - ./configure --prefix="$HOME"/install --disable-dependency-tracking CFLAGS="$CFLAGS" $CONFIGURE_OPTS || { tail -n 300 config.log; false; }

  - make V=1 $MAKE_OPTS
  # Skip tests when cross compiling.
  - 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
  - make V=1 $MAKE_OPTS install

  - if [ "$CONFIG" = "coverage" ] ; then cd "$TRAVIS_BUILD_DIR"; fi

after_success:
  - if [ "$CONFIG" = "coverage" ] ; then coveralls --build-root libexif --exclude test --exclude contrib --gcov-options '\-lp'; fi