name: Build Linux

on:
  pull_request:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-18.04
    steps:
    - uses: actions/checkout@v2
      with:
        submodules: true

    - name: Install Packages
      run: |
        sudo apt-get update
        sudo apt-get install ninja-build gcc-multilib g++-multilib meson

    - name: Install TurboJPEG library
      run: sudo apt-get install libturbojpeg0-dev libjpeg8-dev

    - name: Build
      run: |
        meson . build -Dlog=true -Dloaders="svg, tvg, png, jpg" -Dsavers="tvg"
        cd build
        sudo ninja -C . install

  examples:
    runs-on: ubuntu-18.04
    steps:
    - uses: actions/checkout@v2
      with:
        submodules: true

    - name: Install Packages
      run: |
        sudo apt-get update
        sudo add-apt-repository ppa:niko2040/e19
        sudo apt-get install ninja-build gcc-multilib g++-multilib meson
        sudo apt-get install libefl-dev

    - name: Install TurboJPEG library
      run: sudo apt-get install libturbojpeg0-dev libjpeg8-dev

    - name: Build
      run: |
        meson . build -Dexamples=true -Dloaders="svg, tvg, png, jpg" -Dsavers="tvg"
        cd build
        sudo ninja -C . install

  unit_test:
    runs-on: ubuntu-18.04
    steps:
    - uses: actions/checkout@v2
      with:
        submodules: true

    - name: Install Packages
      run: |
        sudo apt-get update
        sudo apt-get install ninja-build gcc-multilib g++-multilib libgtest-dev meson cmake cmake-data

    - name: Install TurboJPEG library
      run: sudo apt-get install libturbojpeg0-dev libjpeg8-dev

    - name: Install-ThorVG
      run: |
        meson . build -Dloaders="svg, tvg, png, jpg" -Dsavers="tvg" -Dbindings="capi"
        cd build
        sudo ninja -C . install
        cd ..
        sudo rm -rf ./build

    - name: Build
      run: |
        meson . build -Dtests=true -Dloaders="svg, tvg, png, jpg" -Dsavers="tvg" -Dbindings="capi" --errorlogs
        cd build
        sudo ninja -C . install test

    - uses: actions/upload-artifact@v2
      with:
        name: UnitTestReport
        path: build/meson-logs/testlog.txt
