name: Build FreeDV (Windows)

on:
  push:
    branches-ignore:
    - 'dr-render-manual'
    
env:
  # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
  BUILD_TYPE: Debug

jobs:
  build:
    # The CMake configure and build commands are platform agnostic and should work equally
    # well on Windows or Mac.  You can convert this to a matrix build if you need
    # cross-platform coverage.
    # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    - name: Install required packages
      shell: bash
      working-directory: ${{github.workspace}}
      run: sudo apt-get install nsis

    - name: Download MinGW LLVM
      shell: bash
      working-directory: ${{github.workspace}}
      run: |
        wget https://github.com/mstorsjo/llvm-mingw/releases/download/20230320/llvm-mingw-20230320-ucrt-ubuntu-18.04-x86_64.tar.xz 
        tar xvf llvm-mingw-20230320-ucrt-ubuntu-18.04-x86_64.tar.xz

    - name: Configure freedv-gui
      shell: bash
      working-directory: ${{github.workspace}}
      run: |
        export PATH=${{github.workspace}}/llvm-mingw-20230320-ucrt-ubuntu-18.04-x86_64/bin:$PATH
        mkdir build_windows
        cd build_windows
        cmake -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/cross-compile/freedv-mingw-llvm-x86_64.cmake ..

    - name: Build freedv-gui
      shell: bash
      working-directory: ${{github.workspace}}/build_windows
      run: |
        export PATH=${{github.workspace}}/llvm-mingw-20230320-ucrt-ubuntu-18.04-x86_64/bin:$PATH
        make -j6 package
