language: c

matrix:
  include:
    - os: linux
      compiler: gcc
      env: TARGET=
    - os: linux
      compiler: clang
      env: TARGET=
    - os: linux
      compiler: gcc
      env: TARGET=debug
    - os: linux
      compiler: clang
      env: TARGET=debug
    - os: linux
      compiler: gcc
      env: TARGET=clean
    - os: linux
      compiler: gcc
      env: TARGET= CONFIG=--disable-curses
    - os: linux
      compiler: gcc
      env: TARGET= CONFIG=--disable-lua
    - os: linux
      compiler: gcc
      env: TARGET= CONFIG=--disable-tre
    - os: osx
      compiler: clang
      env: TARGET=
    - os: osx
      compiler: clang
      env: TARGET=debug
    - os: osx
      compiler: clang
      env: TARGET= CONFIG=--disable-curses
    - os: osx
      compiler: clang
      env: TARGET= CONFIG=--disable-lua
    - os: osx
      compiler: clang
      env: TARGET= CONFIG=--disable-tre

addons:
  apt:
    packages:
    - 9base
    - libacl1-dev
    - libtre-dev

cache:
  directories:
    - $HOME/.cache/vis

before_install:
  - mkdir -p "$HOME/.cache/vis/sources" && mkdir dependency && ln -s "$HOME/.cache/vis/sources" dependency/sources

install:
  - if [ "$TRAVIS_OS_NAME" = "osx" ]; then
      brew update &&
      brew install libtermkey lua tre plan9port &&
      luarocks install lpeg &&
      luarocks install busted;
    fi

script:
  - id
  - env
  - locale
  - tty || true
  - if [ "$TRAVIS_OS_NAME" = "linux" ]; then
      make local && make clean;
    fi
  - ./configure CFLAGS="-I$(pwd)/dependency/install/usr/include" LDFLAGS="-L$(pwd)/dependency/install/usr/lib" $CONFIG
  - make CFLAGS_EXTRA=--coverage $TARGET
  - if [ -e vis ]; then
      LD_LIBRARY_PATH="$(pwd)/dependency/install/usr/lib" ./vis -v;
      file vis;
      size vis;
      if [ "$TRAVIS_OS_NAME" = "osx" ]; then
        otool -L vis;
      else
        ldd vis;
      fi
    fi
  - make -C test/core coverage
  - test ! -e vis || LD_LIBRARY_PATH="$(pwd)/dependency/install/usr/lib" make -C test/lua
  - test ! -e vis || LD_LIBRARY_PATH="$(pwd)/dependency/install/usr/lib" make -C test/vis
  - test ! -e vis || LD_LIBRARY_PATH="$(pwd)/dependency/install/usr/lib" make -C test/sam
  - test ! -e vis || LD_LIBRARY_PATH="$(pwd)/dependency/install/usr/lib" make -C test/vim

after_success:
  - bash <(curl -s https://codecov.io/bash)
