name: C/C++ CI

on:

  push:
    paths:
    - src/**
    - .github/workflows/**

  pull_request:
    paths:
    - src/**
    - .github/workflows/**

jobs:
  build:
    name: Build (DEV_BUILD=${{ matrix.dev-build }}, NEW_DYNAREC=${{ matrix.new-dynarec }}, X64=${{ matrix.target-arch.x64 }})

    runs-on: windows-latest

    defaults:
      run:
        shell: msys2 {0}

    strategy:
      matrix:
        dev-build: ['y', 'n']
        new-dynarec: ['y', 'n']
        target-arch:
          - x64: 'n'
            msystem: MINGW32
            prefix: mingw-w64-i686
          - x64: 'y'
            msystem: MINGW64
            prefix: mingw-w64-x86_64

    steps:
    - uses: msys2/setup-msys2@v2
      with:
        update: true
        msystem: ${{ matrix.target-arch.msystem }}
        install: >-
          make
          ${{ matrix.target-arch.prefix }}-toolchain
          ${{ matrix.target-arch.prefix }}-openal
          ${{ matrix.target-arch.prefix }}-freetype
          ${{ matrix.target-arch.prefix }}-SDL2
          ${{ matrix.target-arch.prefix }}-zlib
          ${{ matrix.target-arch.prefix }}-libpng
          ${{ matrix.target-arch.prefix }}-libvncserver
    - uses: actions/checkout@v2
    - name: make
      run: make -fwin/makefile.mingw -j DEV_BUILD=${{ matrix.dev-build }} NEW_DYNAREC=${{ matrix.new-dynarec }} X64=${{ matrix.target-arch.x64 }} VNC=n
      working-directory: ./src
