diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 984e86a..ddde5b8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -71,38 +71,50 @@ jobs: 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' ref: 'main' + - uses: actions/checkout@v4 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: 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' + - name: Create pull request uses: peter-evans/create-pull-request@v6 with: @@ -122,13 +134,17 @@ jobs: with: repository: 'libsdl-org/SDL' ref: 'main' + - uses: actions/checkout@v4 with: path: 'SDL3-CS' + - name: Build (iOS) run: xcodebuild -project Xcode/SDL/SDL.xcodeproj -target SDL3.xcframework -configuration Release + - name: Prepare release directory (iOS) run: mkdir -p SDL3-CS/native/ios + - name: Prepare release (iOS) run: | 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_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; + - name: Create pull request uses: peter-evans/create-pull-request@v6 with: commit-message: 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 path: 'SDL3-CS' env: 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' diff --git a/SDL3-CS-Android/Additions/AboutAdditions.txt b/SDL3-CS-Android/Additions/AboutAdditions.txt new file mode 100644 index 0000000..2775bd3 --- /dev/null +++ b/SDL3-CS-Android/Additions/AboutAdditions.txt @@ -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; } +} \ No newline at end of file diff --git a/SDL3-CS-Android/SDL3-CS-Android.csproj b/SDL3-CS-Android/SDL3-CS-Android.csproj new file mode 100644 index 0000000..c304bdd --- /dev/null +++ b/SDL3-CS-Android/SDL3-CS-Android.csproj @@ -0,0 +1,18 @@ + + + net8.0-android + 21 + SDL3_CS_Android + enable + enable + + + + + + + + + + + \ No newline at end of file diff --git a/SDL3-CS-Android/Transforms/EnumFields.xml b/SDL3-CS-Android/Transforms/EnumFields.xml new file mode 100644 index 0000000..2295995 --- /dev/null +++ b/SDL3-CS-Android/Transforms/EnumFields.xml @@ -0,0 +1,14 @@ + + + \ No newline at end of file diff --git a/SDL3-CS-Android/Transforms/EnumMethods.xml b/SDL3-CS-Android/Transforms/EnumMethods.xml new file mode 100644 index 0000000..49216c6 --- /dev/null +++ b/SDL3-CS-Android/Transforms/EnumMethods.xml @@ -0,0 +1,13 @@ + + + \ No newline at end of file diff --git a/SDL3-CS-Android/Transforms/Metadata.xml b/SDL3-CS-Android/Transforms/Metadata.xml new file mode 100644 index 0000000..6105866 --- /dev/null +++ b/SDL3-CS-Android/Transforms/Metadata.xml @@ -0,0 +1,14 @@ + + + + + + + + diff --git a/SDL3-CS.sln b/SDL3-CS.sln index 98f5ca6..6b4a898 100644 --- a/SDL3-CS.sln +++ b/SDL3-CS.sln @@ -6,27 +6,26 @@ MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{18C20490-AA42-464A-BBC4-7B6CF63B91DE}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig + .gitignore = .gitignore .globalconfig = .globalconfig Directory.Build.props = Directory.Build.props - global.json = global.json .config\dotnet-tools.json = .config\dotnet-tools.json - .gitignore = .gitignore + global.json = global.json EndProjectSection 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 -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 -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 Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {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 @@ -40,5 +39,15 @@ Global {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.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 EndGlobal diff --git a/native/ios/SDL3.xcframework/Info.plist b/native/ios/SDL3.xcframework/Info.plist index 3943adc..f51bed4 100644 --- a/native/ios/SDL3.xcframework/Info.plist +++ b/native/ios/SDL3.xcframework/Info.plist @@ -4,31 +4,6 @@ AvailableLibraries - - LibraryIdentifier - ios-arm64 - LibraryPath - SDL3.framework - SupportedArchitectures - - arm64 - - SupportedPlatform - ios - - - LibraryIdentifier - macos-arm64_x86_64 - LibraryPath - SDL3.framework - SupportedArchitectures - - arm64 - x86_64 - - SupportedPlatform - macos - LibraryIdentifier tvos-arm64_x86_64-simulator @@ -44,6 +19,18 @@ SupportedPlatformVariant simulator + + LibraryIdentifier + ios-arm64 + LibraryPath + SDL3.framework + SupportedArchitectures + + arm64 + + SupportedPlatform + ios + LibraryIdentifier ios-arm64_x86_64-simulator @@ -59,6 +46,19 @@ SupportedPlatformVariant simulator + + LibraryIdentifier + macos-arm64_x86_64 + LibraryPath + SDL3.framework + SupportedArchitectures + + arm64 + x86_64 + + SupportedPlatform + macos + LibraryIdentifier tvos-arm64 diff --git a/native/ios/SDL3.xcframework/ios-arm64/SDL3.framework/SDL3 b/native/ios/SDL3.xcframework/ios-arm64/SDL3.framework/SDL3 index f220b22..c62f702 100755 Binary files a/native/ios/SDL3.xcframework/ios-arm64/SDL3.framework/SDL3 and b/native/ios/SDL3.xcframework/ios-arm64/SDL3.framework/SDL3 differ diff --git a/native/ios/SDL3.xcframework/ios-arm64_x86_64-simulator/SDL3.framework/SDL3 b/native/ios/SDL3.xcframework/ios-arm64_x86_64-simulator/SDL3.framework/SDL3 index de7a963..2d0e24d 100755 Binary files a/native/ios/SDL3.xcframework/ios-arm64_x86_64-simulator/SDL3.framework/SDL3 and b/native/ios/SDL3.xcframework/ios-arm64_x86_64-simulator/SDL3.framework/SDL3 differ diff --git a/native/linux-x64/libSDL3.so b/native/linux-x64/libSDL3.so index 3ed95b5..cfc865b 100644 Binary files a/native/linux-x64/libSDL3.so and b/native/linux-x64/libSDL3.so differ diff --git a/native/linux-x86/libSDL3.so b/native/linux-x86/libSDL3.so index bb2c957..e14c1d9 100644 Binary files a/native/linux-x86/libSDL3.so and b/native/linux-x86/libSDL3.so differ diff --git a/native/osx-arm64/libSDL3.dylib b/native/osx-arm64/libSDL3.dylib index e70f85c..e66cd3b 100755 Binary files a/native/osx-arm64/libSDL3.dylib and b/native/osx-arm64/libSDL3.dylib differ diff --git a/native/osx-x64/libSDL3.dylib b/native/osx-x64/libSDL3.dylib index c6b1122..58f5d04 100755 Binary files a/native/osx-x64/libSDL3.dylib and b/native/osx-x64/libSDL3.dylib differ diff --git a/native/win-arm64/SDL3.dll b/native/win-arm64/SDL3.dll index 21f9752..5357352 100644 Binary files a/native/win-arm64/SDL3.dll and b/native/win-arm64/SDL3.dll differ diff --git a/native/win-x64/SDL3.dll b/native/win-x64/SDL3.dll index a413fee..26c039c 100644 Binary files a/native/win-x64/SDL3.dll and b/native/win-x64/SDL3.dll differ diff --git a/native/win-x86/SDL3.dll b/native/win-x86/SDL3.dll index b664ab1..b18d633 100644 Binary files a/native/win-x86/SDL3.dll and b/native/win-x86/SDL3.dll differ