name: Linux

on: [push, pull_request]

jobs:
  Linux:
    runs-on: ubuntu-22.04
    steps:
    - name: Checkout repository
      uses: actions/checkout@v3
      with:
        fetch-depth: 2
    - name: Checkout submodules
      run: |
        git submodule update --init --recursive
    - name: Install dependencies
      run: |
        sudo add-apt-repository universe
        sudo add-apt-repository multiverse
        sudo apt update
        sudo apt install gcc-12 g++-12 wget libsdl2-2.0-0 libsdl2-dev
        sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 10
        sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 10
        sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
        sudo update-alternatives --set cc /usr/bin/gcc
        sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
        sudo update-alternatives --set c++ /usr/bin/g++
        sudo update-alternatives --config gcc
        sudo update-alternatives --config g++
        wget https://github.com/premake/premake-core/releases/download/v5.0.0-beta1/premake-5.0.0-beta1-linux.tar.gz
        tar xvzf premake-5.0.0-beta1-linux.tar.gz
    - name: Build
      run: |
        ./premake5 --with-mojoal gmake2
        cd make/linux
        make all -j$(nproc)
