name: Ubuntu Cross to Win64

on:
    push:
        paths:
            - "**.c"
            - "**.cpp"
            - "**.h"
            - "**.hpp"
            - ".gitea/workflows/ci_meson.yaml"
    pull_request:
        paths:
            - "**.c"
            - "**.cpp"
            - "**.h"
            - "**.hpp"

jobs:
    cross_compile:
        name: Cross Compile with ming64
        runs-on: ${{ matrix.os }}
        strategy:
            matrix:
                os: [ubuntu-latest]
                meson_version: ["1.4.0"]
        steps:
            - name: Checkout Code
              uses: https://gitea.com/ScMi1/checkout@v1
            - name: Install APT Dependencies
              run: |
                apt update -y
                apt install -y python3-pip cmake clang build-essential libwayland-dev libxkbcommon-dev xorg-dev mingw-w64 mingw-w64-common wine-stable
            - name: Install PIP Dependencies
              run: python -m pip install meson==${{ matrix.meson_version }} ninja
            - name: Configure Project
              run: |
                chmod +x ./scripts/download_dxc_cross.sh
                ./scripts/download_dxc_cross.sh
                meson setup --cross-file scripts/x86_64-w64-mingw32.txt -Db_sanitize=none build
                cd build && meson devenv && cd ..
            - name: Compile
              run: meson compile -C build
            - name: Run Tests
              run: meson test -C build/ -v
            - name: Upload Test Log
              uses: actions/upload-artifact@v4
              if: failure()
              with:
                name: ${{ matrix.os }}_Meson_Testlog
                path: build/meson-logs/testlog.txt
    compile_linux:
        name: Compile for linux
        runs-on: ${{ matrix.os }}
        strategy:
            matrix:
                os: [ ubuntu-latest ]
                meson_version: [ "1.4.0" ]
        steps:
            -   name: Checkout Code
                uses: https://gitea.com/ScMi1/checkout@v1
            -   name: Install APT Dependencies
                run: |
                    wget -qO- https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo tee /etc/apt/trusted.gpg.d/lunarg.asc
                    wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list http://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list
                    apt update -y
                    apt install -y python3-pip cmake clang build-essential libwayland-dev libxkbcommon-dev xorg-dev vulkan-sdk
            -   name: Install PIP Dependencies
                run: python -m pip install meson==${{ matrix.meson_version }} ninja
            -   name: Configure Project
                run: |
                    chmod +x ./scripts/download_dxc.sh
                    ./scripts/download_dxc.sh
                    meson setup -Dbuild_dx11=false -Dbuild_vk=true -Dstatic_renderer=vk -Denable_dx11_shader_compiler=false -Db_sanitize=none build
                    cd build && meson devenv && cd ..
            -   name: Compile
                run: meson compile -C build
            -   name: Run Tests
                run: meson test -C build/ -v
            -   name: Upload Test Log
                uses: actions/upload-artifact@v4
                if: failure()
                with:
                    name: ${{ matrix.os }}_Meson_Testlog
                    path: build/meson-logs/testlog.txt