pool:
  vmImage: 'ubuntu-latest'

trigger:
  branches:
    exclude:
    - master
    # - ci/*
    # include:
    # - ci/azure*

jobs:
- job: clang_analysis
  variables:
    CC: clang-10
    CXX: clang++-10
    # CFLAGS: -Weverything -Werror
    # CXXFLAGS: -Weverything -Werror
  steps:
  - script: uname -a && cat /proc/cpuinfo /proc/meminfo
    displayName: System Information
  - script: sudo add-apt-repository 'ppa:ubuntu-toolchain-r/test' && sudo apt-get update && sudo apt-get install -y ninja-build ninja-build python3-pip python3-setuptools python3-wheel clang-10 clang-tools-10
    displayName: Install APT Dependencies
  - script: pip3 install -v meson
    displayName: Install pip Dependencies
  - script: scan-build-10 /home/vsts/.local/bin/meson setup build -Db_sanitize=address,undefined
    displayName: Configure
  - script: scan-build-10 ninja -C build -v
    displayName: Build
  - script: ninja -C build -v test
    displayName: Test

- job: gcc_analysis
  variables:
    CC: gcc-10
    CXX: g++-10
    CFLAGS: -fanalyzer -Wextra -Werror
    CXXFLAGS: -fanalyzer -Wextra -Werror
  steps:
  - script: uname -a && cat /proc/cpuinfo /proc/meminfo
    displayName: System Information
  - script: sudo add-apt-repository 'ppa:ubuntu-toolchain-r/test' && sudo apt-get update && sudo apt-get install -y ninja-build ninja-build python3-pip python3-setuptools python3-wheel gcc-10 g++-10
    displayName: Install APT Dependencies
  - script: pip3 install meson
    displayName: Install pip Dependencies
  - script: /home/vsts/.local/bin/meson setup build -Db_sanitize=address,undefined
    displayName: Configure
  - script: ninja -C build -v
    displayName: Build
  - script: ninja -C build -v test
    displayName: Test

# - job: loongson3a
#   container:
#     image: debian:unstable
#     options: "--name ci-container -v /usr/bin/docker:/tmp/docker:ro"
#   steps:
#   # https://github.com/Microsoft/azure-pipelines-agent/issues/2043
#   - script: /tmp/docker exec -t -u 0 ci-container sh -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confold" -y install sudo"
#     displayName: 'Install Sudo in container'
#   - script: uname -a && cat /proc/cpuinfo /proc/meminfo
#     displayName: System Information
#   - script: sudo dpkg --add-architecture mips64el && sudo apt-get update && sudo apt-get install -y ninja-build ninja-build python3-pip python3-setuptools python3-wheel libc6:mips64el gcc-10-mips64el-linux-gnuabi64 g++-10-mips64el-linux-gnuabi64 qemu-user-static
#     displayName: Install APT Dependencies
#   - script: pip3 install meson
#     displayName: Install pip Dependencies
#   - script: /home/vsts/.local/bin/meson setup build --cross-file=docker/cross-files/loongson-gcc-10.cross
#     displayName: Configure
#   - script: ninja -C build -v
#     displayName: Build
#   - script: ninja -C build -v test
#     displayName: Test
