name: DeSmuME Interface (DLL/SO)

on:
  - push
  - pull_request

jobs:
  build_linux:
    runs-on: ubuntu-20.04
    name: Build Linux
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Install dependencies
        run: sudo apt update && sudo apt install meson libsdl2-dev libpcap-dev

      - name: Build - Meson
        run: |
          cd desmume/src/frontend/interface/
          meson build

      - name: Build - ninja
        run: ninja -C desmume/src/frontend/interface/build

      - name: Upload artificat
        uses: actions/upload-artifact@v2
        with:
          name: linux
          path: desmume/src/frontend/interface/build/libdesmume.so

  build_macos:
    runs-on: macos-10.15
    name: Build MacOS
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Install MacOS build deps
        run: brew install coreutils gcc sdl2 meson glib

      - name: Build - Meson
        run: |
          cd desmume/src/frontend/interface/
          meson build
        env:
          CC: clang
          CXX: clang++

      - name: Build - ninja
        run: ninja -C desmume/src/frontend/interface/build
        env:
          CC: clang
          CXX: clang++

      - name: Upload artificat
        uses: actions/upload-artifact@v2
        with:
          name: macos
          path: desmume/src/frontend/interface/build/libdesmume.dylib

  build_windows:
    runs-on: windows-2019
    name: Build Windows
    strategy:
      fail-fast: false
      matrix:
        arch: [ 'x64', 'x86' ]
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Add msbuild to PATH
        uses: microsoft/setup-msbuild@v1.0.2

      - name: Build
        run: |
          cd desmume\src\frontend\interface\windows
          MSBuild.exe DeSmuME_Interface.vcxproj /p:configuration="Release Fastbuild" /p:Platform=${{ matrix.arch }}

      - name: Upload artificat
        uses: actions/upload-artifact@v2
        with:
          name: win-${{ matrix.arch }}
          path: desmume/src/frontend/interface/windows/__bins/*.dll
