Merge pull request #142 from smoogipoo/add-submodule

Add SDL submodule
This commit is contained in:
Dean Herbert 2024-09-20 13:21:58 +09:00 committed by GitHub
commit 75c49e289e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 58 additions and 64 deletions

View File

@ -1,12 +1,6 @@
name: Build Native
on:
workflow_dispatch:
inputs:
sdl_ref:
description: SDL3 commit/branch/tag to build
required: true
default: main
type: string
# schedule:
# - cron: '0 0 * * *'
env:
@ -23,7 +17,7 @@ jobs:
- { 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-x64, os: ubuntu-20.04, flags: -GNinja, target_apt_arch: ":amd64" }
- { 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 }
@ -33,12 +27,7 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
repository: 'libsdl-org/SDL'
ref: ${{ inputs.sdl_ref }}
- uses: actions/checkout@v4
with:
path: 'SDL3-CS'
submodules: true
- name: Set up QEMU
if: contains(matrix.platform.container, 'arm')
@ -58,7 +47,7 @@ jobs:
-e BUILD_TYPE=${{ env.BUILD_TYPE }}
run: |
cd /workspace
./SDL3-CS/build.sh
./External/build.sh
- name: Build
if: ${{ !contains(matrix.platform.container, 'arm') }}
@ -68,7 +57,7 @@ jobs:
TARGET_APT_ARCH: ${{ matrix.platform.target_apt_arch }}
RUNNER_OS: ${{ runner.os }}
FLAGS: ${{ matrix.platform.flags }}
run: ./SDL3-CS/build.sh
run: ./External/build.sh
- name: Get Actions user id
if: runner.os == 'Linux'
@ -88,7 +77,6 @@ jobs:
title: Update ${{ matrix.platform.name }} SDL binaries
body: This PR has been auto-generated to update the ${{ matrix.platform.name }} SDL binaries.
branch: update-${{ matrix.platform.name }}-binaries
path: 'SDL3-CS'
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
@ -98,28 +86,23 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
repository: 'libsdl-org/SDL'
ref: ${{ inputs.sdl_ref }}
- uses: actions/checkout@v4
with:
path: 'SDL3-CS'
submodules: true
- name: Build (iOS)
run: xcodebuild -project Xcode/SDL/SDL.xcodeproj -target SDL3.xcframework -configuration Release
run: xcodebuild -project External/SDL/Xcode/SDL/SDL.xcodeproj -target SDL3.xcframework -configuration Release
- name: Prepare release directory (iOS)
run: mkdir -p SDL3-CS/native/ios
run: mkdir -p native/ios
- name: Prepare release (iOS)
run: |
mkdir -p SDL3-CS/native/ios/SDL3.xcframework/ios-arm64/SDL3.framework;
mkdir -p SDL3-CS/native/ios/SDL3.xcframework/ios-arm64_x86_64-simulator/SDL3.framework;
cp Xcode/SDL/build/SDL3.xcframework/Info.plist SDL3-CS/native/ios/SDL3.xcframework/Info.plist;
cp Xcode/SDL/build/SDL3.xcframework/ios-arm64/SDL3.framework/SDL3 SDL3-CS/native/ios/SDL3.xcframework/ios-arm64/SDL3.framework/SDL3;
cp Xcode/SDL/build/SDL3.xcframework/ios-arm64/SDL3.framework/Info.plist SDL3-CS/native/ios/SDL3.xcframework/ios-arm64/SDL3.framework/Info.plist;
cp Xcode/SDL/build/SDL3.xcframework/ios-arm64_x86_64-simulator/SDL3.framework/SDL3 SDL3-CS/native/ios/SDL3.xcframework/ios-arm64_x86_64-simulator/SDL3.framework/SDL3;
cp Xcode/SDL/build/SDL3.xcframework/ios-arm64_x86_64-simulator/SDL3.framework/Info.plist SDL3-CS/native/ios/SDL3.xcframework/ios-arm64_x86_64-simulator/SDL3.framework/Info.plist;
mkdir -p native/ios/SDL3.xcframework/ios-arm64/SDL3.framework;
mkdir -p native/ios/SDL3.xcframework/ios-arm64_x86_64-simulator/SDL3.framework;
cp External/SDL/Xcode/SDL/build/SDL3.xcframework/Info.plist native/ios/SDL3.xcframework/Info.plist;
cp External/SDL/Xcode/SDL/build/SDL3.xcframework/ios-arm64/SDL3.framework/SDL3 native/ios/SDL3.xcframework/ios-arm64/SDL3.framework/SDL3;
cp External/SDL/Xcode/SDL/build/SDL3.xcframework/ios-arm64/SDL3.framework/Info.plist native/ios/SDL3.xcframework/ios-arm64/SDL3.framework/Info.plist;
cp External/SDL/Xcode/SDL/build/SDL3.xcframework/ios-arm64_x86_64-simulator/SDL3.framework/SDL3 native/ios/SDL3.xcframework/ios-arm64_x86_64-simulator/SDL3.framework/SDL3;
cp External/SDL/Xcode/SDL/build/SDL3.xcframework/ios-arm64_x86_64-simulator/SDL3.framework/Info.plist native/ios/SDL3.xcframework/ios-arm64_x86_64-simulator/SDL3.framework/Info.plist;
- name: Create pull request
uses: peter-evans/create-pull-request@v6
@ -128,7 +111,6 @@ jobs:
title: Update iOS SDL binaries
body: This PR has been auto-generated to update the iOS SDL binaries
branch: update-ios-binaries
path: 'SDL3-CS'
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
@ -136,17 +118,12 @@ jobs:
name: android
runs-on: ubuntu-20.04
env:
NDK_VER: 23.1.7779620
PLATFORM_VER: android-34
NDK_VER: 23.1.7779620
PLATFORM_VER: android-34
steps:
- uses: actions/checkout@v4
with:
repository: 'libsdl-org/SDL'
ref: ${{ inputs.sdl_ref }}
- uses: actions/checkout@v4
with:
path: 'SDL3-CS'
submodules: true
- name: Setup JDK
uses: actions/setup-java@v3
@ -169,22 +146,22 @@ jobs:
- name: Build (Android)
run: |
export PATH=$ANDROID_HOME/ndk/$NDK_VER:$PATH
export OUTPUT=$PWD/SDL3-CS/native/android
export OUTPUT=$PWD/native/android
rm -rf $OUTPUT && mkdir -p $OUTPUT
# Build SDL3
sed -i 's/abi=.*/abi="armeabi-v7a arm64-v8a x86 x86_64"/g' ./build-scripts/androidbuildlibs.sh
./build-scripts/androidbuildlibs.sh NDK_LIBS_OUT="$OUTPUT"
sed -i 's/abi=.*/abi="armeabi-v7a arm64-v8a x86 x86_64"/g' ./External/SDL/build-scripts/androidbuildlibs.sh
./External/SDL/build-scripts/androidbuildlibs.sh NDK_LIBS_OUT="$OUTPUT"
- name: Build SDL3 Android Java
run: |
export JAVA_HOME=$JAVA_HOME_11_X64
export PATH=$JAVA_HOME_11_X64/bin:$PATH
export OUTPUT=$PWD/SDL3-CS/SDL3-CS.Android/Jars/
export OUTPUT=$PWD/SDL3-CS.Android/Jars/
rm -rf $OUTPUT && mkdir -p $OUTPUT
# Build SDL3 Android Java part
cd android-project/app/src/main/java
cd ./External/SDL/android-project/app/src/main/java
javac -cp $ANDROID_HOME/platforms/$PLATFORM_VER/android.jar -encoding utf8 org/libsdl/app/*.java
jar cvf $OUTPUT/SDL3AndroidBridge.jar org/libsdl/app/*.class
@ -195,6 +172,5 @@ jobs:
title: Update Android SDL binaries
body: This PR has been auto-generated to update the Android SDL binaries
branch: update-android-binaries
path: 'SDL3-CS'
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "SDL"]
path = External/SDL
url = https://github.com/libsdl-org/SDL

1
External/SDL vendored Submodule

@ -0,0 +1 @@
Subproject commit 93bf53426840fd052da2aeb6d5a5a6f380f4c21a

View File

@ -1,5 +1,7 @@
#!/bin/bash
pushd "$(dirname "$0")" >/dev/null
# 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."
@ -83,24 +85,21 @@ if [[ $RUNNER_OS == 'Linux' ]]; then
fi
fi
# Build SDL
pushd SDL >/dev/null
git reset --hard HEAD
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
# Install
$SUDO cmake --install build/ --prefix install_output --config Release
popd >/dev/null
mkdir -p SDL3-CS/native/$NAME
# Move build lib into correct folders
if [[ $RUNNER_OS == 'Windows' ]]; then
# Prepare release (Windows)
cp install_output/bin/SDL3.dll SDL3-CS/native/$NAME/SDL3.dll
cp SDL/install_output/bin/SDL3.dll ../native/$NAME/SDL3.dll
elif [[ $RUNNER_OS == 'Linux' ]]; then
# Prepare release (Linux)
cp install_output/lib/libSDL3.so SDL3-CS/native/$NAME/libSDL3.so
cp SDL/install_output/lib/libSDL3.so ../native/$NAME/libSDL3.so
elif [[ $RUNNER_OS == 'macOS' ]]; then
# Prepare release (macOS)
cp install_output/lib/libSDL3.dylib SDL3-CS/native/$NAME/libSDL3.dylib
cp SDL/install_output/lib/libSDL3.dylib ../native/$NAME/libSDL3.dylib
fi
popd >/dev/null

View File

@ -6,8 +6,6 @@ Generates C# bindings for SDL3 using ClangSharp.
Prerequisites:
- run `dotnet tool restore` (to install ClangSharpPInvokeGenerator)
- https://github.com/libsdl-org/SDL checked out alongside this repository
- git apply --3way `SDL-use-proper-types.patch` to SDL repo
This script should be run manually.
"""
@ -21,12 +19,13 @@ import sys
# Needs to match SDL3.SourceGeneration.Helper.UnsafePrefix
unsafe_prefix = "Unsafe_"
SDL_root = pathlib.Path("../../SDL")
repository_root = pathlib.Path(__file__).resolve().parents[1]
SDL_root = repository_root / "External" / "SDL"
SDL_include_root = SDL_root / "include"
SDL3_header_base = "SDL3" # base folder of header files
csproj_root = pathlib.Path(".")
csproj_root = repository_root / "SDL3-CS"
class Header:
"""Represents a SDL header file that is used in ClangSharp generation."""
@ -131,6 +130,20 @@ headers = [
add("SDL3/SDL_vulkan.h"),
]
def prepare_sdl_source():
subprocess.run([
"git",
"reset",
"--hard",
"HEAD"
], cwd = SDL_root)
subprocess.run([
"git",
"apply",
"--3way",
repository_root / "External" / "SDL-use-proper-types.patch"
], cwd = SDL_root)
def get_sdl_api_dump():
subprocess.run([
@ -292,6 +305,8 @@ def get_string_returning_functions(sdl_api):
def main():
prepare_sdl_source()
sdl_api = get_sdl_api_dump()
# typedefs are added globally as their types appear outside of the defining header