#
# Copyright 2018 - 2022 Free Software Foundation, Inc.
#
# This file is part of VOLK
#
# SPDX-License-Identifier: LGPL-3.0-or-later
#
language: cpp

os: linux
dist: bionic

addons:
  apt:
    packages: &common_packages
      - python3-mako
      - liborc-dev

env:
  global:
    - SDE_VERSION=sde-external-8.50.0-2020-03-26-lin
    - SDE_URL=http://software.intel.com/content/dam/develop/external/us/en/protected/

matrix:
  include:
    # Job 1 ... gcc-7 with Intel SDE
    - name: Linux x86 Intel SDE GCC 7
      env: MATRIX_EVAL="CC=gcc-7 && CXX=g++-7 CMAKE_ARG=-DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchains/intel-sde.cmake"
      addons: {apt: {sources: "ubuntu-toolchain-r-test", packages: [*common_packages]}}
      cache:
        directories:
          - ${TRAVIS_BUILD_DIR}/cache
      before_script:
        - cd ${TRAVIS_BUILD_DIR} && ./scripts/ci/download_intel_sde.sh

    # Job 4 ... gcc-6
    - name: Linux x86 GCC 6
      env: MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"
      addons: {apt: {sources: "ubuntu-toolchain-r-test", packages: [*common_packages, g++-6]}}

    # Job 7 ... ARMv7 cross compile
    - name: Linux ARMv7 Qemu GCC 7
      env: MATRIX_EVAL="CMAKE_ARG=-DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchains/arm-linux-gnueabihf.cmake"
      addons: {apt: {sources: "ubuntu-toolchain-r-test", packages: [*common_packages, g++-arm-linux-gnueabihf, qemu-user]}}

    # Job 8 ... ARMv8 (aarch64) cross compile
    - name: Linux ARMv8 (aarch64) Qemu GCC 7
      env: MATRIX_EVAL="CMAKE_ARG=-DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchains/aarch64-linux-gnu.cmake"
      addons: {apt: {sources: "ubuntu-toolchain-r-test", packages: [*common_packages, g++-aarch64-linux-gnu, qemu-user]}}

    # Job 9 ... clang
    - name: Linux x86 Clang 6
      env: MATRIX_EVAL="CC=\"clang -fprofile-instr-generate -fcoverage-mapping\" && CXX=\"clang++ -fprofile-instr-generate -fcoverage-mapping\""
      addons: {apt: {packages: [*common_packages, ]}}

    - name: Linux ARMv8 (aarch64) GCC 7
      arch: arm64
      env: MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"
      addons: {apt: {packages: [*common_packages, ]}}

    - name: Linux ARMv8 (aarch64) Clang 6
      arch: arm64
      env: MATRIX_EVAL="CC=clang && CXX=clang++"
      addons: {apt: {packages: [*common_packages, ]}}

script:
  - eval "${MATRIX_EVAL}"
  - lscpu
  - git submodule update --init --recursive
  - mkdir build && cd build
  - cmake ${CMAKE_ARG} ../
  - make
  - echo $(./apps/volk-config-info --malloc) && echo $(./apps/volk-config-info --alignment) && echo "All compiled VOLK machines:" $(./apps/volk-config-info --all-machines) && echo "Available VOLK machines:" $(./apps/volk-config-info --avail-machines)
  - ctest -V
