Build Native #38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Native | |
| on: | |
| workflow_dispatch: | |
| # schedule: | |
| # - cron: '0 0 * * *' | |
| env: | |
| BUILD_TYPE: Release | |
| NDK_VER: 28.2.13676358 | |
| PLATFORM_VER: 35 | |
| jobs: | |
| build: | |
| name: ${{ matrix.platform.name }} | |
| runs-on: ${{ matrix.platform.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| platform: | |
| - { name: win-x64, os: windows-latest, flags: -A x64 } | |
| - { name: win-x86, os: windows-2022, flags: -A Win32 } | |
| - { name: win-arm64, os: windows-latest, flags: -A ARM64 } | |
| - { name: linux-x64, os: ubuntu-22.04, flags: -GNinja, target_apt_arch: ":amd64" } | |
| - { name: linux-x86, os: ubuntu-22.04, flags: -GNinja -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 -DWAVPACK_ENABLE_ASM=OFF, target_apt_arch: ":i386" } | |
| - { name: linux-arm64, os: ubuntu-22.04-arm, flags: -GNinja, target_apt_arch: ":arm64", container: "arm64v8/ubuntu:22.04" } | |
| - { name: linux-arm, os: ubuntu-22.04-arm, flags: -GNinja -DCMAKE_C_FLAGS=-mfpu=neon -DCMAKE_CXX_FLAGS=-mfpu=neon, target_apt_arch: ":armhf", container: "arm32v7/ubuntu:22.04" } | |
| - { name: osx-x64, os: macos-13, 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: android-arm64, os: ubuntu-22.04, flags: -GNinja, abi: arm64-v8a } | |
| - { name: android-arm, os: ubuntu-22.04, flags: -GNinja, abi: armeabi-v7a } | |
| - { name: android-x64, os: ubuntu-22.04, flags: -GNinja, abi: x86_64 } | |
| - { name: android-x86, os: ubuntu-22.04, flags: -GNinja, abi: x86 } | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Setup JDK | |
| if: contains(matrix.platform.name, 'android') | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: microsoft | |
| java-version: 17 | |
| - name: Install Android SDK Manager | |
| if: contains(matrix.platform.name, 'android') | |
| uses: android-actions/setup-android@v3 | |
| - name: Install Android SDK | |
| if: contains(matrix.platform.name, 'android') | |
| run: | | |
| sdkmanager --install "platforms;android-$PLATFORM_VER" | |
| sdkmanager --install "ndk;$NDK_VER" | |
| - 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 BUILD_TYPE=${{ env.BUILD_TYPE }} | |
| run: | | |
| cd /workspace | |
| FLAGS="${{ matrix.platform.flags }}" ./External/build.sh | |
| - name: Build | |
| 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 }} | |
| ANDROID_ABI: ${{ matrix.platform.abi }} | |
| run: ./External/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 }} | |
| - name: Compress native directory | |
| if: ${{ !contains(matrix.platform.name, 'android') }} | |
| run: tar -cvf native-${{ matrix.platform.name }}.tar native/${{ matrix.platform.name }} | |
| - name: Compress native directory (Android) | |
| if: contains(matrix.platform.name, 'android') | |
| run: tar -cvf native-${{ matrix.platform.name }}.tar native/android/${{ matrix.platform.abi }} | |
| - name: Upload native artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: native-${{ matrix.platform.name }} | |
| path: native-${{ matrix.platform.name }}.tar | |
| if-no-files-found: error | |
| build-ios: | |
| name: ios | |
| runs-on: macos-15 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| # https://github.com/dotnet/macios/issues/19157 | |
| # https://github.com/actions/runner-images/issues/12758 | |
| - name: Use Xcode 16.4 | |
| run: sudo xcode-select -switch /Applications/Xcode_16.4.app | |
| - name: Build (iOS) | |
| run: | | |
| modules=("SDL3" "SDL3_image" "SDL3_ttf" "SDL3_mixer") | |
| architectures=("ios-arm64" "ios-arm64_x86_64-simulator") | |
| for module in "${modules[@]}"; do | |
| module0="${module/SDL3/SDL}" | |
| directory="External/${module0}/Xcode" | |
| if [ "$module" == "SDL3" ]; then | |
| directory+="/SDL" | |
| fi | |
| target="${module}.xcframework" | |
| framework="${module}.framework" | |
| output_dir="native/ios/${target}" | |
| xcodebuild -project "${directory}/${module0}.xcodeproj" -target "${target}" -configuration Release | |
| build_dir="${directory}/build/${target}" | |
| for arch in "${architectures[@]}"; do | |
| mkdir -p "${output_dir}/${arch}/${framework}" | |
| cp "${build_dir}/${arch}/${framework}/${module}" "${output_dir}/${arch}/${framework}/${module}" | |
| cp "${build_dir}/${arch}/${framework}/Info.plist" "${output_dir}/${arch}/${framework}/Info.plist" | |
| done | |
| cp "${build_dir}/Info.plist" "${output_dir}/Info.plist" | |
| done | |
| - name: Compress native directory | |
| run: tar -cvf native-ios.tar native/ios | |
| - name: Upload native artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: native-ios | |
| path: native-ios.tar | |
| if-no-files-found: error | |
| build-android-jar: | |
| name: android-jar | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - name: Setup JDK | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: microsoft | |
| java-version: | | |
| 11 | |
| 17 | |
| - name: Install Android SDK Manager | |
| uses: android-actions/setup-android@v3 | |
| - name: Install Android SDK | |
| run: | | |
| sdkmanager --install "platforms;android-$PLATFORM_VER" | |
| - 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/Jars/ | |
| rm -rf $OUTPUT && mkdir -p $OUTPUT | |
| # Build SDL3 Android Java part | |
| cd ./External/SDL/android-project/app/src/main/java | |
| javac -cp $ANDROID_HOME/platforms/android-$PLATFORM_VER/android.jar -encoding utf8 org/libsdl/app/*.java | |
| jar cvf $OUTPUT/SDL3AndroidBridge.jar org/libsdl/app/*.class | |
| - name: Upload JAR artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: android-jar | |
| path: SDL3-CS/Jars/SDL3AndroidBridge.jar | |
| if-no-files-found: error | |
| make-pr: | |
| name: Submit pull request | |
| runs-on: ubuntu-latest | |
| needs: [ build, build-ios, build-android-jar ] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download native artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: native-* | |
| merge-multiple: true | |
| - name: Decompress native artifacts | |
| run: | | |
| for file in native-*.tar | |
| do | |
| tar -xf "$file" | |
| done | |
| rm native-*.tar | |
| - name: Download JAR artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: android-jar | |
| path: SDL3-CS/Jars/ | |
| - name: Create pull request | |
| uses: peter-evans/create-pull-request@v6 | |
| with: | |
| commit-message: Update native binaries | |
| title: Update native binaries | |
| body: This PR has been auto-generated to update the native SDL binaries | |
| branch: update-native-binaries | |
| env: | |
| ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' |