From 2402c1a0dbc90787cbd4e7e9547290b6b6ebff23 Mon Sep 17 00:00:00 2001 From: Mary Guillemard Date: Tue, 6 Feb 2024 20:44:23 +0100 Subject: [PATCH] Enable linux-arm64 in CI Signed-off-by: Mary Guillemard --- .github/workflows/build.yml | 20 ++++++++++-------- ci/{build.sh => compile.sh} | 2 ++ ci/run.sh | 41 +++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 8 deletions(-) rename ci/{build.sh => compile.sh} (99%) create mode 100755 ci/run.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ba631cc..1d7c167 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,14 +18,18 @@ jobs: fail-fast: false matrix: platform: - - { name: win-x64, os: windows-latest, arch: x64 } - - { name: win-x86, os: windows-latest, arch: Win32 } - - { name: win-arm64, os: windows-latest, arch: ARM64 } - - { name: linux-x64, os: ubuntu-20.04, arch: amd64 } - - { name: linux-x86, os: ubuntu-20.04, arch: i386 } - - { name: osx-x64, os: macos-latest, arch: x86_64} - - { name: osx-arm64, os: macos-latest, arch: arm64 } + - { name: win-x64, os: windows-latest, arch: x64 } + # - { name: win-x86, os: windows-latest, arch: Win32 } + - { name: win-arm64, os: windows-latest, arch: ARM64 } + - { name: linux-x64, os: ubuntu-20.04, arch: amd64 } + # - { name: linux-x86, os: ubuntu-20.04, arch: i386 } + - { name: linux-arm64, os: ubuntu-20.04, arch: arm64 } + - { name: osx-x64, os: macos-latest, arch: x86_64 } + - { name: osx-arm64, os: macos-latest, arch: arm64 } steps: + - name: Setup qemu static + uses: docker/setup-qemu-action@v3 + if: runner.os == 'Linux' - uses: actions/checkout@v4 with: repository: Ryujinx/SDL @@ -34,7 +38,7 @@ jobs: with: path: 'SDL2-CS' - name: Build and prepare release - run: SDL2-CS/ci/build.sh $PWD SDL2-CS/native/${{ matrix.platform.name }} ${{ matrix.platform.arch }} + run: SDL2-CS/ci/run.sh $PWD $PWD/SDL2-CS/native/${{ matrix.platform.name }} ${{ matrix.platform.arch }} shell: bash - name: Upload artifacts uses: actions/upload-artifact@v3 diff --git a/ci/build.sh b/ci/compile.sh similarity index 99% rename from ci/build.sh rename to ci/compile.sh index d62b281..518baee 100755 --- a/ci/build.sh +++ b/ci/compile.sh @@ -97,6 +97,8 @@ cmake -B build -DCMAKE_BUILD_TYPE=Release -DSDL_SHARED_ENABLED_BY_DEFAULT=ON -DS cmake --build build/ --config Release $SUDO cmake --install build/ --prefix install_output --config Release +mkdir -p $output_path + if [[ $system_name == "linux" ]]; then cp install_output/lib/libSDL2-2.0.so.0 $output_path/libSDL2.so elif [[ $system_name == "macos" ]]; then diff --git a/ci/run.sh b/ci/run.sh new file mode 100755 index 0000000..68725a4 --- /dev/null +++ b/ci/run.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +set -e + +if [ "$#" -le 2 ]; then + echo "usage: " + exit 1 +fi + +uname_system="$(uname -s)" + +case "${uname_system}" in + Linux*) system_name=linux;; + Darwin*) system_name=macos;; + CYGWIN*) system_name=win;; + MINGW*) system_name=win;; + *) system_name="Unknown OS: ${uname_system}" +esac + +sdl_dir=$1 +output_path=$2 +build_arch=$3 + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +mkdir -p $output_path + +if [ $system_name == "linux" ] && [ $build_arch == "arm64" ]; then + if command -v podman &> /dev/null; then + DOCKER=podman + elif command -v docker &> /dev/null; then + DOCKER=docker + else + echo "ERROR - Missing docker/podman env, cannot crossbuild" + exit 1 + fi + + $DOCKER run --rm -v $SCRIPT_DIR:/scripts -v $output_path:/output -v $sdl_dir:/source -t arm64v8/ubuntu:focal bash /scripts/compile.sh /source /output $build_arch +else + $SCRIPT_DIR/compile.sh "$sdl_dir" "$output_path" "$build_arch" +fi \ No newline at end of file