build-native #72
This file contains 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: | |
inputs: {} | |
# schedule: | |
# - cron: '0 0 * * *' | |
env: | |
BUILD_TYPE: Release | |
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-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" } | |
# 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" } | |
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 <https://github.com/actions/virtual-environments/issues/4589> | |
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 }} \ | |
libsdl2-2.0-0${{ 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' | |
ref: 'SDL2' | |
- uses: actions/checkout@v4 | |
with: | |
path: 'NAudio-Sdl2-Library' | |
- 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 NAudio-Sdl2-Library/NAudio.Sdl2.Library/native/${{ matrix.platform.name }} | |
if: runner.os == 'Windows' | |
- name: Prepare release directory | |
run: mkdir -p NAudio-Sdl2-Library/NAudio.Sdl2.Library/native/${{ matrix.platform.name }} | |
if: runner.os != 'Windows' | |
- name: Prepare release (Windows) | |
run: cp install_output/bin/SDL2.dll NAudio-Sdl2-Library/NAudio.Sdl2.Library/native/${{ matrix.platform.name }}/SDL2.dll | |
if: runner.os == 'Windows' | |
- name: Prepare release (Linux) | |
run: cp install_output/lib/libSDL2-2.0.so.0 NAudio-Sdl2-Library/NAudio.Sdl2.Library/native/${{ matrix.platform.name }}/libSDL2.so | |
if: runner.os == 'Linux' | |
- name: Prepare release (macOS) | |
run: cp install_output/lib/libSDL2-2.0.dylib NAudio-Sdl2-Library/NAudio.Sdl2.Library/native/${{ matrix.platform.name }}/libSDL2.dylib | |
if: runner.os == 'macOS' | |
- name: Create pull request | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
commit-message: Update ${{ matrix.platform.name }} SDL binaries | |
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: 'NAudio-Sdl2-Library' | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' | |
build-ios: | |
name: ios | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
repository: 'libsdl-org/SDL' | |
ref: 'SDL2' | |
- uses: actions/checkout@v4 | |
with: | |
path: 'NAudio-Sdl2-Library' | |
- name: Build (iOS) | |
run: xcodebuild -project Xcode/SDL/SDL.xcodeproj -scheme xcFramework-iOS -configuration Release | |
- name: Prepare release directory (iOS) | |
run: mkdir -p NAudio-Sdl2-Library/NAudio-Sdl2-Library/NAudio.Sdl2.Library/native/ios | |
- name: Prepare release (iOS) | |
run: | | |
mkdir -p NAudio-Sdl2-Library/NAudio.Sdl2.Library/native/ios/SDL2.xcframework/ios-arm64/SDL2.framework; | |
mkdir -p NAudio-Sdl2-Library/NAudio.Sdl2.Library/native/ios/SDL2.xcframework/ios-arm64_x86_64-simulator/SDL2.framework; | |
cp Xcode/SDL/Products/SDL2.xcframework/Info.plist NAudio-Sdl2-Library/NAudio.Sdl2.Library/native/ios/SDL2.xcframework/Info.plist; | |
cp Xcode/SDL/Products/SDL2.xcframework/ios-arm64/SDL2.framework/SDL2 NAudio-Sdl2-Library/NAudio.Sdl2.Library/native/ios/SDL2.xcframework/ios-arm64/SDL2.framework/SDL2; | |
cp Xcode/SDL/Products/SDL2.xcframework/ios-arm64/SDL2.framework/Info.plist NAudio-Sdl2-Library/NAudio.Sdl2.Library/native/ios/SDL2.xcframework/ios-arm64/SDL2.framework/Info.plist; | |
cp Xcode/SDL/Products/SDL2.xcframework/ios-arm64_x86_64-simulator/SDL2.framework/SDL2 NAudio-Sdl2-Library/NAudio.Sdl2.Library/native/ios/SDL2.xcframework/ios-arm64_x86_64-simulator/SDL2.framework/SDL2; | |
cp Xcode/SDL/Products/SDL2.xcframework/ios-arm64_x86_64-simulator/SDL2.framework/Info.plist NAudio-Sdl2-Library/NAudio.Sdl2.Library/native/ios/SDL2.xcframework/ios-arm64_x86_64-simulator/SDL2.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 | |
branch: update-ios-binaries | |
path: 'NAudio-Sdl2-Library' | |
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: 'SDL2' | |
- uses: actions/checkout@v4 | |
with: | |
path: 'NAudio-Sdl2-Library' | |
- 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 | |
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/native/android | |
rm -rf $OUTPUT && mkdir -p $OUTPUT | |
# Build SDL2 | |
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: Prepare release directory (android) | |
run: mkdir -p NAudio-Sdl2-Library/NAudio.Sdl2.Library/native/android | |
- name: Prepare release (android) | |
run: | | |
mkdir -p NAudio-Sdl2-Library/NAudio.Sdl2.Library/native/android/arm64-v8a; | |
mkdir -p NAudio-Sdl2-Library/NAudio.Sdl2.Library/native/android/armeabi-v7a; | |
mkdir -p NAudio-Sdl2-Library/NAudio.Sdl2.Library/native/android/x86; | |
mkdir -p NAudio-Sdl2-Library/NAudio.Sdl2.Library/native/android/x86_64; | |
cp NAudio-Sdl2-Library/native/android/arm64-v8a/libSDL2.so NAudio-Sdl2-Library/NAudio.Sdl2.Library/native/android/arm64-v8a/libSDL2.so; | |
cp NAudio-Sdl2-Library/native/android/armeabi-v7a/libSDL2.so NAudio-Sdl2-Library/NAudio.Sdl2.Library/native/android/armeabi-v7a/libSDL2.so; | |
cp NAudio-Sdl2-Library/native/android/x86/libSDL2.so NAudio-Sdl2-Library/NAudio.Sdl2.Library/native/android/x86/libSDL2.so; | |
cp NAudio-Sdl2-Library/native/android/x86_64/libSDL2.so NAudio-Sdl2-Library/NAudio.Sdl2.Library/native/android/x86_64/libSDL2.so; | |
- name: Build SDL2 Android Java | |
run: | | |
export JAVA_HOME=$JAVA_HOME_11_X64 | |
export PATH=$JAVA_HOME_11_X64/bin:$PATH | |
export OUTPUT=NAudio-Sdl2-Library/Jars/ | |
rm -rf $OUTPUT && mkdir -p $OUTPUT | |
# Build SDL2 Android Java part | |
javac -cp $ANDROID_HOME/platforms/$PLATFORM_VER/android.jar -encoding utf8 android-project/app/src/main/java/org/libsdl/app/*.java | |
jar cvf $OUTPUT/SDL2AndroidBridge.jar android-project/app/src/main/java/org/libsdl/app/*.class | |
- name: Prepare release directory (android java) | |
run: mkdir -p NAudio-Sdl2-Library/NAudio.Sdl2.Library.Android | |
- name: Prepare release (android java) | |
run: | | |
mkdir -p NAudio-Sdl2-Library/NAudio.Sdl2.Library.Android/Jars; | |
cp NAudio-Sdl2-Library/Jars/SDL2AndroidBridge.jar NAudio-Sdl2-Library/NAudio.Sdl2.Library.Android/Jars/SDL2AndroidBridge.jar; | |
rm -rf NAudio-Sdl2-Library/Jars; | |
- 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-genereated to update the android SDL binaries | |
branch: update-android-binaries | |
path: 'NAudio-Sdl2-Library' | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' |