dist: xenial
sudo: required
language: c
cache:
  apt: true
  directories:
  - $HOME/.opam
addons:
  apt:
    packages:
    - libgtksourceview-3.0-dev
    - libgtkspell3-3-dev
env:
  global:
  - OPAMJOBS="2"
  - OPAMROOTISOK="true"
  - OPAMYES="true"
  - COMPILER="4.07.1"
  - BASE_OPAM="camlp4 dune cairo2"

  # Main test suite, some examples don't work in 4.05.0
  matrix:
  - TEST_TARGET="build"       COMPILER="4.05.0"
  - TEST_TARGET="build-all"   COMPILER="4.06.1"
  - TEST_TARGET="build-all"   COMPILER="4.07.1"
  - TEST_TARGET="opam"        COMPILER="4.07.1"

matrix:
  include:
    - os: osx
      env:
        - TEST_TARGET="build" COMPILER="4.07.1"
        - PKG_CONFIG_PATH=/usr/local/opt/libffi/lib/pkgconfig
      cache:
        ccache: true
        directories:
          - $HOME/.opam
          - $HOME/Library/Caches/Homebrew
      before_cache:
        - brew cleanup
      before_install: |
        set -e
        brew update
        brew install ccache opam pkg-config gtk+3 gtksourceview3 gtkspell3

before_install: |
  sudo curl -sL https://github.com/ocaml/opam/releases/download/2.0.1/opam-2.0.1-x86_64-linux -o /usr/bin/opam
  sudo chmod 755 /usr/bin/opam

install: |
  opam init -c "$COMPILER" --disable-sandboxing
  opam switch set "$COMPILER"
  eval $(opam env)
  opam install $BASE_OPAM
  opam list

script:
- set -e
- echo 'Building LablGtk...' && echo -en 'travis_fold:start:lablgtk.build\\r'
- pkg-config --list-all
- make -f Makefile.travis "$TEST_TARGET"
- echo -en 'travis_fold:end:lablgtk.build\\r'
