
trigger:
  paths:
    include:
      - '*'
    exclude:
      - '.azure/azure-pipelines-android.yml'
      - '.azure/azure-pipelines-vcpkg.yml'
      - '.azure/azure-pipelines-win.yml'
      - '.circleci/config.yml'
      - '.github/workflows/linux.yml'
      - '.github/workflows/sonarcloud.yml'
      - '.cirrus.yml'
      - 'README.md'

jobs:
- job: macOS
  strategy:
    matrix:
      UnixLibs:
        imageName: 'macos-11'
        CMakeFlags: '-Denable-framework=0'
      10_15:
        imageName: 'macOS-10.15'
        CMakeFlags: ''
      11_0:
        imageName: 'macos-11'
        CMakeFlags: ''

  pool:
    vmImage: $(imageName)
# recommended by https://github.com/Homebrew/brew/issues/2491#issuecomment-294207661
#        brew update || brew update
#        brew upgrade $PACKAGES
  steps:
    - script: |
        set -ex
        PACKAGES="glib gobject-introspection libsndfile pkg-config jack dbus-glib pulseaudio portaudio sdl2 libomp"
        brew install $PACKAGES
      displayName: 'Prerequisites'
    - script: |
        set -ex
        mkdir build && cd build
        export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"
        cmake -Werror=dev $(CMakeFlags) -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=1 -DNO_GUI=1 ..
        make -j3
      displayName: 'Compile fluidsynth'
    - script: |
        set -ex
        cd build
        make -j3 check
      displayName: 'Execute Unittests'
    - script: |
        set -ex
        cd build
        make -j3 demo
      displayName: 'Compile demos'
    - script: |
        set -ex
        cd build
        sudo make install
        rm -f install_manifest.txt
      displayName: 'Install fluidsynth to default location'
    - script: |
        set -ex
        cd build
        cmake -DCMAKE_INSTALL_PREFIX=$(Build.ArtifactStagingDirectory) ..
        make install
      displayName: 'Install fluidsynth to artifact dir'
