language: c

# Dump CPU info before start
before_install:
  - cat /proc/cpuinfo

matrix:
  fast_finish: true
  include:

    - name: General linux tests (Xenial)
      dist: xenial
      arch: amd64
      addons:
        apt:
          packages:
            - clang
            - g++-multilib
            - gcc-multilib
            - cppcheck
      script:
        - make -B test-all

    - name: Check results consistency on x64
      arch: amd64
      script:
        - CPPFLAGS=-DXXH_VECTOR=0 make check   # Scalar code path
        - make clean
        - CPPFLAGS=-DXXH_VECTOR=1 make check   # SSE2 code path
        - make clean
        - CPPFLAGS="-mavx2 -DXXH_VECTOR=2" make check   # AVX2 code path
        - make clean
        - CPPFLAGS=-DXXH_REROLL=1 make check   # reroll code path (#240)
        - make -C tests/bench

    - name: ARM compilation and consistency checks (Qemu)
      dist: xenial
      arch: amd64
      addons:
        apt:
          packages:
            - qemu-system-arm
            - qemu-user-static
            - gcc-arm-linux-gnueabi
            - libc6-dev-armel-cross
      script:
        # arm (32-bit)
        - CC=arm-linux-gnueabi-gcc CPPFLAGS=-DXXH_VECTOR=0 LDFLAGS=-static RUN_ENV=qemu-arm-static make check   # Scalar code path
        - make clean
        # NEON (32-bit)
        - CC=arm-linux-gnueabi-gcc CPPFLAGS=-DXXH_VECTOR=3 CFLAGS="-O3 -march=armv7-a -fPIC -mfloat-abi=softfp -mfpu=neon-vfpv4" LDFLAGS=-static RUN_ENV=qemu-arm-static make check   # NEON code path

    - name: aarch64 compilation and consistency checks
      dist: xenial
      arch: arm64
      script:
        # aarch64
        - CPPFLAGS=-DXXH_VECTOR=0 LDFLAGS=-static make check   # Scalar code path
        # NEON (64-bit)
        - make clean
        - CPPFLAGS=-DXXH_VECTOR=3 LDFLAGS=-static make check   # NEON code path

    # We need Bionic here because the QEMU versions shipped in the older repos
    # do not support POWER8 emulation, and compiling QEMU from source is a pain.
    - name: PowerPC + PPC64 compilation and consistency checks (Qemu on Bionic)
      dist: bionic
      arch: amd64
      addons:
        apt:
          packages:
            - qemu-system-ppc
            - qemu-user-static
            - gcc-powerpc-linux-gnu
            - gcc-powerpc64-linux-gnu
            - libc6-dev-powerpc-cross
            - libc6-dev-ppc64-cross
      script:
        - CC=powerpc-linux-gnu-gcc RUN_ENV=qemu-ppc-static LDFLAGS=-static make check   # Scalar code path
        - make clean
        - CC=powerpc64-linux-gnu-gcc RUN_ENV=qemu-ppc64-static CPPFLAGS=-DXXH_VECTOR=0 CFLAGS="-O3" LDFLAGS="-static -m64" make check   # Scalar code path
        - make clean
        # VSX code
        - CC=powerpc64-linux-gnu-gcc RUN_ENV="qemu-ppc64-static -cpu power8" CFLAGS="-O3 -maltivec -mvsx -mcpu=power8 -mpower8-vector" LDFLAGS="-static -m64" make check   # Auto code path
        - make clean

    - name: PPC64LE compilation and consistency checks
      dist: xenial
      arch: ppc64le
      script:
        # Scalar (universal) code path
        - CPPFLAGS=-DXXH_VECTOR=0 LDFLAGS=-static make check
        # VSX code path (64-bit)
        - make clean
        - CPPFLAGS=-DXXH_VECTOR=4 CFLAGS="-O3 -maltivec -mvsx -mpower8-vector -mcpu=power8" LDFLAGS="-static" make check

    - name: IBM s390x compilation and consistency checks
      dist: bionic
      arch: s390x
      script:
        # Scalar (universal) code path
        - CPPFLAGS=-DXXH_VECTOR=0 LDFLAGS=-static make check
        # s390x code path (64-bit)
        - make clean
        - CPPFLAGS=-DXXH_VECTOR=4 CFLAGS="-O3 -march=arch11 -mzvector" LDFLAGS="-static" make check

    - name: cmake build test
      script:
        - cd cmake_unofficial
        - mkdir build
        - cd build
        - cmake ..
        - make

