Merge branch 'master' into update-bindings

This commit is contained in:
Susko3 2024-04-15 19:49:51 +02:00
commit 36c069f94a
17 changed files with 234 additions and 34 deletions

View File

@ -71,38 +71,50 @@ jobs:
libdrm-dev${{ matrix.platform.target_apt_arch }} \ libdrm-dev${{ matrix.platform.target_apt_arch }} \
libgbm-dev${{ matrix.platform.target_apt_arch }} \ libgbm-dev${{ matrix.platform.target_apt_arch }} \
libpulse-dev${{ matrix.platform.target_apt_arch }} libpulse-dev${{ matrix.platform.target_apt_arch }}
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
repository: 'libsdl-org/SDL' repository: 'libsdl-org/SDL'
ref: 'main' ref: 'main'
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
path: 'SDL3-CS' path: 'SDL3-CS'
- name: Configure CMake - 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 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 - name: Build
run: cmake --build build/ --config Release run: cmake --build build/ --config Release
- name: Install (Windows) - name: Install (Windows)
run: cmake --install build/ --prefix install_output --config Release run: cmake --install build/ --prefix install_output --config Release
if: runner.os == 'Windows' if: runner.os == 'Windows'
- name: Install - name: Install
run: sudo cmake --install build/ --prefix install_output --config Release run: sudo cmake --install build/ --prefix install_output --config Release
if: runner.os != 'Windows' if: runner.os != 'Windows'
- name: Prepare release directory (Windows) - name: Prepare release directory (Windows)
run: mkdir -Force SDL3-CS/native/${{ matrix.platform.name }} run: mkdir -Force SDL3-CS/native/${{ matrix.platform.name }}
if: runner.os == 'Windows' if: runner.os == 'Windows'
- name: Prepare release directory - name: Prepare release directory
run: mkdir -p SDL3-CS/native/${{ matrix.platform.name }} run: mkdir -p SDL3-CS/native/${{ matrix.platform.name }}
if: runner.os != 'Windows' if: runner.os != 'Windows'
- name: Prepare release (Windows) - name: Prepare release (Windows)
run: cp install_output/bin/SDL3.dll SDL3-CS/native/${{ matrix.platform.name }}/SDL3.dll run: cp install_output/bin/SDL3.dll SDL3-CS/native/${{ matrix.platform.name }}/SDL3.dll
if: runner.os == 'Windows' if: runner.os == 'Windows'
- name: Prepare release (Linux) - name: Prepare release (Linux)
run: cp install_output/lib/libSDL3.so SDL3-CS/native/${{ matrix.platform.name }}/libSDL3.so run: cp install_output/lib/libSDL3.so SDL3-CS/native/${{ matrix.platform.name }}/libSDL3.so
if: runner.os == 'Linux' if: runner.os == 'Linux'
- name: Prepare release (macOS) - name: Prepare release (macOS)
run: cp install_output/lib/libSDL3.dylib SDL3-CS/native/${{ matrix.platform.name }}/libSDL3.dylib run: cp install_output/lib/libSDL3.dylib SDL3-CS/native/${{ matrix.platform.name }}/libSDL3.dylib
if: runner.os == 'macOS' if: runner.os == 'macOS'
- name: Create pull request - name: Create pull request
uses: peter-evans/create-pull-request@v6 uses: peter-evans/create-pull-request@v6
with: with:
@ -122,13 +134,17 @@ jobs:
with: with:
repository: 'libsdl-org/SDL' repository: 'libsdl-org/SDL'
ref: 'main' ref: 'main'
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
path: 'SDL3-CS' path: 'SDL3-CS'
- name: Build (iOS) - name: Build (iOS)
run: xcodebuild -project Xcode/SDL/SDL.xcodeproj -target SDL3.xcframework -configuration Release run: xcodebuild -project Xcode/SDL/SDL.xcodeproj -target SDL3.xcframework -configuration Release
- name: Prepare release directory (iOS) - name: Prepare release directory (iOS)
run: mkdir -p SDL3-CS/native/ios run: mkdir -p SDL3-CS/native/ios
- name: Prepare release (iOS) - name: Prepare release (iOS)
run: | run: |
mkdir -p SDL3-CS/native/ios/SDL3.xcframework/ios-arm64/SDL3.framework; mkdir -p SDL3-CS/native/ios/SDL3.xcframework/ios-arm64/SDL3.framework;
@ -138,13 +154,81 @@ jobs:
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/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/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; 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;
- name: Create pull request - name: Create pull request
uses: peter-evans/create-pull-request@v6 uses: peter-evans/create-pull-request@v6
with: with:
commit-message: Update iOS SDL binaries commit-message: Update iOS SDL binaries
title: Update iOS SDL binaries title: Update iOS SDL binaries
body: This PR has been auto-genereated to update the iOS SDL binaries body: This PR has been auto-generated to update the iOS SDL binaries
branch: update-ios-binaries branch: update-ios-binaries
path: 'SDL3-CS' path: 'SDL3-CS'
env: env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
build-android:
name: android
runs-on: ubuntu-20.04
env:
NDK_VER: 23.1.7779620
PLATFORM_VER: android-34
steps:
- uses: actions/checkout@v4
with:
repository: 'libsdl-org/SDL'
ref: 'main'
- uses: actions/checkout@v4
with:
path: 'SDL3-CS'
- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: microsoft
java-version: |
11
17
- name: Install Android SDK Manager
uses: android-actions/setup-android@v3
with:
packages: ''
- name: Install Android SDK
run: |
sdkmanager --install "platform-tools" "platforms;$PLATFORM_VER"
sdkmanager --install "ndk;$NDK_VER" --channel=3
- name: Build (Android)
run: |
export PATH=$ANDROID_HOME/ndk/$NDK_VER:$PATH
export OUTPUT=$PWD/SDL3-CS/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"
- 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/
rm -rf $OUTPUT && mkdir -p $OUTPUT
# Build SDL3 Android Java part
cd 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
- name: Create pull request
uses: peter-evans/create-pull-request@v6
with:
commit-message: Update Android SDL binaries
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'

View File

@ -0,0 +1,48 @@
Additions allow you to add arbitrary C# to the generated classes
before they are compiled. This can be helpful for providing convenience
methods or adding pure C# classes.
== Adding Methods to Generated Classes ==
Let's say the library being bound has a Rectangle class with a constructor
that takes an x and y position, and a width and length size. It will look like
this:
public partial class Rectangle
{
public Rectangle (int x, int y, int width, int height)
{
// JNI bindings
}
}
Imagine we want to add a constructor to this class that takes a Point and
Size structure instead of 4 ints. We can add a new file called Rectangle.cs
with a partial class containing our new method:
public partial class Rectangle
{
public Rectangle (Point location, Size size) :
this (location.X, location.Y, size.Width, size.Height)
{
}
}
At compile time, the additions class will be added to the generated class
and the final assembly will a Rectangle class with both constructors.
== Adding C# Classes ==
Another thing that can be done is adding fully C# managed classes to the
generated library. In the above example, let's assume that there isn't a
Point class available in Java or our library. The one we create doesn't need
to interact with Java, so we'll create it like a normal class in C#.
By adding a Point.cs file with this class, it will end up in the binding library:
public class Point
{
public int X { get; set; }
public int Y { get; set; }
}

View File

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-android</TargetFramework>
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
<RootNamespace>SDL3_CS_Android</RootNamespace>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<EmbeddedJar Include="Jars\SDL3AndroidBridge.jar" />
</ItemGroup>
<ItemGroup>
<EmbeddedNativeLibrary Include="..\native\android\armeabi-v7a\libSDL3.so" />
<EmbeddedNativeLibrary Include="..\native\android\arm64-v8a\libSDL3.so" />
<EmbeddedNativeLibrary Include="..\native\android\x86\libSDL3.so" />
<EmbeddedNativeLibrary Include="..\native\android\x86_64\libSDL3.so" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,14 @@
<enum-field-mappings>
<!--
This example converts the constants Fragment_id, Fragment_name,
and Fragment_tag from android.support.v4.app.FragmentActivity.FragmentTag
to an enum called Android.Support.V4.App.FragmentTagType with values
Id, Name, and Tag.
<mapping jni-class="android/support/v4/app/FragmentActivity$FragmentTag" clr-enum-type="Android.Support.V4.App.FragmentTagType">
<field jni-name="Fragment_name" clr-name="Name" value="0" />
<field jni-name="Fragment_id" clr-name="Id" value="1" />
<field jni-name="Fragment_tag" clr-name="Tag" value="2" />
</mapping>
-->
</enum-field-mappings>

View File

@ -0,0 +1,13 @@
<enum-method-mappings>
<!--
This example changes the Java method:
android.support.v4.app.Fragment.SavedState.writeToParcel (int flags)
to be:
android.support.v4.app.Fragment.SavedState.writeToParcel (Android.OS.ParcelableWriteFlags flags)
when bound in C#.
<mapping jni-class="android/support/v4/app/Fragment.SavedState">
<method jni-name="writeToParcel" parameter="flags" clr-enum-type="Android.OS.ParcelableWriteFlags" />
</mapping>
-->
</enum-method-mappings>

View File

@ -0,0 +1,14 @@
<metadata>
<remove-node
path="/api/package[@name='org.libsdl.app']/class[@name='SDLActivity']/field[@name='mClipboardHandler']"/>
<remove-node
path="/api/package[@name='org.libsdl.app']/class[@name='SDLActivity']/field[@name='mMotionListener']"/>
<remove-node
path="/api/package[@name='org.libsdl.app']/class[@name='SDLActivity']/field[@name='mTextEdit']"/>
<remove-node
path="/api/package[@name='org.libsdl.app']/class[@name='SDLActivity']/method[@name='getMotionListener' and count(parameter)=0]"/>
<remove-node
path="/api/package[@name='org.libsdl.app']/class[@name='SDLControllerManager']/field[@name='mHapticHandler']"/>
<remove-node
path="/api/package[@name='org.libsdl.app']/class[@name='SDLControllerManager']/field[@name='mJoystickHandler']"/>
</metadata>

View File

@ -6,27 +6,26 @@ MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{18C20490-AA42-464A-BBC4-7B6CF63B91DE}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{18C20490-AA42-464A-BBC4-7B6CF63B91DE}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig .editorconfig = .editorconfig
.gitignore = .gitignore
.globalconfig = .globalconfig .globalconfig = .globalconfig
Directory.Build.props = Directory.Build.props Directory.Build.props = Directory.Build.props
global.json = global.json
.config\dotnet-tools.json = .config\dotnet-tools.json .config\dotnet-tools.json = .config\dotnet-tools.json
.gitignore = .gitignore global.json = global.json
EndProjectSection EndProjectSection
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDL3-CS", "SDL3-CS\SDL3-CS.csproj", "{3AEE5979-6974-4BD6-9BB1-1409B0BB469B}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SDL3-CS", "SDL3-CS\SDL3-CS.csproj", "{3AEE5979-6974-4BD6-9BB1-1409B0BB469B}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDL3-CS.SourceGeneration", "SDL3-CS.SourceGeneration\SDL3-CS.SourceGeneration.csproj", "{432C86D0-D371-4D01-BFFE-01D2CDCCA7B8}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SDL3-CS.SourceGeneration", "SDL3-CS.SourceGeneration\SDL3-CS.SourceGeneration.csproj", "{432C86D0-D371-4D01-BFFE-01D2CDCCA7B8}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDL3-CS.Tests", "SDL3-CS.Tests\SDL3-CS.Tests.csproj", "{CF980481-8227-4BED-970E-6433C83F64CB}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SDL3-CS.Tests", "SDL3-CS.Tests\SDL3-CS.Tests.csproj", "{CF980481-8227-4BED-970E-6433C83F64CB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDL3-CS-Android", "SDL3-CS-Android\SDL3-CS-Android.csproj", "{CA28F49C-D0BE-47D6-9E82-7A0B8C380B8B}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3AEE5979-6974-4BD6-9BB1-1409B0BB469B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3AEE5979-6974-4BD6-9BB1-1409B0BB469B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3AEE5979-6974-4BD6-9BB1-1409B0BB469B}.Debug|Any CPU.Build.0 = Debug|Any CPU {3AEE5979-6974-4BD6-9BB1-1409B0BB469B}.Debug|Any CPU.Build.0 = Debug|Any CPU
@ -40,5 +39,15 @@ Global
{CF980481-8227-4BED-970E-6433C83F64CB}.Debug|Any CPU.Build.0 = Debug|Any CPU {CF980481-8227-4BED-970E-6433C83F64CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CF980481-8227-4BED-970E-6433C83F64CB}.Release|Any CPU.ActiveCfg = Release|Any CPU {CF980481-8227-4BED-970E-6433C83F64CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CF980481-8227-4BED-970E-6433C83F64CB}.Release|Any CPU.Build.0 = Release|Any CPU {CF980481-8227-4BED-970E-6433C83F64CB}.Release|Any CPU.Build.0 = Release|Any CPU
{CA28F49C-D0BE-47D6-9E82-7A0B8C380B8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CA28F49C-D0BE-47D6-9E82-7A0B8C380B8B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CA28F49C-D0BE-47D6-9E82-7A0B8C380B8B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CA28F49C-D0BE-47D6-9E82-7A0B8C380B8B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {19F716B7-F795-4152-A923-B8750DDBAB4E}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View File

@ -4,31 +4,6 @@
<dict> <dict>
<key>AvailableLibraries</key> <key>AvailableLibraries</key>
<array> <array>
<dict>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>SDL3.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
</dict>
<dict>
<key>LibraryIdentifier</key>
<string>macos-arm64_x86_64</string>
<key>LibraryPath</key>
<string>SDL3.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>macos</string>
</dict>
<dict> <dict>
<key>LibraryIdentifier</key> <key>LibraryIdentifier</key>
<string>tvos-arm64_x86_64-simulator</string> <string>tvos-arm64_x86_64-simulator</string>
@ -44,6 +19,18 @@
<key>SupportedPlatformVariant</key> <key>SupportedPlatformVariant</key>
<string>simulator</string> <string>simulator</string>
</dict> </dict>
<dict>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>SDL3.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
</dict>
<dict> <dict>
<key>LibraryIdentifier</key> <key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string> <string>ios-arm64_x86_64-simulator</string>
@ -59,6 +46,19 @@
<key>SupportedPlatformVariant</key> <key>SupportedPlatformVariant</key>
<string>simulator</string> <string>simulator</string>
</dict> </dict>
<dict>
<key>LibraryIdentifier</key>
<string>macos-arm64_x86_64</string>
<key>LibraryPath</key>
<string>SDL3.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>macos</string>
</dict>
<dict> <dict>
<key>LibraryIdentifier</key> <key>LibraryIdentifier</key>
<string>tvos-arm64</string> <string>tvos-arm64</string>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.