parameters:
- name: uhdSrcDir
  type: string
- name: uhdBuildDir
  type: string
- name: uhdEnableTraceLog
  type: boolean
  default: false
- name: uhdAllowWarnings
  type: boolean
  default: false
- name: uhdCxxFlags
  type: string
  default: ""

steps:
- script: |
    mkdir -p ${{ parameters.uhdBuildDir }}
    cd ${{ parameters.uhdBuildDir }}
    if [[ "${{ parameters.uhdEnableTraceLog }}" = "True" ]]; then
      echo "Enabling UHD Tracing"
      export UHD_CI_CMAKE_OPTIONS="-DUHD_LOG_MIN_LEVEL=trace $UHD_CI_CMAKE_OPTIONS"
    fi
    if [[ "${{ parameters.uhdAllowWarnings }}" = "False" ]]; then
      echo "Warnings not allowed for this build."
      export CXXFLAGS="-Werror -Wno-error=maybe-uninitialized $CXXFLAGS"
    fi
    export CXXFLAGS="${{ parameters.uhdCxxFlags }} $CXXFLAGS"
    cmake \
      $UHD_CI_CMAKE_OPTIONS \
      ${{ parameters.uhdSrcDir }}/host
  displayName: cmake make UHD

- script: |
    cd ${{ parameters.uhdBuildDir }}
    make -j$(nproc) -k
  displayName: make UHD
- script: |
    cd ${{ parameters.uhdBuildDir }}
    ctest --no-compress-output --output-on-failure -T test
  continueOnError: true
  displayName: ctest make UHD