| #!/bin/bash |
| |
| set -o errexit -o nounset -o pipefail |
| set -o xtrace |
| |
| # Calls CMake to generate build files and then run the build. |
| # Usage: |
| # generate_and_build <output directory> [<other generate args> ...] |
| generate_and_build() { |
| local folder_name=$1 |
| shift |
| |
| mkdir "${folder_name}" |
| (cd "${folder_name}"; cmake "$@" ..) |
| cmake --build "${folder_name}" |
| } |
| |
| # Installs given packages. |
| # Usage: |
| # apt_install <package1> [<package2> ...] |
| apt_install() { |
| # Update package lists first. Without this, we've seen missing packages |
| # and dependency conflicts that block installation. |
| sudo apt update |
| |
| sudo apt install "$@" |
| } |
| |
| OS_COMPILER_CPU=${TRAVIS_OS_NAME}_${TRAVIS_COMPILER}_${TRAVIS_CPU_ARCH} |
| case "${OS_COMPILER_CPU}" in |
| linux_clang_*) |
| apt_install "linux-headers-$(uname -r)" |
| |
| generate_and_build build -DCMAKE_CXX_CLANG_TIDY=clang-tidy |
| ;; |
| |
| osx_clang_*) |
| generate_and_build build |
| ;; |
| |
| windows_*) |
| generate_and_build build-x64 -A x64 |
| generate_and_build build-win32 -A Win32 |
| ;; |
| |
| linux_gcc_amd64) |
| # Install the 32-bit compiler and C/C++ runtimes |
| apt_install \ |
| "linux-headers-$(uname -r)" \ |
| g++-i686-linux-gnu \ |
| libc6:i386 \ |
| libstdc++6:i386 |
| |
| generate_and_build build-x86_64 |
| generate_and_build build-i686 \ |
| -DCMAKE_TOOLCHAIN_FILE=ci/toolchains/i686-linux-gnu.cmake |
| ;; |
| |
| linux_gcc_*) |
| apt_install "linux-headers-$(uname -r)" |
| |
| generate_and_build build |
| ;; |
| esac |