language: cpp

matrix:
    include:
        - env: CTEST_OUTPUT_ON_FAILURE=1
        - env: CTEST_OUTPUT_ON_FAILURE=1 CFLAGS='-fsanitize=address'
        - env: CTEST_OUTPUT_ON_FAILURE=1 OPTION='-DCMAKE_CXX_FLAGS=-O0 -DENABLE_GCOV=yes' COVERALLS=yes

git:
    depth: 1

before_install:
    - sudo pip install cpp-coveralls
    - sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test
    - sudo add-apt-repository --yes ppa:ubuntu-sdk-team/ppa
    - sudo add-apt-repository --yes ppa:chewing/chewing
    - sudo add-apt-repository --yes ppa:chewing/travis-ci
    - sudo apt-get update
      # FIXME: We need to instal cmake-data manually to prevent cmake upgrade fails.
    - sudo apt-get install --yes cmake-data cmake gcc-4.8 g++-4.8 help2man libchewing3-dev pkg-config qt5-default qttools5-dev-tools
    - sudo ln -fs /usr/bin/gcc-4.8 /usr/bin/gcc
    - gcc --version
    - sudo ln -fs /usr/bin/g++-4.8 /usr/bin/g++
    - g++ --version
    - sudo ln -fs /usr/bin/gcov-4.8 /usr/bin/gcov
    - gcov --version

script:
    - cmake $OPTION .
    - make -j2
    - make -j2 check

after_success:
    - if [ x$COVERALLS == xyes ]; then coveralls --exclude gmock --exclude test --exclude-pattern '.*CMake[^/]+\.c(?:pp)?' --exclude-pattern '.*_automoc.cpp'; fi
