Build sherpa-onnx as a single shared library (#1078)

When `-D BUILD_SHARED_LIBS=ON` is passed to `cmake`, it builds a single shared library.

Specifically, 

- For C APIs, it builds `libsherpa-onnx-c-api.so`
- For Python APIs, it builds `_sherpa_onnx.cpython-xx-xx.so`
- For Kotlin and Java APIs, it builds `libsherpa-onnx-jni.so`

There is no `libsherpa-onnx-core.so` any longer.

Note it affects only shared libraries.
This commit is contained in:
Fangjun Kuang
2024-07-06 16:41:54 +08:00
committed by GitHub
parent 55decb7bee
commit a25075101c
69 changed files with 571 additions and 324 deletions

View File

@@ -44,7 +44,7 @@ windows_x86_wheel=$src_dir/$windows_x86_wheel_filename
windows_arm64_wheel_filename=sherpa-onnx-${SHERPA_ONNX_VERSION}-win-arm64.tar.bz2
windows_arm64_wheel=$src_dir/$windows_arm64_wheel_filename
if [ ! -f $src_dir/linux/libsherpa-onnx-core.so ]; then
if [ ! -f $src_dir/linux/libsherpa-onnx-c-api.so ]; then
echo "---linux x86_64---"
cd linux
mkdir -p wheel
@@ -57,15 +57,12 @@ if [ ! -f $src_dir/linux/libsherpa-onnx-core.so ]; then
unzip $linux_wheel_filename
cp -v sherpa_onnx/lib/*.so* ../
cd ..
rm -fv libpiper_phonemize.so libpiper_phonemize.so.1.2.0
rm -fv libonnxruntime.so
rm -fv libcargs.so
rm -rf wheel
ls -lh
cd ..
fi
if [ ! -f $src_dir/macos-x64/libsherpa-onnx-core.dylib ]; then
if [ ! -f $src_dir/macos-x64/libsherpa-onnx-c-api.dylib ]; then
echo "--- macOS x86_64---"
cd macos-x64
mkdir -p wheel
@@ -80,15 +77,12 @@ if [ ! -f $src_dir/macos-x64/libsherpa-onnx-core.dylib ]; then
cd ..
rm -fv libcargs.dylib
rm -fv libonnxruntime.dylib
rm -fv libpiper_phonemize.1.2.0.dylib libpiper_phonemize.dylib
rm -rf wheel
ls -lh
cd ..
fi
if [ ! -f $src_dir/macos-arm64/libsherpa-onnx-core.dylib ]; then
if [ ! -f $src_dir/macos-arm64/libsherpa-onnx-c-api.dylib ]; then
echo "--- macOS arm64---"
cd macos-arm64
mkdir -p wheel
@@ -103,15 +97,12 @@ if [ ! -f $src_dir/macos-arm64/libsherpa-onnx-core.dylib ]; then
cd ..
rm -fv libcargs.dylib
rm -fv libonnxruntime.dylib
rm -fv libpiper_phonemize.1.2.0.dylib libpiper_phonemize.dylib
rm -rf wheel
ls -lh
cd ..
fi
if [ ! -f $src_dir/windows-x64/sherpa-onnx-core.dll ]; then
if [ ! -f $src_dir/windows-x64/sherpa-onnx-c-api.dll ]; then
echo "---windows x64---"
cd windows-x64
mkdir -p wheel
@@ -130,7 +121,7 @@ if [ ! -f $src_dir/windows-x64/sherpa-onnx-core.dll ]; then
cd ..
fi
if [ ! -f $src_dir/windows-x86/sherpa-onnx-core.dll ]; then
if [ ! -f $src_dir/windows-x86/sherpa-onnx-c-api.dll ]; then
echo "---windows x86---"
cd windows-x86
mkdir -p wheel
@@ -149,7 +140,7 @@ if [ ! -f $src_dir/windows-x86/sherpa-onnx-core.dll ]; then
cd ..
fi
if [ ! -f $src_dir/windows-arm64/sherpa-onnx-core.dll ]; then
if [ ! -f $src_dir/windows-arm64/sherpa-onnx-c-api.dll ]; then
echo "---windows arm64---"
cd windows-arm64
mkdir -p wheel