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 20.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_20.04 C_COMPILER=clang CXX_COMPILER=clang++ TARGET_ARCH=x86_64 Z3_BUILD_TYPE=Debug
    - LINUX_BASE=ubuntu_20.04 C_COMPILER=clang CXX_COMPILER=clang++ TARGET_ARCH=x86_64 Z3_BUILD_TYPE=Release UBSAN_BUILD=1
    - LINUX_BASE=ubuntu_20.04 C_COMPILER=clang CXX_COMPILER=clang++ TARGET_ARCH=x86_64 Z3_BUILD_TYPE=Release ASAN_BUILD=1 DOTNET_BINDINGS=0 JAVA_BINDINGS=0 PYTHON_BINDINGS=0

    # gcc
    # ubsan/msan builds too slow
    - LINUX_BASE=ubuntu_20.04 C_COMPILER=gcc CXX_COMPILER=g++ TARGET_ARCH=x86_64 Z3_BUILD_TYPE=Release BUILD_DOCS=1
    - LINUX_BASE=ubuntu_20.04 C_COMPILER=gcc CXX_COMPILER=g++ TARGET_ARCH=x86_64 Z3_BUILD_TYPE=Debug

    # GMP library
    - LINUX_BASE=ubuntu_20.04 TARGET_ARCH=x86_64 Z3_BUILD_TYPE=Release USE_LIBGMP=1
    - LINUX_BASE=ubuntu_20.04 TARGET_ARCH=x86_64 Z3_BUILD_TYPE=Debug USE_LIBGMP=1

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

    # LTO build
    - LINUX_BASE=ubuntu_20.04 C_COMPILER=gcc CXX_COMPILER=g++ TARGET_ARCH=x86_64 USE_LTO=1 RUN_UNIT_TESTS=BUILD_ONLY RUN_SYSTEM_TESTS=0
    - LINUX_BASE=ubuntu_20.04 C_COMPILER=clang CXX_COMPILER=clang++ TARGET_ARCH=x86_64 USE_LTO=1 RUN_UNIT_TESTS=BUILD_ONLY RUN_SYSTEM_TESTS=0

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


script:
  # Use `travis_wait` when building because some configurations don't produce an
  # output for a long time (linking & testing)
  - travis_wait 55 contrib/ci/scripts/travis_ci_entry_point.sh || exit 1;