diff --git a/.gitmodules b/.gitmodules index a350be8..bd57cb6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -34,6 +34,9 @@ [submodule "keyman"] path = keyman url = https://github.com/keymanapp/keyman +[submodule "kyotocabinet"] + path = kyotocabinet + url = https://github.com/deepin-community/kyotocabinet [submodule "leveldb"] path = leveldb url = https://github.com/google/leveldb @@ -58,6 +61,9 @@ [submodule "libmozc"] path = libmozc url = https://github.com/fcitx-contrib/fcitx5-mozc +[submodule "libpinyin"] + path = libpinyin + url = https://github.com/libpinyin/libpinyin [submodule "librime"] path = librime url = https://github.com/rime/librime diff --git a/kyotocabinet b/kyotocabinet new file mode 160000 index 0000000..1812d35 --- /dev/null +++ b/kyotocabinet @@ -0,0 +1 @@ +Subproject commit 1812d352483494eb62ed8095ce12c1e965c3ae44 diff --git a/libpinyin b/libpinyin new file mode 160000 index 0000000..a9b614f --- /dev/null +++ b/libpinyin @@ -0,0 +1 @@ +Subproject commit a9b614ff26b7216bef5695b8f50960a459b62d1a diff --git a/patches/kyotocabinet.patch b/patches/kyotocabinet.patch new file mode 100644 index 0000000..3007115 --- /dev/null +++ b/patches/kyotocabinet.patch @@ -0,0 +1,26 @@ +diff --git a/configure b/configure +index 6447b39..64fec24 100755 +--- a/configure ++++ b/configure +@@ -2141,7 +2141,7 @@ MYPCFILES="kyotocabinet.pc" + # Building flags + MYCFLAGS="-Wall -ansi -pedantic -fPIC -fsigned-char -g0 -O2" + MYCXXFLAGS="-Wall -fPIC -fsigned-char -g0 -O2" +-MYCPPFLAGS="-I. -I\$(INCLUDEDIR) -I/usr/local/include" ++MYCPPFLAGS="-I." + MYCPPFLAGS="$MYCPPFLAGS -DNDEBUG -D_GNU_SOURCE=1" + MYCPPFLAGS="$MYCPPFLAGS -D_FILE_OFFSET_BITS=64 -D_REENTRANT -D__EXTENSIONS__" + MYLDFLAGS="-L. -L\$(LIBDIR) -L/usr/local/lib" +diff --git a/kccommon.h b/kccommon.h +index 999f37a..946b8b4 100644 +--- a/kccommon.h ++++ b/kccommon.h +@@ -190,7 +190,7 @@ using tr1::unordered_set; + #else + #define __KCFUNC__ "-" ///< for debugging + #endif +-#define _KCCODELINE_ __FILE__, __LINE__, __KCFUNC__ ///< for debugging ++#define _KCCODELINE_ __FILE_NAME__, __LINE__, __KCFUNC__ ///< for debugging + + /** + * All symbols of Kyoto Cabinet. diff --git a/patches/libpinyin.patch b/patches/libpinyin.patch new file mode 100644 index 0000000..8a897bc --- /dev/null +++ b/patches/libpinyin.patch @@ -0,0 +1,167 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 4f62a9f..0942e6b 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -15,7 +15,7 @@ + ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + ######## Project settings +-cmake_minimum_required(VERSION 2.8) ++cmake_minimum_required(VERSION 3.5) + set (PACKAGE_NAME libpinyin) + project (${PACKAGE_NAME} CXX C) + enable_testing() +@@ -24,9 +24,9 @@ enable_testing() + set (PACKAGE_URL https://github.com/libpinyin/libpinyin) + set (PACKAGE_BUGREPORT https://github.com/libpinyin/libpinyin/issues) + set (LIBPINYIN_VERSION_MAJOR 2) +-set (LIBPINYIN_VERSION_MINOR 1) +-set (LIBPINYIN_VERSION_REVISION 0) +-set (LIBPINYIN_BINARY_VERSION 13.0) ++set (LIBPINYIN_VERSION_MINOR 11) ++set (LIBPINYIN_VERSION_REVISION 91) ++set (LIBPINYIN_BINARY_VERSION 15.0) + + if (CMAKE_BUILD_TYPE MATCHES Debug) + set (version_suffix .Debug) +@@ -79,14 +79,12 @@ endif (DB_FOUND) + if (NOT HAVE_BERKELEY_DB) + # DBM: Kyoto Cabinet + find_package(KyotoCabinet) +- if (KyotoCabinet_FOUND) + include_directories ( ${KyotoCabinet_INCLUDE_PATH} ) + SET (LIBS ${LIBS} ${KyotoCabinet_LIBRARY}) + SET (HAVE_KYOTO_CABINET 1) + SET (DATABASE_FORMAT "KyotoCabinet") + SET (CMAKE_CXX_LINK_EXECUTABLE + "${CMAKE_CXX_LINK_EXECUTABLE} ${LIBS}") +- endif (KyotoCabinet_FOUND) + endif (NOT HAVE_BERKELEY_DB) + + +@@ -141,6 +139,12 @@ configure_file( + @ONLY + ) + ++configure_file( ++ libzhuyin.pc.in ++ libzhuyin.pc ++ @ONLY ++) ++ + configure_file( + config.h.cmake + config.h +@@ -150,6 +154,7 @@ configure_file( + install( + FILES + ${CMAKE_BINARY_DIR}/libpinyin.pc ++ ${CMAKE_BINARY_DIR}/libzhuyin.pc + DESTINATION + ${DIR_LIBRARY}/pkgconfig + ) +@@ -178,6 +183,3 @@ include_directories( + ######## Subdirectories + + add_subdirectory(src) +-add_subdirectory(tests) +-add_subdirectory(utils) +-add_subdirectory(data) +diff --git a/libzhuyin.pc.in b/libzhuyin.pc.in +index f248d1c..0e6b944 100644 +--- a/libzhuyin.pc.in ++++ b/libzhuyin.pc.in +@@ -11,5 +11,5 @@ Name: libzhuyin + Description: Library to deal with zhuyin + Version: @VERSION@ + Requires: glib-2.0 +-Libs: -L${libdir} -lzhuyin ++Libs: -L${libdir} -lpinyin + Cflags: -I${libzhuyinincludedir} +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index fe16a66..f8a496f 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -10,8 +10,8 @@ set( + + add_library( + pinyin +- SHARED + ${LIBPINYIN_SOURCES} ++ zhuyin.cpp + ) + + target_link_libraries( +@@ -41,6 +41,7 @@ install( + install( + FILES + ${LIBPINYIN_HEADERS} ++ zhuyin.h + DESTINATION + ${DIR_INCLUDE_LIBPINYIN} + ) +diff --git a/src/lookup/CMakeLists.txt b/src/lookup/CMakeLists.txt +index 767748c..77da8b1 100644 +--- a/src/lookup/CMakeLists.txt ++++ b/src/lookup/CMakeLists.txt +@@ -12,7 +12,7 @@ set( + + add_library( + lookup +- STATIC ++ OBJECT + ${LIBLOOKUP_SOURCES} + ) + +diff --git a/src/storage/CMakeLists.txt b/src/storage/CMakeLists.txt +index 26330e0..da215d7 100644 +--- a/src/storage/CMakeLists.txt ++++ b/src/storage/CMakeLists.txt +@@ -45,7 +45,7 @@ endif (HAVE_KYOTO_CABINET) + + add_library( + storage +- STATIC ++ OBJECT + ${LIBSTORAGE_SOURCES} + ) + +@@ -58,6 +58,7 @@ target_link_libraries( + install( + FILES + ${LIBSTORAGE_HEADERS} ++ zhuyin_custom2.h + DESTINATION + ${DIR_INCLUDE_LIBPINYIN} + ) +diff --git a/src/zhuyin.cpp b/src/zhuyin.cpp +index 1aeecf5..a4d868b 100644 +--- a/src/zhuyin.cpp ++++ b/src/zhuyin.cpp +@@ -1127,7 +1127,7 @@ static gint compare_item_with_token(gconstpointer lhs, + #endif + + static gint compare_item_with_length_and_frequency(gconstpointer lhs, +- gconstpointer rhs) { ++ gconstpointer rhs, void *) { + lookup_candidate_t * item_lhs = (lookup_candidate_t *)lhs; + lookup_candidate_t * item_rhs = (lookup_candidate_t *)rhs; + +@@ -1526,7 +1526,7 @@ bool zhuyin_guess_candidates_after_cursor(zhuyin_instance_t * instance, + _compute_frequency_of_items(context, prev_token, &merged_gram, candidates); + + /* sort the candidates by length and frequency. */ +- g_array_sort(candidates, compare_item_with_length_and_frequency); ++ g_array_sort(candidates, (GCompareFunc)compare_item_with_length_and_frequency); + + /* post process to remove duplicated candidates */ + +@@ -1607,7 +1607,7 @@ bool zhuyin_guess_candidates_before_cursor(zhuyin_instance_t * instance, + _compute_frequency_of_items(context, prev_token, &merged_gram, items); + + /* sort the items by length and frequency. */ +- g_array_sort(items, compare_item_with_length_and_frequency); ++ g_array_sort(items, (GCompareFunc)compare_item_with_length_and_frequency); + + g_array_append_vals(candidates, items->data, items->len); + diff --git a/scripts/common.py b/scripts/common.py index e23f46e..35a4445 100644 --- a/scripts/common.py +++ b/scripts/common.py @@ -355,6 +355,8 @@ def install(self): class MakeBuilder(Builder): + target = '' + def configure(self): command = './configure' if PLATFORM == 'js': @@ -365,6 +367,7 @@ def configure(self): '--enable-static', '--disable-shared', *self.options, + *(self.js if PLATFORM == 'js' else []), f'PKG_CONFIG_SYSROOT_DIR={PKG_CONFIG_SYSROOT_DIR}', f'PKG_CONFIG_PATH={PKG_CONFIG_PATH}', f'XDG_DATA_DIRS={XDG_DATA_DIRS}' @@ -373,6 +376,7 @@ def configure(self): def build(self): ensure('make', [ '-j8', + self.target, f'CFLAGS="{get_platform_cflags()}"', f'CXXFLAGS="{get_platform_cflags()}"' ]) diff --git a/scripts/dependencies.py b/scripts/dependencies.py index bef2b7c..6575d81 100644 --- a/scripts/dependencies.py +++ b/scripts/dependencies.py @@ -4,6 +4,7 @@ 'json-glib': ['glib'], 'libgee': ['glib'], 'libkkc': ['json-glib', 'libgee', 'marisa'], + 'libpinyin': ['glib', 'kyotocabinet'], 'librime': ['boost', 'glog', 'leveldb', 'lua', 'marisa', 'opencc', 'yaml-cpp'], 'libskk': ['json-glib', 'libgee', 'libxkbcommon'], 'opencc': ['marisa'], @@ -21,6 +22,7 @@ 'json', 'json-glib', 'keyman-core', + 'kyotocabinet', 'leveldb', 'libchewing', 'libexpat', @@ -29,6 +31,7 @@ 'libintl', 'libkkc', 'libmozc', + 'libpinyin', 'librime', 'libskk', 'libthai', @@ -102,6 +105,7 @@ 'json', 'json-glib', 'keyman-core', + 'kyotocabinet', 'leveldb', 'libchewing', 'libexpat', @@ -109,6 +113,7 @@ 'libhangul', 'libkkc', 'libmozc', + 'libpinyin', 'librime', 'libskk', 'libthai', diff --git a/scripts/kyotocabinet.py b/scripts/kyotocabinet.py new file mode 100644 index 0000000..e9d7dd0 --- /dev/null +++ b/scripts/kyotocabinet.py @@ -0,0 +1,20 @@ +from common import INSTALL_PREFIX, MakeBuilder, ensure, patch + + +project = 'kyotocabinet' +patch(project) # hard-coded include directory + +class KyotoCabinetBuilder(MakeBuilder): + target = 'libkyotocabinet.a' + + def install(self): + usr = f'{self.dest_dir}{INSTALL_PREFIX}' + include_dir = f'{usr}/include' + lib_dir = f'{usr}/lib' + pkgconfig_dir = f'{lib_dir}/pkgconfig' + ensure('mkdir', ['-p', include_dir, pkgconfig_dir]) + ensure('cp', ['k*.h', include_dir]) + ensure('cp', [self.target, lib_dir]) + ensure('cp', ['kyotocabinet.pc', pkgconfig_dir]) + +KyotoCabinetBuilder(project, js=['--disable-zlib']).exec() diff --git a/scripts/libpinyin.py b/scripts/libpinyin.py new file mode 100644 index 0000000..9f09ee4 --- /dev/null +++ b/scripts/libpinyin.py @@ -0,0 +1,6 @@ +from common import CMakeBuilder, patch + +project = 'libpinyin' +patch(project) + +CMakeBuilder(project).exec()