ci: fix git submodule checkout issues #2
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 Library | |
| on: | |
| push: | |
| paths: | |
| - 'Native/**' | |
| - '.github/workflows/**' | |
| jobs: | |
| build-freebsd-x64: | |
| name: Build for FreeBSD - x86_64 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| submodules: recursive | |
| - name: Create Build Directories on Host | |
| shell: bash | |
| run: | | |
| mkdir -p ${{ github.workspace }}/Native/build | |
| mkdir -p ${{ github.workspace }}/Native/cmake | |
| - name: Build on FreeBSD x86_64 VM | |
| uses: vmactions/freebsd-vm@v1 | |
| with: | |
| release: "14.2" | |
| arch: "x86_64" | |
| usesh: true | |
| prepare: | | |
| pkg install -y cmake gcc | |
| run: | | |
| set -ex # Exit on error and print commands | |
| echo "--- Current directory: $(pwd) ---" | |
| echo "--- Listing GITHUB_WORKSPACE ---" | |
| ls -la $GITHUB_WORKSPACE | |
| cd $GITHUB_WORKSPACE/Native | |
| echo "--- System Information (inside FreeBSD VM) ---" | |
| freebsd-version | |
| uname -a | |
| cc --version || clang --version || gcc --version | |
| cmake --version | |
| echo "--- Configuring CMake for FreeBSD x86_64 ---" | |
| CMAKE_FLAGS="-DCMAKE_SYSTEM_PROCESSOR=amd64" | |
| rm -rf build | |
| mkdir build | |
| cmake -S . -B build -DCMAKE_BUILD_TYPE=Release $CMAKE_FLAGS | |
| echo "--- Building for FreeBSD x86_64 ---" | |
| cmake --build build --config Release | |
| echo "--- Built library path ---" | |
| ls -l build/libminiaudio.so | |
| echo "--- Analyzing Dependencies for FreeBSD x86_64 ---" | |
| ldd build/libminiaudio.so | |
| - name: Create Output Directory for Artifact | |
| shell: bash | |
| run: | | |
| mkdir -p runtimes/freebsd-x64/native | |
| - name: Copy Library for Artifact | |
| shell: bash | |
| run: | | |
| cp "${{ github.workspace }}/Native/build/libminiaudio.so" "runtimes/freebsd-x64/native/" | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: freebsd-x64 | |
| path: runtimes/freebsd-x64 | |
| build-freebsd-arm64: | |
| name: Build for FreeBSD - aarch64 | |
| runs-on: ubuntu-latest | |
| needs: build-freebsd-x64 | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| submodules: recursive | |
| - name: Create Build Directories on Host | |
| shell: bash | |
| run: | | |
| mkdir -p ${{ github.workspace }}/Native/build | |
| mkdir -p ${{ github.workspace }}/Native/cmake | |
| - name: Build on FreeBSD aarch64 VM | |
| uses: vmactions/freebsd-vm@v1 | |
| with: | |
| release: "14.2" | |
| arch: "aarch64" | |
| usesh: true | |
| prepare: | | |
| pkg install -y cmake gcc | |
| run: | | |
| set -ex # Exit on error and print commands | |
| echo "--- Current directory: $(pwd) ---" | |
| echo "--- Listing GITHUB_WORKSPACE ---" | |
| ls -la $GITHUB_WORKSPACE | |
| cd $GITHUB_WORKSPACE/Native | |
| echo "--- System Information (inside FreeBSD VM) ---" | |
| freebsd-version | |
| uname -a | |
| cc --version || clang --version || gcc --version | |
| cmake --version | |
| echo "--- Configuring CMake for FreeBSD aarch64 ---" | |
| CMAKE_FLAGS="-DCMAKE_SYSTEM_PROCESSOR=arm64" | |
| rm -rf build | |
| mkdir build | |
| cmake -S . -B build -DCMAKE_BUILD_TYPE=Release $CMAKE_FLAGS | |
| echo "--- Building for FreeBSD aarch64 ---" | |
| cmake --build build --config Release | |
| echo "--- Built library path ---" | |
| ls -l build/libminiaudio.so | |
| echo "--- Analyzing Dependencies for FreeBSD aarch64 ---" | |
| ldd build/libminiaudio.so | |
| - name: Create Output Directory for Artifact | |
| shell: bash | |
| run: | | |
| mkdir -p runtimes/freebsd-arm64/native | |
| - name: Copy Library for Artifact | |
| shell: bash | |
| run: | | |
| cp "${{ github.workspace }}/Native/build/libminiaudio.so" "runtimes/freebsd-arm64/native/" | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: freebsd-arm64 | |
| path: runtimes/freebsd-arm64 | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Windows builds | |
| - os: windows-latest | |
| rid: win-x64 | |
| platform: Windows | |
| arch: x64 | |
| cmake_target_arch: x64 | |
| lib_extension: ".dll" | |
| toolchain: "Visual Studio 17 2022" | |
| - os: windows-latest | |
| rid: win-x86 | |
| platform: Windows | |
| arch: x86 | |
| cmake_target_arch: Win32 | |
| lib_extension: ".dll" | |
| toolchain: "Visual Studio 17 2022" | |
| - os: windows-latest | |
| rid: win-arm64 | |
| platform: Windows | |
| arch: ARM64 | |
| cmake_target_arch: ARM64 | |
| lib_extension: ".dll" | |
| toolchain: "Visual Studio 17 2022" | |
| # Linux builds | |
| - os: ubuntu-22.04 | |
| rid: linux-x64 | |
| platform: Linux | |
| arch: x86_64 | |
| cmake_target_arch: x64 | |
| lib_extension: ".so" | |
| - os: ubuntu-22.04 | |
| rid: linux-arm | |
| platform: Linux | |
| arch: armv7l | |
| cmake_target_arch: arm | |
| lib_extension: ".so" | |
| - os: ubuntu-22.04 | |
| rid: linux-arm64 | |
| platform: Linux | |
| arch: aarch64 | |
| cmake_target_arch: aarch64 | |
| lib_extension: ".so" | |
| # macOS builds | |
| - os: macos-latest | |
| rid: osx-arm64 | |
| platform: macOS | |
| arch: arm64 | |
| cmake_target_arch: arm64 | |
| lib_extension: ".dylib" | |
| - os: macos-latest | |
| rid: osx-x64 | |
| platform: macOS | |
| arch: x86_64 | |
| cmake_target_arch: x86_64 | |
| lib_extension: ".dylib" | |
| # iOS builds | |
| - os: macos-latest | |
| rid: ios-arm64 | |
| platform: iOS | |
| arch: arm64 | |
| cmake_target_arch: arm64 | |
| lib_extension: ".framework" | |
| # Android builds | |
| - os: ubuntu-22.04 | |
| rid: android-arm | |
| platform: Android | |
| arch: armeabi-v7a | |
| cmake_target_arch: armeabi-v7a | |
| lib_extension: ".so" | |
| - os: ubuntu-22.04 | |
| rid: android-arm64 | |
| platform: Android | |
| arch: arm64-v8a | |
| cmake_target_arch: arm64-v8a | |
| lib_extension: ".so" | |
| - os: ubuntu-22.04 | |
| rid: android-x64 | |
| platform: Android | |
| arch: x86_64 | |
| cmake_target_arch: x86_64 | |
| lib_extension: ".so" | |
| name: Build for ${{ matrix.platform }} - ${{ matrix.arch }} | |
| container: ${{ matrix.platform == 'Linux' && 'debian:buster-slim' || '' }} | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Checkout submodules | |
| run: git submodule update --init --recursive | |
| - name: Create Build Directories | |
| shell: bash | |
| run: | | |
| mkdir -p ${{ github.workspace }}/Native/build | |
| mkdir -p ${{ github.workspace }}/Native/cmake | |
| # Windows-specific setup | |
| - name: Setup Visual Studio (Windows) | |
| if: matrix.platform == 'Windows' | |
| uses: microsoft/setup-msbuild@v2 | |
| - name: Install Windows SDK (Windows) | |
| if: matrix.platform == 'Windows' | |
| uses: GuillaumeFalourd/setup-windows10-sdk-action@v2.4 | |
| - name: Install VS Build Tools | |
| if: matrix.platform == 'Windows' | |
| shell: powershell | |
| run: | | |
| # Install Chocolatey | |
| Set-ExecutionPolicy Bypass -Scope Process -Force; | |
| [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; | |
| iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) | |
| # Install Visual Studio Build Tools | |
| choco install visualstudio2019buildtools --package-parameters "--includeRecommended --includeOptional --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64" --no-progress | |
| # Find and set dumpbin path | |
| $vsPath = "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC" | |
| $latestVersion = (Get-ChildItem -Path $vsPath | Sort-Object Name -Descending | Select-Object -First 1).Name | |
| $dumpbinPath = "$vsPath\$latestVersion\bin\Hostx64\x64" | |
| # Add to PATH | |
| "DUMPBIN_PATH=$dumpbinPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| "PATH=$dumpbinPath;$env:PATH" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| # Linux/Android dependencies | |
| - name: UpdateSource (Linux) | |
| if: matrix.platform == 'Linux' | |
| run: | | |
| rm /etc/apt/sources.list | |
| echo 'deb http://archive.debian.org/debian buster main contrib non-free' >> /etc/apt/sources.list | |
| echo 'deb http://archive.debian.org/debian buster-updates main contrib non-free' >> /etc/apt/sources.list | |
| echo 'deb http://archive.debian.org/debian-security buster/updates main contrib non-free' >> /etc/apt/sources.list | |
| - name: InstallTool (Linux) | |
| if: matrix.platform == 'Linux' | |
| run: | | |
| dpkg --add-architecture arm64 | |
| apt-get clean | |
| apt-get update | |
| apt-get install libicu-dev -y | |
| apt-get install libssl-dev -y | |
| apt-get install wget -y | |
| apt-get install curl -y | |
| apt-get install clang llvm -y | |
| apt-get install gcc-aarch64-linux-gnu -y | |
| apt-get install binutils-aarch64-linux-gnu -y | |
| apt-get install zlib1g-dev -y | |
| apt-get install zlib1g-dev:arm64 -y | |
| - name: Install Dependencies (Linux) | |
| if: matrix.platform == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y cmake gcc g++ file binutils | |
| - name: Install Dependencies (Android) | |
| if: matrix.platform == 'Android' | |
| uses: android-actions/setup-android@v2 | |
| - name: Install Cross-Compilation tools (Linux) | |
| if: matrix.platform == 'Linux' && (matrix.arch == 'armv7l' || matrix.arch == 'aarch64') | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y qemu-user-static | |
| if [ "${{ matrix.arch }}" == "armv7l" ]; then | |
| sudo apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf | |
| elif [ "${{ matrix.arch }}" == "aarch64" ]; then | |
| sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu | |
| fi | |
| - name: Configure CMake (Windows) | |
| if: matrix.platform == 'Windows' | |
| shell: cmd | |
| working-directory: ${{ github.workspace }}/Native | |
| run: | | |
| cmake -B build -G "%TOOLCHAIN%" -A %CMAKE_TARGET_ARCH% -DCMAKE_BUILD_TYPE=Release | |
| env: | |
| TOOLCHAIN: ${{ matrix.toolchain }} | |
| CMAKE_TARGET_ARCH: ${{ matrix.cmake_target_arch }} | |
| - name: Configure CMake (Unix) | |
| if: matrix.platform != 'Windows' | |
| shell: bash | |
| working-directory: ${{ github.workspace }}/Native | |
| run: | | |
| CMAKE_FLAGS="" | |
| if [ "${{ matrix.platform }}" == "Android" ]; then | |
| CMAKE_FLAGS="-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake -DANDROID_ABI=${{ matrix.arch }} -DANDROID_PLATFORM=android-21 -DCMAKE_ANDROID_ARCH_ABI=${{ matrix.cmake_target_arch }}" | |
| elif [ "${{ matrix.platform }}" == "iOS" ]; then | |
| CMAKE_FLAGS="-G Xcode \ | |
| -DCMAKE_SYSTEM_NAME=iOS \ | |
| -DCMAKE_OSX_ARCHITECTURES=${{ matrix.cmake_target_arch }} \ | |
| -DCMAKE_OSX_DEPLOYMENT_TARGET=12.0 \ | |
| -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY="" \ | |
| -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=NO \ | |
| -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED=NO" | |
| elif [ "${{ matrix.platform }}" == "macOS" ]; then | |
| CMAKE_FLAGS="-DCMAKE_OSX_ARCHITECTURES=${{ matrix.cmake_target_arch }}" | |
| elif [ "${{ matrix.platform }}" == "Linux" ]; then | |
| # Add specific flags for Linux cross-compilation | |
| if [ "${{ matrix.arch }}" == "armv7l" ]; then | |
| CMAKE_FLAGS="-DCMAKE_SYSTEM_PROCESSOR=arm -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc -DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++" | |
| elif [ "${{ matrix.arch }}" == "aarch64" ]; then | |
| CMAKE_FLAGS="-DCMAKE_SYSTEM_PROCESSOR=aarch64 -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++" | |
| else | |
| CMAKE_FLAGS="-DCMAKE_SYSTEM_PROCESSOR=x86_64" | |
| fi | |
| fi | |
| cmake -B build -DCMAKE_BUILD_TYPE=Release $CMAKE_FLAGS | |
| # Build steps | |
| - name: Build (Windows) | |
| if: matrix.platform == 'Windows' | |
| shell: cmd | |
| working-directory: ${{ github.workspace }}/Native/build | |
| run: | | |
| cmake --build . --config Release | |
| - name: Build (iOS) | |
| if: matrix.platform == 'iOS' | |
| shell: bash | |
| working-directory: ${{ github.workspace }}/Native/build | |
| run: | | |
| xcodebuild \ | |
| -project *.xcodeproj \ | |
| -configuration Release \ | |
| -sdk iphoneos \ | |
| CODE_SIGN_IDENTITY="" \ | |
| CODE_SIGNING_REQUIRED=NO \ | |
| CODE_SIGNING_ALLOWED=NO | |
| - name: Build (Unix) | |
| if: matrix.platform != 'Windows' && matrix.platform != 'iOS' | |
| shell: bash | |
| working-directory: ${{ github.workspace }}/Native/build | |
| run: | | |
| cmake --build . --config Release | |
| # Artifact collection | |
| - name: Create Output Directory | |
| shell: bash | |
| run: | | |
| mkdir -p runtimes/${{ matrix.rid }}/native | |
| - name: Copy Library | |
| shell: bash | |
| run: | | |
| mkdir -p runtimes/${{ matrix.rid }}/native | |
| if [ "${{ matrix.platform }}" == "Windows" ]; then | |
| cp "${{ github.workspace }}/Native/build/Release/miniaudio.dll" "runtimes/${{ matrix.rid }}/native/" | |
| elif [ "${{ matrix.platform }}" == "iOS" ]; then | |
| cp -r "${{ github.workspace }}/Native/build/Release-iphoneos/miniaudio.framework" "runtimes/${{ matrix.rid }}/native/" | |
| else | |
| cp "${{ github.workspace }}/Native/build/libminiaudio${{ matrix.lib_extension }}" "runtimes/${{ matrix.rid }}/native/" | |
| fi | |
| # Dependency analysis | |
| - name: Analyze Dependencies and Exports (Windows) | |
| if: matrix.platform == 'Windows' | |
| shell: powershell | |
| run: | | |
| $libPath = "runtimes/${{ matrix.rid }}/native/miniaudio.dll" | |
| Write-Host "--- Dependencies for $libPath ---" | |
| & "$env:DUMPBIN_PATH\dumpbin.exe" /DEPENDENTS "$libPath" | |
| Write-Host "--- Exports for $libPath ---" | |
| & "$env:DUMPBIN_PATH\dumpbin.exe" /EXPORTS "$libPath" | |
| - name: Analyze Dependencies and Exports (iOS) | |
| if: matrix.platform == 'iOS' | |
| shell: bash | |
| run: | | |
| LIB_PATH="runtimes/${{ matrix.rid }}/native/miniaudio.framework/miniaudio" | |
| echo "--- Dependencies for iOS ---" | |
| otool -L "$LIB_PATH" | |
| echo "--- Symbols ---" | |
| nm -g "$LIB_PATH" | grep " T " | |
| - name: Analyze Dependencies and Exports (Android) | |
| if: matrix.platform == 'Android' | |
| shell: bash | |
| run: | | |
| LIB_PATH="runtimes/${{ matrix.rid }}/native/libminiaudio.so" | |
| echo "--- Dependencies for Android ---" | |
| readelf -d "$LIB_PATH" | |
| echo "--- Symbols ---" | |
| nm -g "$LIB_PATH" | grep " T " | |
| - name: Analyze Dependencies and Exports (Linux) | |
| if: matrix.platform == 'Linux' | |
| shell: bash | |
| run: | | |
| LIB_PATH="runtimes/${{ matrix.rid }}/native/libminiaudio.so" | |
| echo "=== Library Information ===" | |
| file "$LIB_PATH" | |
| echo -e "\n=== Dependencies ===" | |
| if [[ "${{ matrix.arch }}" == "x86_64" ]]; then | |
| ldd "$LIB_PATH" || true | |
| else | |
| readelf -d "$LIB_PATH" | grep "NEEDED" || true | |
| fi | |
| echo -e "\n=== Symbols ===" | |
| if [[ "${{ matrix.arch }}" == "x86_64" || "${{ matrix.arch }}" == "aarch64" ]]; then | |
| nm -g "$LIB_PATH" | grep " T " || true | |
| else | |
| arm-linux-gnueabihf-nm -g "$LIB_PATH" | grep " T " || true | |
| fi | |
| echo -e "\n=== SONAME ===" | |
| readelf -d "$LIB_PATH" | grep "SONAME" || true | |
| - name: Analyze Dependencies and Exports (macOS) | |
| if: matrix.platform == 'macOS' | |
| shell: bash | |
| run: | | |
| LIB_PATH="runtimes/${{ matrix.rid }}/native/libminiaudio.dylib" | |
| echo "--- Dependencies for macOS ---" | |
| otool -L "$LIB_PATH" | |
| echo "--- Symbols ---" | |
| nm -g "$LIB_PATH" | grep " T " | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.rid }} | |
| path: runtimes/${{ matrix.rid }} | |
| package: | |
| needs: [build-freebsd-x64, build-freebsd-arm64, build] | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Create final package | |
| run: | | |
| mkdir -p runtimes | |
| cp -r artifacts/* runtimes/ | |
| zip -r native-libraries.zip runtimes | |
| - name: Upload final package | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: native-libraries | |
| path: native-libraries.zip |