Skip to content

Commit

Permalink
Publish prebuild macos xcframework
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj committed Oct 29, 2024
1 parent 36a0e78 commit a5f015c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
26 changes: 26 additions & 0 deletions .github/workflows/swift.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches:
- master
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
paths:
- './build-swift-macos.sh'
- '.github/workflows/swift.yaml'
Expand Down Expand Up @@ -65,6 +67,30 @@ jobs:
./build-swift-macos.sh
- name: Copy files
if: matrix.os == 'macos-13' && (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
shell: bash
run: |
SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-macos-xcframework-static
mkdir $dst
mv -v build-swift-macos/sherpa-onnx.xcframework $dst
brew install tree
tree $dst
tar cjvf ${dst}.tar.bz2 $dst
- name: Release pre-compiled binaries and libs for macOS
if: matrix.os == 'macos-13' && (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
uses: svenstaro/upload-release-action@v2
with:
file_glob: true
overwrite: true
file: sherpa-onnx-*macos-xcframework-static.tar.bz2

- name: test
shell: bash
run: |
Expand Down
9 changes: 9 additions & 0 deletions build-swift-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ mkdir -p $dir
cd $dir

cmake \
-DSHERPA_ONNX_ENABLE_BINARY=OFF \
-DSHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF \
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
-DCMAKE_INSTALL_PREFIX=./install \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
Expand All @@ -21,6 +24,7 @@ cmake \

make VERBOSE=1 -j4
make install
rm -fv ./install/include/cargs.h

libtool -static -o ./install/lib/libsherpa-onnx.a \
./install/lib/libsherpa-onnx-c-api.a \
Expand All @@ -34,3 +38,8 @@ libtool -static -o ./install/lib/libsherpa-onnx.a \
./install/lib/libpiper_phonemize.a \
./install/lib/libespeak-ng.a \
./install/lib/libssentencepiece_core.a

xcodebuild -create-xcframework \
-library install/lib/libsherpa-onnx.a \
-headers install/include \
-output sherpa-onnx.xcframework
1 change: 0 additions & 1 deletion sherpa-onnx/c-api/cxx-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,4 +315,3 @@ class SHERPA_ONNX_API OfflineRecognizer
} // namespace sherpa_onnx::cxx

#endif // SHERPA_ONNX_C_API_CXX_API_H_
//

0 comments on commit a5f015c

Please sign in to comment.