Move build operation to a bash script

This greatly simplify the action and prepare for building for other archs.

Signed-off-by: Mary Guillemard <mary@mary.zone>
This commit is contained in:
Mary Guillemard 2024-02-06 19:52:06 +01:00
parent 70a111cbb6
commit 275e67ad11
2 changed files with 117 additions and 83 deletions

View file

@ -18,65 +18,14 @@ jobs:
fail-fast: false
matrix:
platform:
- { name: win-x64, os: windows-latest, flags: -A x64 }
#- { name: win-x86, os: windows-latest, flags: -A Win32 }
- { name: win-arm64, os: windows-latest, flags: -A ARM64 }
- { name: linux-x64, os: ubuntu-20.04, flags: -GNinja, target_apt_arch: ":amd64" }
#- { name: linux-x86, os: ubuntu-20.04, flags: -GNinja, cmake_configure_env: CFLAGS=-m32 CXXFLAGS=-m32, target_apt_arch: ":i386" }
- { name: osx-x64, os: macos-latest, flags: -DCMAKE_OSX_ARCHITECTURES="x86_64" -DCMAKE_OSX_DEPLOYMENT_TARGET="11.0" }
- { name: osx-arm64, os: macos-latest, flags: -DCMAKE_OSX_ARCHITECTURES="arm64" -DCMAKE_OSX_DEPLOYMENT_TARGET="11.0" }
- { 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 }
steps:
- name: Setup Linux dependencies
if: runner.os == 'Linux'
run: |
if [[ ${{ matrix.platform.target_apt_arch }} == :i386 ]]; then
sudo dpkg --add-architecture i386
fi
sudo apt-get update -y -qq
if [[ ${{ matrix.platform.target_apt_arch }} == :i386 ]]; then
# Workaround GitHub's ubuntu-20.04 image issue <https://github.com/actions/virtual-environments/issues/4589>
sudo apt-get install -y --allow-downgrades libpcre2-8-0=10.34-7
fi
sudo apt-get install -y \
gcc-multilib \
g++-multilib \
cmake \
ninja-build \
wayland-scanner++ \
wayland-protocols \
pkg-config${{ matrix.platform.target_apt_arch }} \
libasound2-dev${{ matrix.platform.target_apt_arch }} \
libdbus-1-dev${{ matrix.platform.target_apt_arch }} \
libegl1-mesa-dev${{ matrix.platform.target_apt_arch }} \
libgl1-mesa-dev${{ matrix.platform.target_apt_arch }} \
libgles2-mesa-dev${{ matrix.platform.target_apt_arch }} \
libglu1-mesa-dev${{ matrix.platform.target_apt_arch }} \
libibus-1.0-dev${{ matrix.platform.target_apt_arch }} \
libpulse-dev${{ matrix.platform.target_apt_arch }} \
libsdl2-2.0-0${{ matrix.platform.target_apt_arch }} \
libsndio-dev${{ matrix.platform.target_apt_arch }} \
libudev-dev${{ matrix.platform.target_apt_arch }} \
libwayland-dev${{ matrix.platform.target_apt_arch }} \
libx11-dev${{ matrix.platform.target_apt_arch }} \
libxcursor-dev${{ matrix.platform.target_apt_arch }} \
libxext-dev${{ matrix.platform.target_apt_arch }} \
libxi-dev${{ matrix.platform.target_apt_arch }} \
libxinerama-dev${{ matrix.platform.target_apt_arch }} \
libxkbcommon-dev${{ matrix.platform.target_apt_arch }} \
libxrandr-dev${{ matrix.platform.target_apt_arch }} \
libxss-dev${{ matrix.platform.target_apt_arch }} \
libxt-dev${{ matrix.platform.target_apt_arch }} \
libxv-dev${{ matrix.platform.target_apt_arch }} \
libxxf86vm-dev${{ matrix.platform.target_apt_arch }} \
libdrm-dev${{ matrix.platform.target_apt_arch }} \
libgbm-dev${{ matrix.platform.target_apt_arch }} \
libpulse-dev${{ matrix.platform.target_apt_arch }} \
libhidapi-dev${{ matrix.platform.target_apt_arch }} \
libwayland-client++0$ \
libwayland-cursor++0$ \
- uses: actions/checkout@v4
with:
repository: Ryujinx/SDL
@ -84,31 +33,9 @@ jobs:
- uses: actions/checkout@v4
with:
path: 'SDL2-CS'
- name: Configure CMake
run: ${{ matrix.platform.cmake_configure_env }} cmake -B build ${{ matrix.platform.flags }} -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DSDL_SHARED_ENABLED_BY_DEFAULT=ON -DSDL_STATIC_ENABLED_BY_DEFAULT=ON
- name: Build
run: cmake --build build/ --config Release
- name: Install (Windows)
run: cmake --install build/ --prefix install_output --config Release
if: runner.os == 'Windows'
- name: Install
run: sudo cmake --install build/ --prefix install_output --config Release
if: runner.os != 'Windows'
- name: Prepare release directory (Windows)
run: mkdir -Force SDL2-CS/native/${{ matrix.platform.name }}
if: runner.os == 'Windows'
- name: Prepare release directory
run: mkdir -p SDL2-CS/native/${{ matrix.platform.name }}
if: runner.os != 'Windows'
- name: Prepare release (Windows)
run: cp install_output/bin/SDL2.dll SDL2-CS/native/${{ matrix.platform.name }}/SDL2.dll
if: runner.os == 'Windows'
- name: Prepare release (Linux)
run: cp install_output/lib/libSDL2-2.0.so.0 SDL2-CS/native/${{ matrix.platform.name }}/libSDL2.so
if: runner.os == 'Linux'
- name: Prepare release (macOS)
run: cp install_output/lib/libSDL2-2.0.dylib SDL2-CS/native/${{ matrix.platform.name }}/libSDL2.dylib
if: runner.os == 'macOS'
- name: Build and prepare release
run: SDL2-CS/ci/build.sh $PWD SDL2-CS/native/${{ matrix.platform.name }} ${{ matrix.platform.arch }}
shell: bash
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:

107
ci/build.sh Executable file
View file

@ -0,0 +1,107 @@
#!/bin/bash
set -e
if [ "$#" -le 1 ]; then
echo "usage: <sdl_dir> <output_path> [build_arch]"
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
export DEBIAN_FRONTEND=noninteractive
sdl_dir=$1
output_path=$2
build_arch=$3
mkdir -p $output_path
if [ -z "$3" ]; then
if [ $system_name == "linux" ]; then
build_arch=$(dpkg --print-architecture)
else
echo "ERROR - build_arch parameter needed on macOS and Windows"
exit 1
fi
fi
if command -v sudo &> /dev/null
then
SUDO=sudo
fi
if [[ $system_name == "linux" ]]; then
if [[ $build_arch == "i386" ]]; then
sudo dpkg --add-architecture i386
export CFLAGS=-m32
export CXXFLAGS=-m32
fi
$SUDO apt-get update -y
$SUDO apt-get install -y \
build-essential \
cmake \
ninja-build \
wayland-scanner++ \
wayland-protocols \
pkg-config:$build_arch \
libasound2-dev:$build_arch \
libdbus-1-dev:$build_arch \
libegl1-mesa-dev:$build_arch \
libgl1-mesa-dev:$build_arch \
libgles2-mesa-dev:$build_arch \
libglu1-mesa-dev:$build_arch \
libibus-1.0-dev:$build_arch \
libpulse-dev:$build_arch \
libsdl2-2.0-0:$build_arch \
libsndio-dev:$build_arch \
libudev-dev:$build_arch \
libwayland-dev:$build_arch \
libx11-dev:$build_arch \
libxcursor-dev:$build_arch \
libxext-dev:$build_arch \
libxi-dev:$build_arch \
libxinerama-dev:$build_arch \
libxkbcommon-dev:$build_arch \
libxrandr-dev:$build_arch \
libxss-dev:$build_arch \
libxt-dev:$build_arch \
libxv-dev:$build_arch \
libxxf86vm-dev:$build_arch \
libdrm-dev:$build_arch \
libgbm-dev:$build_arch \
libpulse-dev:$build_arch \
libhidapi-dev:$build_arch \
libwayland-client++0:$build_arch \
libwayland-cursor++0:$build_arch
extra_cmake_flags="-GNinja"
elif [[ $system_name == "macos" ]]; then
extra_cmake_flags="-DCMAKE_OSX_ARCHITECTURES=\"$build_arch\" -DCMAKE_OSX_DEPLOYMENT_TARGET=\"11.0\""
elif [[ $system_name == "win" ]]; then
extra_cmake_flags="-A $build_arch"
fi
pushd $sdl_dir
cmake -B build -DCMAKE_BUILD_TYPE=Release -DSDL_SHARED_ENABLED_BY_DEFAULT=ON -DSDL_STATIC_ENABLED_BY_DEFAULT=ON $extra_cmake_flags
cmake --build build/ --config Release
$SUDO cmake --install build/ --prefix install_output --config Release
if [[ $system_name == "linux" ]]; then
cp install_output/lib/libSDL2-2.0.so.0 $output_path/libSDL2.so
elif [[ $system_name == "macos" ]]; then
cp install_output/lib/libSDL2-2.0.dylib $output_path/libSDL2.dylib
elif [[ $system_name == "win" ]]; then
cp install_output/bin/SDL2.dll $output_path/SDL2.dll
fi
popd