Skip to content

Commit e216dbc

Browse files
committed
Fixed sqlite4java native lib and added a dedicated protobuf-lite native lib
1 parent f681bc4 commit e216dbc

6 files changed

Lines changed: 30 additions & 4 deletions

File tree

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
[submodule "app/src/main/cpp/src/libs/bergamot"]
55
path = app/src/main/cpp/src/bergamot_translator/libs/bergamot
66
url = https://github.com/niedev/bergamot-translator
7+
[submodule "app/src/main/cpp/src/libs/protobuf-lite"]
8+
path = app/src/main/cpp/src/libs/protobuf-lite
9+
url = https://github.com/niedev/protobuf

.idea/vcs.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ android {
6565
}
6666
}
6767

68+
buildFeatures {
69+
prefab true
70+
}
71+
6872
buildTypes {
6973
debug {
7074
minifyEnabled false
9.39 MB
Binary file not shown.

app/src/main/cpp/src/CMakeLists.txt

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,34 @@ add_library(sentencepiece-interface SHARED SentencePieceProcessorInterface.cpp)
2121
add_library(cache_container_native SHARED CacheContainerNative.cpp)
2222
add_library(dictionary_translator_interface SHARED DictionaryTranslator.cpp protobuf/dictionary_data.pb.cc protobuf/dictionary_data.pb.h)
2323

24-
find_library(sqlite4java sqlite4java)
24+
find_package(sqlite4java-android REQUIRED CONFIG)
25+
26+
# protobuf lite import
27+
# FIND THREADS (This populates CMAKE_THREAD_LIBS_INIT) and force protobuf to use it
28+
find_package(Threads REQUIRED)
29+
add_definitions(-DHAVE_PTHREAD)
30+
# Define paths
31+
set(protobuf_source_dir "${CMAKE_CURRENT_SOURCE_DIR}/libs/protobuf-lite")
32+
set(protobuf_cmake_dir "${protobuf_source_dir}/cmake")
33+
# Protobuf Lite configuration variables
34+
# These are required by the 'libprotobuf-lite.cmake' file
35+
set(protobuf_VERSION "3.14.0")
36+
set(LIB_PREFIX "")
37+
set(protobuf_DEBUG_POSTFIX "")
38+
set(protobuf_SHARED_OR_STATIC STATIC) # Usually best to build as static for Android JNI
39+
# Include ONLY the lite library definition
40+
# This file defines the 'libprotobuf-lite' target and its source list
41+
include("${protobuf_cmake_dir}/libprotobuf-lite.cmake")
2542

2643

2744
target_include_directories(dictionary_translator_interface PRIVATE
28-
${CMAKE_CURRENT_SOURCE_DIR}/libs/sentencepiece/third_party/protobuf-lite
45+
#${CMAKE_CURRENT_SOURCE_DIR}/libs/sentencepiece/third_party/protobuf-lite
2946
${CMAKE_CURRENT_SOURCE_DIR}/sqlite4java/include
3047
)
3148

3249
target_link_libraries(dictionary_translator_interface
33-
sentencepiece-static-android
34-
sqlite4java
50+
libprotobuf-lite
51+
sqlite4java-android::sqlite4java
3552
android
3653
log
3754
)
Submodule protobuf-lite added at 31fef64

0 commit comments

Comments
 (0)