language: cpp
env:
  global:
    - LOCAL=$HOME/local
matrix:
  include:
    - os: osx
      env: export HDT_CPP=clang++
    - os: osx
      env: export HDT_CPP=g++
    - os: linux
      env: export HDT_CPP=clang++
    - os: linux
      env: export HDT_CPP=g++
    - os: linux
      addons:
        apt:
          sources: ['ubuntu-toolchain-r-test']
          packages: ['g++-4.8', 'zlib1g-dev']
      env: export HDT_CPP=g++-4.8
    - os: linux
      addons:
        apt:
          sources: ['ubuntu-toolchain-r-test']
          packages: ['g++-5', 'zlib1g-dev']
      env: export HDT_CPP=g++-5
    - os: linux
      addons:
        apt:
          sources: ['ubuntu-toolchain-r-test']
          packages: ['g++-6', 'zlib1g-dev']
      env: export HDT_CPP=g++-6
before_install:
  - pushd $HOME
  # Download and install Serd
  # - curl -s http://download.drobilla.net/serd-0.24.0.tar.bz2 | tar -xj
  - git clone https://github.com/drobilla/serd.git
  - pushd serd* && ./waf configure --prefix=$LOCAL && ./waf && ./waf install && popd
  # Set up build environment
  - $HDT_CPP --version
  - popd
script:
  # Build standalone binaries
  - ./autogen.sh
  - export PKG_CONFIG_PATH=$LOCAL/lib/pkgconfig
  - export LD_LIBRARY_PATH=$LOCAL/lib
  - export PATH=$LOCAL/bin:$PATH
  - ./configure --prefix=$LOCAL CXX=$HDT_CPP
  - make -j2
  # Make and run selected tests. Most tests in HDT are failing
  - make check -j2 -C libcds || ( cat libcds/tests/test-suite.log && exit -1)
  - make check -j2 -C libhdt || ( cat libhdt/tests/test-suite.log && exit -1)
  # Install
  - make install
  - hdtSearch -q 0 libhdt/data/literals.hdt
  # Test installation files
  - test -f $LOCAL/bin/hdt2rdf
  - test -f $LOCAL/bin/hdtInfo
  - test -f $LOCAL/bin/hdtSearch
  - test -f $LOCAL/bin/modifyHeader
  - test -f $LOCAL/bin/rdf2hdt
  - test -f $LOCAL/bin/replaceHeader
  - test -f $LOCAL/bin/searchHeader
  - test -f $LOCAL/lib/libhdt.la
  - test -f $LOCAL/lib/libcds.la
  - "if [ \"$TRAVIS_OS_NAME\" = \"linux\" ]; then test -L $LOCAL/lib/libhdt.so; fi"
  - "if [ \"$TRAVIS_OS_NAME\" = \"linux\" ]; then test -L $LOCAL/lib/libcds.so; fi"
  - "if [ \"$TRAVIS_OS_NAME\" = \"osx\" ]; then test -L $LOCAL/lib/libhdt.dylib; fi"
  - "if [ \"$TRAVIS_OS_NAME\" = \"osx\" ]; then test -L $LOCAL/lib/libcds.dylib; fi"
  - test -f $LOCAL/lib/pkgconfig/hdt.pc
  - test -f $LOCAL/lib/pkgconfig/cds.pc
