cache:
  # This persistent cache is used to cache the building of
  # docker base images.
  directories:
    - $DOCKER_TRAVIS_CI_CACHE_DIR
sudo: required
language: cpp
services:
  - docker
env:
  global:
    # This environment variable tells the `travis_ci_linux_entry_point.sh`
    # script to look for a cached Docker image.
    - DOCKER_TRAVIS_CI_CACHE_DIR=$HOME/.cache/docker
  # Configurations
  matrix:
###############################################################################
# Ubuntu 18.04 LTS
###############################################################################
    # Note the unit tests for the debug builds are compiled but **not**
    # executed. This is because the debug build of unit tests takes a large
    # amount of time to execute compared to the optimized builds.

    # clang
    - LINUX_BASE=ubuntu_18.04 C_COMPILER=clang CXX_COMPILER=clang++ TARGET_ARCH=x86_64 Z3_BUILD_TYPE=Debug UBSAN_BUILD=1 RUN_UNIT_TESTS=BUILD_ONLY
    - LINUX_BASE=ubuntu_18.04 C_COMPILER=clang CXX_COMPILER=clang++ TARGET_ARCH=x86_64 Z3_BUILD_TYPE=Debug ASAN_BUILD=1 RUN_UNIT_TESTS=BUILD_ONLY
    - LINUX_BASE=ubuntu_18.04 C_COMPILER=clang CXX_COMPILER=clang++ TARGET_ARCH=x86_64 Z3_BUILD_TYPE=RelWithDebInfo ASAN_BUILD=1 RUN_UNIT_TESTS=BUILD_AND_RUN UBSAN_BUILD=1 RUN_API_EXAMPLES=0 RUN_SYSTEM_TESTS=0 DOTNET_BINDINGS=0 JAVA_BINDINGS=0 PYTHON_BINDINGS=0

    # gcc
    - LINUX_BASE=ubuntu_18.04 C_COMPILER=gcc CXX_COMPILER=g++ TARGET_ARCH=x86_64 Z3_BUILD_TYPE=Release RUN_UNIT_TESTS=BUILD_AND_RUN
    - LINUX_BASE=ubuntu_18.04 C_COMPILER=gcc CXX_COMPILER=g++ TARGET_ARCH=x86_64 Z3_BUILD_TYPE=Debug UBSAN_BUILD=1 RUN_UNIT_TESTS=BUILD_ONLY
    - LINUX_BASE=ubuntu_18.04 C_COMPILER=gcc CXX_COMPILER=g++ TARGET_ARCH=x86_64 Z3_BUILD_TYPE=Debug ASAN_BUILD=1 RUN_UNIT_TESTS=BUILD_ONLY

    # Both of the two configurations below build the docs because the current
    # implementation uses python as part of the building process.
    # TODO: Teach one of the configurations to upload built docs somewhere.
    # Test with Python 3 and API docs
    - LINUX_BASE=ubuntu_18.04 PYTHON_EXECUTABLE=/usr/bin/python3 BUILD_DOCS=1
    # Test with LibGMP and API docs
    - LINUX_BASE=ubuntu_18.04 TARGET_ARCH=x86_64 USE_LIBGMP=1 BUILD_DOCS=1 PYTHON_EXECUTABLE=/usr/bin/python2.7

    # Unix Makefile generator build
    - LINUX_BASE=ubuntu_18.04 TARGET_ARCH=x86_64 Z3_CMAKE_GENERATOR="Unix Makefiles"

    # LTO build
    - LINUX_BASE=ubuntu_18.04 TARGET_ARCH=x86_64 USE_LTO=1

    # Static build. Note we have disable building the bindings because they won't work with a static libz3
    - LINUX_BASE=ubuntu_18.04 TARGET_ARCH=x86_64 Z3_STATIC_BUILD=1 DOTNET_BINDINGS=0 JAVA_BINDINGS=0 PYTHON_BINDINGS=0


script:
  # Use `travis_wait` when doing LTO builds because this configuration will
  # have long link times during which it will not show any output which
  # TravisCI might kill due to perceived inactivity.
  - if [ "X${USE_LTO}" = "X1" ]; then
      travis_wait 55 contrib/ci/scripts/travis_ci_entry_point.sh || exit 1;
    else
      contrib/ci/scripts/travis_ci_entry_point.sh || exit 1;
    fi