name: Build (Haiku)

on: [push, pull_request]

jobs:
  haiku:
    runs-on: ubuntu-latest
    name: Haiku
    container: haiku/cross-compiler:x86_64-r1beta4
    steps:
    - uses: actions/checkout@v3
    - name: Setup dependencies
      run: |
        apt-get install pkg-config -y
    - name: Configure Haiku environment variables
      run: |
        echo "CC=x86_64-unknown-haiku-gcc" >> $GITHUB_ENV
        echo "CXX=x86_64-unknown-haiku-g++" >> $GITHUB_ENV
    - name: Configure (CMake)
      run: |
        cmake -S . -B build -GNinja \
          -Wdeprecated -Wdev -Werror \
          -DSDL_SHARED=ON \
          -DSDL_STATIC=ON \
          -DSDL_TESTS=ON \
          -DSDL_WERROR=ON \
          -DSDL_INSTALL_TESTS=ON \
          -DSDL_VENDOR_INFO=Github_Workflow \
          -DCMAKE_INSTALL_PREFIX=cmake_prefix \
          -DCMAKE_BUILD_TYPE=Release \
          -DCMAKE_SYSTEM_NAME=Haiku
    - name: Build (CMake)
      run: |
        cmake --build build/ --config Release --verbose --parallel
    - name: Install (CMake)
      run: |
        echo "SDL3_DIR=$(pwd)/cmake_prefix" >> $GITHUB_ENV
        cmake --install build/ --config Release
    - name: Package (CPack)
      run: |
        cmake --build build/ --config Release --target package
    - name: Verify CMake configuration files
      run: |
        cmake -S cmake/test -B cmake_config_build -G Ninja \
          -DCMAKE_BUILD_TYPE=Release \
          -DCMAKE_PREFIX_PATH=${{ env.SDL3_DIR }} \
          -DCMAKE_SYSTEM_NAME=Haiku
        cmake --build ./cmake_config_build --verbose
    - name: Verify sdl3.pc
      run: |
        export PKG_CONFIG_PATH=${{ env.SDL3_DIR }}/lib/pkgconfig
        cmake/test/test_pkgconfig.sh
    - uses: actions/upload-artifact@v3
      with:
        if-no-files-found: error
        name: SDL-haiku
        path: build/dist/SDL3*
