# -*- mode: yaml -*-

jobs:
- job: linux
  pool:
    vmImage: ubuntu-16.04
  container:
      image: pdal/ubuntubase:latest
      options: --privileged
  timeoutInMinutes: 60
  steps:
  - script: |
      echo "Current directory:" `pwd`
      . /opt/conda/etc/profile.d/conda.sh
      conda activate pdal
      mkdir build
      cd build
      CC=gcc-6 CXX=g++-6 \
        cmake .. \
        -G Ninja \
        -DCMAKE_BUILD_TYPE=Debug \
        -DBUILD_PLUGIN_CPD=ON \
        -DCMAKE_INSTALL_PREFIX=`pwd`/../install \
        -DBUILD_PLUGIN_I3S=ON \
        -DBUILD_PLUGIN_NITF=ON \
        -DBUILD_PLUGIN_TILEDB=ON \
        -DBUILD_PLUGIN_ICEBRIDGE=ON \
        -DBUILD_PLUGIN_HDF=ON \
        -DBUILD_PLUGIN_PGPOINTCLOUD=ON \
        -DBUILD_PLUGIN_E57=ON \
        -DBUILD_PGPOINTCLOUD_TESTS=OFF \
        -DWITH_LAZPERF=ON \
        -DWITH_LASZIP=ON \
        -DWITH_ZSTD=ON \
        -DWITH_ZLIB=ON \
        -DWITH_TESTS=ON
    displayName: 'CMake'
  - script: |
      . /opt/conda/etc/profile.d/conda.sh
      conda activate pdal
      cd build
      ninja
    displayName: 'Build'
  - script: |
      . /opt/conda/etc/profile.d/conda.sh
      conda activate pdal
      cd build
      ctest -V
    displayName: 'Test'
  - script: |
      . /opt/conda/etc/profile.d/conda.sh
      conda activate pdal
      export PDAL_TEST_DIR=`pwd`/test
      export INSTALL_DIR=`pwd`/install
      export PATH=$PATH:$INSTALL_DIR/bin
      cd build
      ls build/lib/*
      ninja install
  - script: |
      . /opt/conda/etc/profile.d/conda.sh
      conda activate pdal
      export BASE=`pwd`
      for EXAMPLE in writing writing-filter writing-kernel \
          writing-reader writing-writer
      do
          cd $BASE/examples/$EXAMPLE
          mkdir -p _build || exit 1
          cd _build || exit 1
          cmake -G "Ninja" .. -DPDAL_DIR=$BASE/install/lib/cmake/PDAL && ninja
      done
    displayName: 'Examples'

