 matrix:
  include:
    # Test build for Linux platform
    - language: cpp
      dist: focal
      os: linux
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-7
            - python3.8
      env:
        - MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"
      cache:
        directories:
      git:
        depth: false
        quiet: true

      before_install:
        - eval "${MATRIX_EVAL}"

      install:
      
      script:
        - mkdir -p build
        - cd build
        - cmake ..
        - cmake --build .

    # Test build for CC13x0 platform
    - language: cpp
      dist: focal
      os: linux
      addons:
        apt:
          sources:
          packages:
            - cmake
            - binutils-arm-none-eabi
            - gcc-arm-none-eabi
            - libnewlib-arm-none-eabi
            - libstdc++-arm-none-eabi-newlib
      env:
        - MATRIX_EVAL="CC=arm-none-eabi-gcc && CXX=arm-none-eabi-g++"
      cache:
        directories:
      git:
        depth: false
        quiet: true

      before_install:
        - eval "${MATRIX_EVAL}"

      install:

      before_script:
        - arm-none-eabi-gcc --version

      script:
        - echo "building knx-cc1310"
        - cd examples/knx-cc1310
        - mkdir -p build
        - cd build
        - cmake -DCMAKE_BUILD_TYPE=Debug ..
        - cmake --build .

    # Test build for PlatformIO based projects
    - language: python
      python:
        - "3.8"
      cache:
        directories:
          - "~/.platformio"
      env:
        - PLATFORMIO_EXTRA_SCRIPTS=pre:/tmp/scripts/custom_hwids.py
      install:
        - pip install -U platformio
        - platformio update      
      script:
        # PRE scripts have to be copied manually as "platformio ci does not care about it"
        - mkdir -p /tmp/scripts
        - cp examples/knx-usb/custom_hwids.py /tmp/scripts

        # Enable verbose output of platformio
        #- platformio settings set force_verbose yes

        - echo "-------";echo "Compiling example knx-usb";echo "--------";
        - platformio ci --lib="." --project-conf=examples/knx-usb/platformio-ci.ini examples/knx-usb/src/main.cpp

        - echo "-------";echo "Compiling example knx-demo";echo "--------";
        - platformio ci --lib="." --project-conf=examples/knx-demo/platformio-ci.ini examples/knx-demo/knx-demo.ino

        - echo "-------";echo "Compiling example knx-demo-coupler";echo "--------";
        - platformio ci --lib="." --project-conf=examples/knx-demo-coupler/platformio-ci.ini examples/knx-demo-coupler/knx-demo-coupler.ino

notifications:
  email:
    on_success: change
    on_failure: change
