Skip to content

Commit

Permalink
misc: add support for ios simulator platform
Browse files Browse the repository at this point in the history
  • Loading branch information
jsm174 committed Jun 25, 2024
1 parent 9ac08a7 commit f11354c
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 11 deletions.
20 changes: 15 additions & 5 deletions .github/workflows/libaltsound.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ jobs:
- os: macos-latest
platform: ios
arch: arm64
- os: macos-latest
platform: ios-simulator
arch: arm64
- os: macos-latest
platform: tvos
arch: arm64
Expand All @@ -80,7 +83,11 @@ jobs:
else
NUM_PROCS=$(nproc)
fi
cmake -DCMAKE_BUILD_TYPE=Release -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} -B build
if [[ "${{ matrix.platform }}" == "tvos" ]]; then
cmake -DCMAKE_BUILD_TYPE=Release -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} -DBUILD_SHARED=OFF -B build
else
cmake -DCMAKE_BUILD_TYPE=Release -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} -B build
fi
cmake --build build -- -j${NUM_PROCS}
fi
- if: (matrix.platform == 'linux' && matrix.arch == 'aarch64')
Expand Down Expand Up @@ -131,9 +138,11 @@ jobs:
cp build/libbass.so tmp
cp build/altsound_test_s tmp
cp build/altsound_test tmp
elif [[ "${{ matrix.platform }}" == "ios" || "${{ matrix.platform }}" == "tvos" ]]; then
elif [[ "${{ matrix.platform }}" == "ios" || "${{ matrix.platform }}" == "ios-simulator" ]]; then
cp build/libaltsound.a tmp
cp build/libaltsound.*.dylib tmp
elif [[ "${{ matrix.platform }}" == "tvos" ]]; then
cp build/libaltsound.a tmp
elif [[ "${{ matrix.platform }}" == "android" ]]; then
cp build/libaltsound.a tmp
cp build/libaltsound.so tmp
Expand All @@ -143,7 +152,7 @@ jobs:
fi
echo "artifact_path=${ARTIFACT_PATH}" >> $GITHUB_OUTPUT
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: libaltsound-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}
path: ${{ steps.artifacts.outputs.artifact_path }}
Expand All @@ -153,7 +162,7 @@ jobs:
needs: [ version, build ]
name: Build libaltsound-macos
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
- name: Unpack artifacts
run: |
cd libaltsound-${{ needs.version.outputs.tag }}-macos-x64
Expand All @@ -178,7 +187,7 @@ jobs:
cd tmp
tar -czvf ../libaltsound-${{ needs.version.outputs.tag }}-macos.tar.gz *
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: libaltsound-${{ needs.version.outputs.tag }}-macos
path: libaltsound-${{ needs.version.outputs.tag }}-macos.tar.gz
Expand All @@ -201,5 +210,6 @@ jobs:
libaltsound-${{ needs.version.outputs.tag }}-linux-x64/libaltsound-${{ needs.version.outputs.tag }}-linux-x64.tar.gz
libaltsound-${{ needs.version.outputs.tag }}-linux-aarch64/libaltsound-${{ needs.version.outputs.tag }}-linux-aarch64.tar.gz
libaltsound-${{ needs.version.outputs.tag }}-ios-arm64/libaltsound-${{ needs.version.outputs.tag }}-ios-arm64.tar.gz
libaltsound-${{ needs.version.outputs.tag }}-ios-simulator-arm64/libaltsound-${{ needs.version.outputs.tag }}-ios-simulator-arm64.tar.gz
libaltsound-${{ needs.version.outputs.tag }}-tvos-arm64/libaltsound-${{ needs.version.outputs.tag }}-tvos-arm64.tar.gz
libaltsound-${{ needs.version.outputs.tag }}-android-arm64-v8a/libaltsound-${{ needs.version.outputs.tag }}-android-arm64-v8a.tar.gz
20 changes: 16 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,17 @@ message(STATUS "ARCH: ${ARCH}")
message(STATUS "BUILD_SHARED: ${BUILD_SHARED}")
message(STATUS "BUILD_STATIC: ${BUILD_STATIC}")

if(PLATFORM STREQUAL "ios")
if(PLATFORM STREQUAL "macos")
set(CMAKE_OSX_DEPLOYMENT_TARGET 14.0)
elseif(PLATFORM STREQUAL "ios" OR PLATFORM STREQUAL "ios-simulator")
set(CMAKE_SYSTEM_NAME iOS)
if (PLATFORM STREQUAL "ios-simulator")
set(CMAKE_OSX_SYSROOT iphonesimulator)
endif()
set(CMAKE_OSX_DEPLOYMENT_TARGET 17.0)
elseif(PLATFORM STREQUAL "tvos")
set(CMAKE_SYSTEM_NAME tvOS)
set(CMAKE_OSX_DEPLOYMENT_TARGET 17.0)
elseif(PLATFORM STREQUAL "android")
set(CMAKE_SYSTEM_NAME Android)
set(CMAKE_SYSTEM_VERSION 30)
Expand All @@ -41,8 +48,7 @@ if(PLATFORM STREQUAL "macos")
endif()
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "@executable_path")
elseif(PLATFORM STREQUAL "ios" OR PLATFORM STREQUAL "tvos")
set(CMAKE_OSX_DEPLOYMENT_TARGET 16.0)
elseif(PLATFORM STREQUAL "ios" OR PLATFORM STREQUAL "ios-simulator" OR PLATFORM STREQUAL "tvos")
set(CMAKE_OSX_ARCHITECTURES arm64)
elseif(PLATFORM STREQUAL "linux" OR PLATFORM STREQUAL "android")
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
Expand Down Expand Up @@ -102,7 +108,13 @@ if(BUILD_SHARED)
third-party/runtime-libs/${PLATFORM}/${ARCH}
)
target_link_libraries(altsound_shared PUBLIC bass)
elseif(PLATFORM STREQUAL "ios" OR PLATFORM STREQUAL "tvos")
elseif(PLATFORM STREQUAL "ios" OR PLATFORM STREQUAL "ios-simulator")
target_link_directories(altsound_shared PUBLIC
third-party/build-libs/${PLATFORM}/${ARCH}
third-party/runtime-libs/${PLATFORM}/${ARCH}
)
target_link_libraries(altsound_shared PUBLIC bass)
elseif(PLATFORM STREQUAL "tvos")
target_link_options(altsound_shared PUBLIC "-Wl,-F${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/frameworks")
target_link_libraries(altsound_shared PUBLIC "-framework bass")
else()
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,17 @@ cmake -DPLATFORM=ios -DARCH=arm64 -DCMAKE_BUILD_TYPE=Release -B build
cmake --build build
```

#### iOS Simulator (arm64)
```shell
platforms/ios-simulator/arm64/external.sh
cmake -DPLATFORM=ios-simulator -DARCH=arm64 -DCMAKE_BUILD_TYPE=Release -B build
cmake --build build
```

#### tvOS (arm64)
```shell
platforms/tvos/arm64/external.sh
cmake -DPLATFORM=tvos -DARCH=arm64 -DCMAKE_BUILD_TYPE=Release -B build
cmake -DPLATFORM=tvos -DARCH=arm64 -DBUILD_SHARED=OFF -DCMAKE_BUILD_TYPE=Release -B build
cmake --build build
```

Expand Down
21 changes: 21 additions & 0 deletions platforms/ios-simulator/arm64/external.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

set -e

rm -rf external
mkdir external
cd external

#
# download bass24 framework and copy to platform/arch/lib
#

mkdir bass
cd bass
curl -s https://www.un4seen.com/files/bass24-ios.zip -o bass.zip
unzip bass.zip
cp bass.h ../../third-party/include
lipo bass.xcframework/ios-arm64_i386_x86_64-simulator/bass.framework/bass -extract arm64 -output libbass.dylib
install_name_tool -id @rpath/libbass.dylib libbass.dylib
codesign --remove-signature libbass.dylib
cp libbass.dylib ../../third-party/runtime-libs/ios-simulator/arm64/libbass.dylib
5 changes: 4 additions & 1 deletion platforms/ios/arm64/external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ cd bass
curl -s https://www.un4seen.com/files/bass24-ios.zip -o bass.zip
unzip bass.zip
cp bass.h ../../third-party/include
cp -r bass.xcframework/ios-arm64_armv7_armv7s/bass.framework ../../third-party/runtime-libs/ios/arm64/frameworks
lipo bass.xcframework/ios-arm64_armv7_armv7s/bass.framework/bass -extract arm64 -output libbass.dylib
install_name_tool -id @rpath/libbass.dylib libbass.dylib
codesign --remove-signature libbass.dylib
cp libbass.dylib ../../third-party/runtime-libs/ios/arm64/libbass.dylib
3 changes: 3 additions & 0 deletions platforms/tvos/arm64/external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ cd external
#
# download bass24 framework and copy to platform/arch/frameworks
#
# Note: The BASS library needs to be replaced with the tvOS version.
# Leaving the iOS version here so we can test the compile for static builds. Shared builds will fail when linking.
#

mkdir bass
cd bass
Expand Down
Empty file.

0 comments on commit f11354c

Please sign in to comment.