name: Linux build

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest

    strategy:
      fail-fast: false

      matrix:
        config-options:
          - "--soc=BCM2835 --driver=RPi"
          - "--soc=BCM2836 --driver=RPi"
          - "--soc=BCM2835 --driver=wiringPi --extra-cflags=-I/usr/local/include"
          - "--driver=SPIDEV"

    steps:
      - uses: actions/checkout@v1
      - name: provide toolchain
        run: |
          sudo apt-get update
          sudo apt-get install binutils-arm-linux-gnueabi gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
          arm-linux-gnueabihf-gcc -v
          arm-linux-gnueabihf-g++ -v
          python3 --version
      - name: provide WiringPi
        if: ${{ matrix.config-options == '--soc=BCM2835 --driver=wiringPi --extra-cflags=-I/usr/local/include' }}
        run: |
          git clone https://github.com/CoRfr/WiringPi
          cd WiringPi/wiringPi
          CC="arm-linux-gnueabihf-gcc -marm -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard" V=1 make -j5
          sudo make install
      - name: library configure
        run: ./configure ${{ matrix.config-options }}
      - name: library make
        run: make
      - name: library make install
        run: sudo make install
      - name: make linux examples
        # compiling examples for wiringPi is broken see nRF24#669 issue
        if: ${{ matrix.config-options != '--soc=BCM2835 --driver=wiringPi --extra-cflags=-I/usr/local/include' }}
        run: |
          cd examples_linux
          make
          file ./gettingstarted
