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:
@@ -12,11 +12,31 @@
|
||||
#include "android/asset_manager_jni.h"
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#if defined(SHERPA_ONNX_BUILD_SHARED_LIBS)
|
||||
#define SHERPA_ONNX_EXPORT __declspec(dllexport)
|
||||
#define SHERPA_ONNX_IMPORT __declspec(dllimport)
|
||||
#else
|
||||
#define SHERPA_ONNX_EXPORT
|
||||
#define SHERPA_ONNX_IMPORT
|
||||
#endif
|
||||
#else // WIN32
|
||||
#define SHERPA_ONNX_EXPORT __attribute__((visibility("default")))
|
||||
|
||||
#define SHERPA_ONNX_IMPORT SHERPA_ONNX_EXPORT
|
||||
#endif // WIN32
|
||||
|
||||
#if defined(SHERPA_ONNX_BUILD_MAIN_LIB)
|
||||
#define SHERPA_ONNX_API SHERPA_ONNX_EXPORT
|
||||
#else
|
||||
#define SHERPA_ONNX_API SHERPA_ONNX_IMPORT
|
||||
#endif
|
||||
|
||||
// If you use ndk, you can find "jni.h" inside
|
||||
// android-ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include
|
||||
#include "jni.h" // NOLINT
|
||||
|
||||
#define SHERPA_ONNX_EXTERN_C extern "C"
|
||||
#define SHERPA_ONNX_EXTERN_C extern "C" SHERPA_ONNX_API
|
||||
|
||||
// defined in jni.cc
|
||||
jobject NewInteger(JNIEnv *env, int32_t value);
|
||||
|
||||
Reference in New Issue
Block a user