From f6677bde9f3f63c9a8dc1c8fdeb0e56aec0b3b43 Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Wed, 15 May 2024 17:29:10 +0200 Subject: [PATCH 1/8] Create build.sh --- build.sh | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 build.sh diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..c402cdb --- /dev/null +++ b/build.sh @@ -0,0 +1,98 @@ +#!/bin/bash + +# Check if environment variables are defined +if [[ -z $NAME || -z $RUNNER_OS || -z $FLAGS ]]; then + echo "One or more required environment variables are not defined." + exit 1 +fi + +SUDO=$(which sudo) + +if [[ $RUNNER_OS == 'Linux' ]]; then +# Setup Linux dependencies + if [[ $TARGET_APT_ARCH == :i386 ]]; then + $SUDO dpkg --add-architecture i386 + fi + + $SUDO apt-get update -y -qq + + if [[ $TARGET_APT_ARCH == :i386 ]]; then + # Workaround GitHub's ubuntu-20.04 image issue + $SUDO apt-get install -y --allow-downgrades libpcre2-8-0=10.34-7 + fi + + if [[ $NAME != 'linux-x86' && $NAME != 'linux-x64' ]]; then + GCC="gcc" + GPP="g++" + else + GCC="gcc-multilib" + GPP="g++-multilib" + fi + + $SUDO apt-get install -y \ + $GCC \ + $GPP \ + cmake \ + ninja-build \ + wayland-scanner++ \ + wayland-protocols \ + pkg-config$TARGET_APT_ARCH \ + libasound2-dev$TARGET_APT_ARCH \ + libdbus-1-dev$TARGET_APT_ARCH \ + libegl1-mesa-dev$TARGET_APT_ARCH \ + libgl1-mesa-dev$TARGET_APT_ARCH \ + libgles2-mesa-dev$TARGET_APT_ARCH \ + libglu1-mesa-dev$TARGET_APT_ARCH \ + libibus-1.0-dev$TARGET_APT_ARCH \ + libpulse-dev$TARGET_APT_ARCH \ + libsndio-dev$TARGET_APT_ARCH \ + libudev-dev$TARGET_APT_ARCH \ + libwayland-dev$TARGET_APT_ARCH \ + libx11-dev$TARGET_APT_ARCH \ + libxcursor-dev$TARGET_APT_ARCH \ + libxext-dev$TARGET_APT_ARCH \ + libxi-dev$TARGET_APT_ARCH \ + libxinerama-dev$TARGET_APT_ARCH \ + libxkbcommon-dev$TARGET_APT_ARCH \ + libxrandr-dev$TARGET_APT_ARCH \ + libxss-dev$TARGET_APT_ARCH \ + libxt-dev$TARGET_APT_ARCH \ + libxv-dev$TARGET_APT_ARCH \ + libxxf86vm-dev$TARGET_APT_ARCH \ + libdrm-dev$TARGET_APT_ARCH \ + libgbm-dev$TARGET_APT_ARCH \ + libpulse-dev$TARGET_APT_ARCH +fi + +# Configure CMake +if [[ $NAME == 'linux-x86' ]]; then + FLAGS="$FLAGS -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32" +elif [[ $NAME == 'linux-x64' ]]; then + FLAGS="$FLAGS -DCMAKE_C_FLAGS=-m64 -DCMAKE_CXX_FLAGS=-m64" +fi + +cmake -B build $FLAGS -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DSDL_SHARED_ENABLED_BY_DEFAULT=ON -DSDL_STATIC_ENABLED_BY_DEFAULT=ON + +# Build +cmake --build build/ --config Release + +if [[ $RUNNER_OS == 'Windows' ]]; then + # Install (Windows) + cmake --install build/ --prefix install_output --config Release +else + # Install + $SUDO cmake --install build/ --prefix install_output --config Release +fi + +mkdir -p SDL3-CS/native/$NAME + +if [[ $RUNNER_OS == 'Windows' ]]; then + # Prepare release (Windows) + cp install_output/bin/SDL3.dll SDL3-CS/native/$NAME/SDL3.dll +elif [[ $RUNNER_OS == 'Linux' ]]; then + # Prepare release (Linux) + cp install_output/lib/libSDL3.so SDL3-CS/native/$NAME/libSDL3.so +elif [[ $RUNNER_OS == 'macOS' ]]; then + # Prepare release (macOS) + cp install_output/lib/libSDL3.dylib SDL3-CS/native/$NAME/libSDL3.dylib +fi From 2dd2ef0ef6a7a141ba43373fe94326670e43edf8 Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Wed, 15 May 2024 17:29:36 +0200 Subject: [PATCH 2/8] Update build.yml --- .github/workflows/build.yml | 122 +++++++++++------------------------- 1 file changed, 36 insertions(+), 86 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index afc9ab8..2e4e9f8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,63 +15,17 @@ 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="10.14" } + - { 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, target_apt_arch: ":i386" } + - { name: linux-arm64, os: ubuntu-20.04, flags: -GNinja, target_apt_arch: ":arm64", container: arm64v8/ubuntu } + - { name: linux-arm, os: ubuntu-20.04, flags: -GNinja, target_apt_arch: ":armhf", container: arm32v7/ubuntu } + - { name: osx-x64, os: macos-latest, flags: -DCMAKE_OSX_ARCHITECTURES="x86_64" -DCMAKE_OSX_DEPLOYMENT_TARGET="10.14" } # NOTE: macOS 11.0 is the first released supported by Apple Silicon. - - { name: osx-arm64, os: macos-latest, flags: -DCMAKE_OSX_ARCHITECTURES="arm64" -DCMAKE_OSX_DEPLOYMENT_TARGET="11.0" } + - { name: osx-arm64, os: macos-latest, flags: -DCMAKE_OSX_ARCHITECTURES="arm64" -DCMAKE_OSX_DEPLOYMENT_TARGET="11.0" } 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 - 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 }} \ - 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 }} - - uses: actions/checkout@v4 with: repository: 'libsdl-org/SDL' @@ -81,39 +35,35 @@ jobs: with: path: 'SDL3-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: Set up QEMU + if: contains(matrix.platform.container, 'arm') + uses: docker/setup-qemu-action@v3 + + - name: Build (Linux ARM) + if: contains(matrix.platform.container, 'arm') + uses: addnab/docker-run-action@v3 + with: + image: ${{ matrix.platform.container }} + options: > + -v ${{ github.workspace }}:/workspace + -e NAME=${{ matrix.platform.name }} + -e TARGET_APT_ARCH=${{ matrix.platform.target_apt_arch }} + -e RUNNER_OS=${{ runner.os }} + -e FLAGS=${{ matrix.platform.flags }} + -e BUILD_TYPE=${{ env.BUILD_TYPE }} + run: | + cd /workspace + ./SDL3-CS/build.sh - 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 SDL3-CS/native/${{ matrix.platform.name }} - if: runner.os == 'Windows' - - - name: Prepare release directory - run: mkdir -p SDL3-CS/native/${{ matrix.platform.name }} - if: runner.os != 'Windows' - - - name: Prepare release (Windows) - run: cp install_output/bin/SDL3.dll SDL3-CS/native/${{ matrix.platform.name }}/SDL3.dll - if: runner.os == 'Windows' - - - name: Prepare release (Linux) - run: cp install_output/lib/libSDL3.so SDL3-CS/native/${{ matrix.platform.name }}/libSDL3.so - if: runner.os == 'Linux' - - - name: Prepare release (macOS) - run: cp install_output/lib/libSDL3.dylib SDL3-CS/native/${{ matrix.platform.name }}/libSDL3.dylib - if: runner.os == 'macOS' + if: ${{ !contains(matrix.platform.container, 'arm') }} + shell: bash + env: + NAME: ${{ matrix.platform.name }} + TARGET_APT_ARCH: ${{ matrix.platform.target_apt_arch }} + RUNNER_OS: ${{ runner.os }} + FLAGS: ${{ matrix.platform.flags }} + run: ./SDL3-CS/build.sh - name: Create pull request uses: peter-evans/create-pull-request@v6 From 515cd199e3fe01b222caaaeca973f359586a0492 Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Wed, 15 May 2024 19:32:52 +0000 Subject: [PATCH 3/8] make build.sh executable --- build.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 build.sh diff --git a/build.sh b/build.sh old mode 100644 new mode 100755 From a7cbefc5e65e8613d717d32405bcc7983e5c421d Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Wed, 15 May 2024 19:43:25 +0000 Subject: [PATCH 4/8] move cmake flags to os matrix --- .github/workflows/build.yml | 2 +- build.sh | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2e4e9f8..b9c56b5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,7 @@ jobs: - { 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, target_apt_arch: ":i386" } + - { name: linux-x86, os: ubuntu-20.04, flags: -GNinja -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32", target_apt_arch: ":i386" } - { name: linux-arm64, os: ubuntu-20.04, flags: -GNinja, target_apt_arch: ":arm64", container: arm64v8/ubuntu } - { name: linux-arm, os: ubuntu-20.04, flags: -GNinja, target_apt_arch: ":armhf", container: arm32v7/ubuntu } - { name: osx-x64, os: macos-latest, flags: -DCMAKE_OSX_ARCHITECTURES="x86_64" -DCMAKE_OSX_DEPLOYMENT_TARGET="10.14" } diff --git a/build.sh b/build.sh index c402cdb..6931358 100755 --- a/build.sh +++ b/build.sh @@ -64,13 +64,6 @@ if [[ $RUNNER_OS == 'Linux' ]]; then libpulse-dev$TARGET_APT_ARCH fi -# Configure CMake -if [[ $NAME == 'linux-x86' ]]; then - FLAGS="$FLAGS -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32" -elif [[ $NAME == 'linux-x64' ]]; then - FLAGS="$FLAGS -DCMAKE_C_FLAGS=-m64 -DCMAKE_CXX_FLAGS=-m64" -fi - cmake -B build $FLAGS -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DSDL_SHARED_ENABLED_BY_DEFAULT=ON -DSDL_STATIC_ENABLED_BY_DEFAULT=ON # Build From 079440d0a08a32c39b48f7f6cd24ffe228cdfdf4 Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Wed, 15 May 2024 19:48:10 +0000 Subject: [PATCH 5/8] fix workspace ownership --- .github/workflows/build.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b9c56b5..fc0db9b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -64,6 +64,15 @@ jobs: RUNNER_OS: ${{ runner.os }} FLAGS: ${{ matrix.platform.flags }} run: ./SDL3-CS/build.sh + + - name: Get Actions user id + id: get_uid + run: echo "uid=$(id -u $USER)" >> $GITHUB_OUTPUT + + - name: Correct Ownership in GITHUB_WORKSPACE directory + uses: peter-murray/reset-workspace-ownership-action@v1 + with: + user_id: ${{ steps.get_uid.outputs.uid }} - name: Create pull request uses: peter-evans/create-pull-request@v6 From 89af77f5a21f5e48254c2da838e0b805be7ec1e4 Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Wed, 15 May 2024 20:14:07 +0000 Subject: [PATCH 6/8] run ownership action on linux --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fc0db9b..8f30cbd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -66,10 +66,12 @@ jobs: run: ./SDL3-CS/build.sh - name: Get Actions user id + if: ${{ runner.os }} == 'Linux' id: get_uid run: echo "uid=$(id -u $USER)" >> $GITHUB_OUTPUT - name: Correct Ownership in GITHUB_WORKSPACE directory + if: ${{ runner.os }} == 'Linux' uses: peter-murray/reset-workspace-ownership-action@v1 with: user_id: ${{ steps.get_uid.outputs.uid }} From 453df16b5e08c1826d9d43d46755e86891f27774 Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Fri, 17 May 2024 21:33:53 +0000 Subject: [PATCH 7/8] remove quotes --- .github/workflows/build.yml | 4 ++-- build.sh | 9 ++------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8f30cbd..86cb035 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,9 +22,9 @@ jobs: - { name: linux-x86, os: ubuntu-20.04, flags: -GNinja -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32", target_apt_arch: ":i386" } - { name: linux-arm64, os: ubuntu-20.04, flags: -GNinja, target_apt_arch: ":arm64", container: arm64v8/ubuntu } - { name: linux-arm, os: ubuntu-20.04, flags: -GNinja, target_apt_arch: ":armhf", container: arm32v7/ubuntu } - - { name: osx-x64, os: macos-latest, flags: -DCMAKE_OSX_ARCHITECTURES="x86_64" -DCMAKE_OSX_DEPLOYMENT_TARGET="10.14" } + - { name: osx-x64, os: macos-latest, flags: -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_OSX_DEPLOYMENT_TARGET=10.14 } # NOTE: macOS 11.0 is the first released supported by Apple Silicon. - - { name: osx-arm64, os: macos-latest, flags: -DCMAKE_OSX_ARCHITECTURES="arm64" -DCMAKE_OSX_DEPLOYMENT_TARGET="11.0" } + - { name: osx-arm64, os: macos-latest, flags: -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 } steps: - uses: actions/checkout@v4 with: diff --git a/build.sh b/build.sh index 6931358..0e6e0cd 100755 --- a/build.sh +++ b/build.sh @@ -69,13 +69,8 @@ cmake -B build $FLAGS -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DSDL_SHARED_ENABLED_BY_DEF # Build cmake --build build/ --config Release -if [[ $RUNNER_OS == 'Windows' ]]; then - # Install (Windows) - cmake --install build/ --prefix install_output --config Release -else - # Install - $SUDO cmake --install build/ --prefix install_output --config Release -fi +# Install +$SUDO cmake --install build/ --prefix install_output --config Release mkdir -p SDL3-CS/native/$NAME From 05714f965791e8ba37da41e0ca1d67017a648236 Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Fri, 17 May 2024 21:39:39 +0000 Subject: [PATCH 8/8] remove expression from conditions --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 86cb035..43e1fbd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -66,12 +66,12 @@ jobs: run: ./SDL3-CS/build.sh - name: Get Actions user id - if: ${{ runner.os }} == 'Linux' + if: runner.os == 'Linux' id: get_uid run: echo "uid=$(id -u $USER)" >> $GITHUB_OUTPUT - name: Correct Ownership in GITHUB_WORKSPACE directory - if: ${{ runner.os }} == 'Linux' + if: runner.os == 'Linux' uses: peter-murray/reset-workspace-ownership-action@v1 with: user_id: ${{ steps.get_uid.outputs.uid }}