name: Legacy Makefile Build Environment

on: [push, pull_request]

env:
  PIPENV_ACTIVE: 1
  deb_packages: >-
    libreadline-dev
    libwxgtk3.0-gtk3-dev
    wx-common
    wx3.0-headers

jobs:
  linux:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
    steps:
    - uses: actions/checkout@v4
    - name: Fetch tags
      run: git fetch --prune --unshallow --tags
    - name: Install dependencies
      run: |
        sudo apt-get update
        sudo apt-get install -y ${{ env.deb_packages }}
    - name: Build
      run: |
        make -j
        make install
        bin/bossac --help
    - uses: actions/upload-artifact@v3
      if: always()
      with:
        name: linux
        path: bin

  macos:
    runs-on: macOS-latest
    strategy:
      fail-fast: false
    steps:
    - uses: actions/checkout@v4
    - name: Fetch tags
      run: git fetch --prune --unshallow --tags
    - name: Install dependencies
      run: |
        brew update
        brew install wxmac
    - name: Build
      run: |
        make -j
        make install
        bin/bossac --help
    - uses: actions/upload-artifact@v3
      if: always()
      with:
        name: macos
        path: bin

  # TODO: Not working currently!
  windows:
    runs-on: windows-latest
    strategy:
      fail-fast: false
      matrix:
        include:
          - { sys: mingw32, env: i686 }
    steps:
    - uses: actions/checkout@v4
    - name: Fetch tags
      run: git fetch --prune --unshallow --tags
    - uses: msys2/setup-msys2@v2
      with:
        msystem: ${{matrix.sys}}
        install: >-
          base-devel
          git
        pacboy: >-
          make
          binutils
          gcc
          wxwidgets3.2-common
          wxwidgets3.2-common-libs
          wxwidgets3.2-gtk3
          wxwidgets3.2-gtk3-libs
          wxwidgets3.2-msw
          wxwidgets3.2-msw-cb_headers
          wxwidgets3.2-msw-libs
    - name: Build
      shell: msys2 {0}
      run: |
        set MSYSTEM=MINGW32
        mingw32-make -j
        mingw32-make install
        bin/bossac --help
    - uses: actions/upload-artifact@v3
      if: always()
      with:
        name: windows
        path: bin
