SDL: ci: use Haiku cross toolchain

From 72e5a52c51b6400a2a01a12d693b237ceedf2ac8 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Thu, 4 May 2023 13:39:22 +0200
Subject: [PATCH] ci: use Haiku cross toolchain

A cross compiler is much faster then an emulated one.
---
 .github/workflows/haiku.yml | 59 +++++++++++++------------------------
 1 file changed, 21 insertions(+), 38 deletions(-)

diff --git a/.github/workflows/haiku.yml b/.github/workflows/haiku.yml
index 38d51a685cad..468d281dd427 100644
--- a/.github/workflows/haiku.yml
+++ b/.github/workflows/haiku.yml
@@ -1,37 +1,24 @@
-name: Build (Haiku @QEMU)
+name: Build (Haiku)
 
-on:
-  # push:  # Disabled ci on push because of long build times
-  # pull_request:
-  #   paths:
-  #     - '**/haiku/*'
-  #     - '.github/workflows/haiku.yml'
-  workflow_dispatch:
+on: [push, pull_request]
 
 jobs:
   haiku:
     runs-on: ubuntu-latest
     name: Haiku
-    container: docker.io/hectorm/qemu-haiku:latest
+    container: haiku/cross-compiler:x86_64-r1beta4
     steps:
-    - name: Wait until the VM is ready
-      run: |
-        container-init & timeout 600 vmshell exit 0
-    - name: Setup Haiku dependencies
-      run: |
-        vmshell pkgman install -y cmd:cmake cmd:gcc cmd:ld cmd:ninja cmd:pkg_config haiku_devel devel:libgl devel:libglu
-    - name: Restart VM
-      run: |
-        sv force-restart qemu || true
-        timeout 600 vmshell exit 0
     - uses: actions/checkout@v3
-    - name: Copy project to VM
+    - name: Setup dependencies
       run: |
-        vmshell mkdir ./src/
-        tar -cf - ./ | vmshell tar -xf - -C ./src/
+        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: |
-        vmshell cmake -S src -B build -GNinja \
+        cmake -S . -B build -GNinja \
           -Wdeprecated -Wdev -Werror \
           -DSDL_SHARED=ON \
           -DSDL_STATIC=ON \
@@ -41,32 +28,28 @@ jobs:
           -DSDL_VENDOR_INFO=Github_Workflow \
           -DCMAKE_INSTALL_PREFIX=cmake_prefix \
           -DCMAKE_BUILD_TYPE=Release \
-          -DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON \
-          -DSDL_TESTS_TIMEOUT_MULTIPLIER=10
+          -DCMAKE_SYSTEM_NAME=Haiku
     - name: Build (CMake)
       run: |
-        vmshell cmake --build ./build/ --config Release --verbose --parallel
-    - name: Run build-time tests (CMake)
-      run: |
-        vmshell ctest -VV --test-dir build/
+        cmake --build build/ --config Release --verbose --parallel
     - name: Install (CMake)
       run: |
-        vmshell cmake --install ./build/ --config Release
+        echo "SDL3_DIR=$(pwd)/cmake_prefix" >> $GITHUB_ENV
+        cmake --install build/ --config Release
     - name: Package (CPack)
       run: |
-        vmshell cmake --build build/ --config Release --target package
+        cmake --build build/ --config Release --target package
     - name: Verify CMake configuration files
       run: |
-        vmshell cmake -S ./src/cmake/test -B cmake_config_build -G Ninja \
+        cmake -S cmake/test -B cmake_config_build -G Ninja \
           -DCMAKE_BUILD_TYPE=Release \
-          -DCMAKE_PREFIX_PATH=\$PWD/cmake_prefix
-        vmshell cmake --build ./cmake_config_build --verbose
+          -DCMAKE_PREFIX_PATH=${{ env.SDL3_DIR }} \
+          -DCMAKE_SYSTEM_NAME=Haiku
+        cmake --build ./cmake_config_build --verbose
     - name: Verify sdl3.pc
       run: |
-        vmshell CC=c++ PKG_CONFIG_PATH=\$PWD/cmake_prefix/lib/pkgconfig src/cmake/test/test_pkgconfig.sh
-    - name: Copy package from VM
-      run: |
-        vmshell tar -cf - build/dist/ | tar -xf - -C ./
+        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