Spaces:
Running
Running
whisper.android : fix cmake multiple libraries build (#1224)
Browse files* whisper.android : fix multiple libraries build
* fix flags for default target
examples/whisper.android/app/build.gradle
CHANGED
|
@@ -19,7 +19,7 @@ android {
|
|
| 19 |
useSupportLibrary true
|
| 20 |
}
|
| 21 |
ndk {
|
| 22 |
-
abiFilters 'arm64-v8a', 'armeabi-v7a'
|
| 23 |
}
|
| 24 |
}
|
| 25 |
|
|
|
|
| 19 |
useSupportLibrary true
|
| 20 |
}
|
| 21 |
ndk {
|
| 22 |
+
abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64'
|
| 23 |
}
|
| 24 |
}
|
| 25 |
|
examples/whisper.android/app/src/main/jni/whisper/CMakeLists.txt
CHANGED
|
@@ -12,33 +12,42 @@ set(
|
|
| 12 |
${CMAKE_SOURCE_DIR}/jni.c
|
| 13 |
)
|
| 14 |
|
| 15 |
-
|
| 16 |
-
set(WHISPER_LIBRARY_NAME whisper_v8fp16_va)
|
| 17 |
-
elseif (${ANDROID_ABI} STREQUAL "armeabi-v7a")
|
| 18 |
-
set(WHISPER_LIBRARY_NAME whisper_vfpv4)
|
| 19 |
-
endif ()
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
|
|
|
| 23 |
SHARED
|
| 24 |
${SOURCE_FILES}
|
| 25 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
if (${ANDROID_ABI} STREQUAL "arm64-v8a")
|
| 28 |
-
|
| 29 |
elseif (${ANDROID_ABI} STREQUAL "armeabi-v7a")
|
| 30 |
-
|
| 31 |
endif ()
|
| 32 |
|
| 33 |
-
|
| 34 |
-
target_link_libraries(${WHISPER_LIBRARY_NAME} log android)
|
| 35 |
include_directories(${WHISPER_LIB_DIR})
|
| 36 |
-
|
| 37 |
-
if (NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug")
|
| 38 |
-
target_compile_options(${WHISPER_LIBRARY_NAME} PRIVATE -O3)
|
| 39 |
-
target_compile_options(${WHISPER_LIBRARY_NAME} PRIVATE -fvisibility=hidden -fvisibility-inlines-hidden)
|
| 40 |
-
target_compile_options(${WHISPER_LIBRARY_NAME} PRIVATE -ffunction-sections -fdata-sections)
|
| 41 |
-
target_link_options(${WHISPER_LIBRARY_NAME} PRIVATE -Wl,--gc-sections)
|
| 42 |
-
target_link_options(${WHISPER_LIBRARY_NAME} PRIVATE -Wl,--exclude-libs,ALL)
|
| 43 |
-
target_link_options(${WHISPER_LIBRARY_NAME} PRIVATE -flto)
|
| 44 |
-
endif ()
|
|
|
|
| 12 |
${CMAKE_SOURCE_DIR}/jni.c
|
| 13 |
)
|
| 14 |
|
| 15 |
+
find_library(LOG_LIB log)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
+
function(build_library target_name)
|
| 18 |
+
add_library(
|
| 19 |
+
${target_name}
|
| 20 |
SHARED
|
| 21 |
${SOURCE_FILES}
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
target_link_libraries(${target_name} ${LOG_LIB} android)
|
| 25 |
+
|
| 26 |
+
if (${target_name} STREQUAL "whisper_v8fp16_va")
|
| 27 |
+
target_compile_options(${target_name} PRIVATE -march=armv8.2-a+fp16)
|
| 28 |
+
elseif (${target_name} STREQUAL "whisper_vfpv4")
|
| 29 |
+
target_compile_options(${target_name} PRIVATE -mfpu=neon-vfpv4)
|
| 30 |
+
endif ()
|
| 31 |
+
|
| 32 |
+
if (NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug")
|
| 33 |
+
|
| 34 |
+
target_compile_options(${target_name} PRIVATE -O3)
|
| 35 |
+
target_compile_options(${target_name} PRIVATE -fvisibility=hidden -fvisibility-inlines-hidden)
|
| 36 |
+
target_compile_options(${target_name} PRIVATE -ffunction-sections -fdata-sections)
|
| 37 |
+
|
| 38 |
+
target_link_options(${target_name} PRIVATE -Wl,--gc-sections)
|
| 39 |
+
target_link_options(${target_name} PRIVATE -Wl,--exclude-libs,ALL)
|
| 40 |
+
target_link_options(${target_name} PRIVATE -flto)
|
| 41 |
+
|
| 42 |
+
endif ()
|
| 43 |
+
endfunction()
|
| 44 |
+
|
| 45 |
+
build_library("whisper") # Default target
|
| 46 |
|
| 47 |
if (${ANDROID_ABI} STREQUAL "arm64-v8a")
|
| 48 |
+
build_library("whisper_v8fp16_va")
|
| 49 |
elseif (${ANDROID_ABI} STREQUAL "armeabi-v7a")
|
| 50 |
+
build_library("whisper_vfpv4")
|
| 51 |
endif ()
|
| 52 |
|
|
|
|
|
|
|
| 53 |
include_directories(${WHISPER_LIB_DIR})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|