-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4def00b
commit 6b24896
Showing
7 changed files
with
253 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule fcitx5-chinese-addons
added at
64e2a0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,225 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index b8b59ad..85625da 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -8,6 +8,12 @@ include(GNUInstallDirs) | ||
include(ECMSetupVersion) | ||
include(ECMUninstallTarget) | ||
|
||
+set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE) | ||
+set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-sSIDE_MODULE") | ||
+set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-sSIDE_MODULE") | ||
+ | ||
+add_compile_options(-fPIC -fexceptions) | ||
+ | ||
find_package(Fcitx5Core 5.1.11 REQUIRED) | ||
find_package(Fcitx5Module REQUIRED COMPONENTS Notifications QuickPhrase Spell Clipboard) | ||
find_package(Fcitx5ModuleLuaAddonLoader) | ||
@@ -22,7 +28,7 @@ else() | ||
set(FMT_TARGET fmt::fmt) | ||
endif () | ||
|
||
-include("${FCITX_INSTALL_CMAKECONFIG_DIR}/Fcitx5Utils/Fcitx5CompilerSettings.cmake") | ||
+include("../build/sysroot${FCITX_INSTALL_CMAKECONFIG_DIR}/Fcitx5Utils/Fcitx5CompilerSettings.cmake") | ||
|
||
####################################################################### | ||
# Options | ||
@@ -67,6 +73,9 @@ find_package(Boost 1.61 REQUIRED COMPONENTS iostreams OPTIONAL_COMPONENTS json) | ||
find_package(LibIMEPinyin 1.1.7 REQUIRED) | ||
find_package(LibIMETable 1.1.4 REQUIRED) | ||
|
||
+pkg_check_modules(ZSTD REQUIRED IMPORTED_TARGET "libzstd") | ||
+set(LIBIME_INSTALL_PKGDATADIR "../libime") | ||
+ | ||
if (ENABLE_CLOUDPINYIN) | ||
pkg_check_modules(Curl REQUIRED IMPORTED_TARGET "libcurl") | ||
endif() | ||
@@ -85,7 +94,6 @@ fcitx5_add_i18n_definition() | ||
add_subdirectory(modules) | ||
add_subdirectory(im) | ||
add_subdirectory(po) | ||
-add_subdirectory(tools) | ||
|
||
if (ENABLE_GUI) | ||
add_subdirectory(gui) | ||
diff --git a/im/pinyin/CMakeLists.txt b/im/pinyin/CMakeLists.txt | ||
index 888c23c..798f4d9 100644 | ||
--- a/im/pinyin/CMakeLists.txt | ||
+++ b/im/pinyin/CMakeLists.txt | ||
@@ -7,7 +7,7 @@ set(PINYIN_SOURCES | ||
) | ||
|
||
add_library(pinyin MODULE ${PINYIN_SOURCES}) | ||
-target_link_libraries(pinyin Fcitx5::Core Fcitx5::Config LibIME::Pinyin Boost::iostreams Fcitx5::Module::Punctuation Fcitx5::Module::QuickPhrase Fcitx5::Module::Notifications Fcitx5::Module::Spell Fcitx5::Module::PinyinHelper Pthread::Pthread ${FMT_TARGET}) | ||
+target_link_libraries(pinyin -fexceptions Fcitx5::Core Fcitx5::Config LibIME::Pinyin Fcitx5::Module::Punctuation Fcitx5::Module::QuickPhrase Fcitx5::Module::Notifications Fcitx5::Module::Spell Fcitx5::Module::PinyinHelper Pthread::Pthread ${FMT_TARGET}) | ||
|
||
if (TARGET Fcitx5::Module::LuaAddonLoader) | ||
target_compile_definitions(pinyin PRIVATE -DFCITX_HAS_LUA) | ||
diff --git a/im/pinyin/pinyin.cpp b/im/pinyin/pinyin.cpp | ||
index 439574c..9102dac 100644 | ||
--- a/im/pinyin/pinyin.cpp | ||
+++ b/im/pinyin/pinyin.cpp | ||
@@ -658,8 +658,7 @@ std::string PinyinEngine::evaluateCustomPhrase(InputContext *inputContext, | ||
|
||
PinyinEngine::PinyinEngine(Instance *instance) | ||
: instance_(instance), | ||
- factory_([this](InputContext &) { return new PinyinState(this); }), | ||
- worker_(instance->eventDispatcher()) { | ||
+ factory_([this](InputContext &) { return new PinyinState(this); }) { | ||
ime_ = std::make_unique<libime::PinyinIME>( | ||
std::make_unique<libime::PinyinDictionary>(), | ||
std::make_unique<libime::UserLanguageModel>( | ||
@@ -828,25 +827,18 @@ void PinyinEngine::loadDict(const std::string &fullPath, | ||
} | ||
ime_->dict()->addEmptyDict(); | ||
PINYIN_DEBUG() << "Loading pinyin dict " << fullPath; | ||
- std::packaged_task<libime::PinyinDictionary::TrieType()> task([fullPath]() { | ||
- std::ifstream in(fullPath, std::ios::in | std::ios::binary); | ||
- auto trie = libime::PinyinDictionary::load( | ||
- in, libime::PinyinDictFormat::Binary); | ||
- return trie; | ||
- }); | ||
- taskTokens.push_back(worker_.addTask( | ||
- std::move(task), | ||
- [this, index = ime_->dict()->dictSize() - 1, fullPath]( | ||
- std::shared_future<libime::PinyinDictionary::TrieType> &future) { | ||
- try { | ||
- PINYIN_DEBUG() | ||
- << "Load pinyin dict " << fullPath << " finished."; | ||
- ime_->dict()->setTrie(index, future.get()); | ||
- } catch (const std::exception &e) { | ||
- PINYIN_ERROR() << "Failed to load pinyin dict " << fullPath | ||
- << ": " << e.what(); | ||
- } | ||
- })); | ||
+ std::ifstream in(fullPath, std::ios::in | std::ios::binary); | ||
+ auto trie = libime::PinyinDictionary::load( | ||
+ in, libime::PinyinDictFormat::Binary); | ||
+ auto index = ime_->dict()->dictSize() - 1; | ||
+ try { | ||
+ PINYIN_DEBUG() | ||
+ << "Load pinyin dict " << fullPath << " finished."; | ||
+ ime_->dict()->setTrie(index, trie); | ||
+ } catch (const std::exception &e) { | ||
+ PINYIN_ERROR() << "Failed to load pinyin dict " << fullPath | ||
+ << ": " << e.what(); | ||
+ } | ||
} | ||
|
||
void PinyinEngine::loadBuiltInDict() { | ||
diff --git a/im/pinyin/pinyin.h b/im/pinyin/pinyin.h | ||
index 9884c8d..3767e70 100644 | ||
--- a/im/pinyin/pinyin.h | ||
+++ b/im/pinyin/pinyin.h | ||
@@ -447,7 +447,6 @@ private: | ||
std::unique_ptr<HandlerTableEntry<EventHandler>> event_; | ||
CustomPhraseDict customPhrase_; | ||
SymbolDict symbols_; | ||
- WorkerThread worker_; | ||
std::list<std::unique_ptr<TaskToken>> persistentTask_; | ||
std::list<std::unique_ptr<TaskToken>> tasks_; | ||
|
||
diff --git a/im/table/CMakeLists.txt b/im/table/CMakeLists.txt | ||
index 91ed495..e5640bf 100644 | ||
--- a/im/table/CMakeLists.txt | ||
+++ b/im/table/CMakeLists.txt | ||
@@ -6,7 +6,7 @@ set(TABLE_SOURCES | ||
candidate.cpp | ||
) | ||
add_library(table MODULE ${TABLE_SOURCES}) | ||
-target_link_libraries(table Fcitx5::Core Fcitx5::Config LibIME::Table LibIME::Pinyin Boost::iostreams Fcitx5::Module::Punctuation Fcitx5::Module::QuickPhrase Fcitx5::Module::PinyinHelper LibIME::Pinyin ${FMT_TARGET}) | ||
+target_link_libraries(table -fexceptions Fcitx5::Core Fcitx5::Config LibIME::Table LibIME::Pinyin Fcitx5::Module::Punctuation Fcitx5::Module::QuickPhrase Fcitx5::Module::PinyinHelper ${FMT_TARGET}) | ||
target_compile_definitions(table PRIVATE FCITX_STRINGUTILS_ENABLE_BOOST_STRING_VIEW) | ||
install(TARGETS table DESTINATION "${CMAKE_INSTALL_LIBDIR}/fcitx5") | ||
configure_file(table.conf.in.in table.conf.in) | ||
diff --git a/modules/chttrans/CMakeLists.txt b/modules/chttrans/CMakeLists.txt | ||
index 14351c8..631be74 100644 | ||
--- a/modules/chttrans/CMakeLists.txt | ||
+++ b/modules/chttrans/CMakeLists.txt | ||
@@ -5,7 +5,7 @@ if (ENABLE_OPENCC) | ||
set(CHTTRANS_SOURCES ${CHTTRANS_SOURCES} chttrans-opencc.cpp) | ||
endif() | ||
add_library(chttrans MODULE ${CHTTRANS_SOURCES}) | ||
-target_link_libraries(chttrans Fcitx5::Core Fcitx5::Config Fcitx5::Module::Notifications Boost::iostreams ${FMT_TARGET}) | ||
+target_link_libraries(chttrans -fexceptions Fcitx5::Core Fcitx5::Config Fcitx5::Module::Notifications Boost::iostreams ${FMT_TARGET}) | ||
if (ENABLE_OPENCC) | ||
target_link_libraries(chttrans OpenCC::OpenCC) | ||
if (TARGET Boost::json) | ||
diff --git a/modules/pinyinhelper/CMakeLists.txt b/modules/pinyinhelper/CMakeLists.txt | ||
index a2ca5d9..8619ff9 100644 | ||
--- a/modules/pinyinhelper/CMakeLists.txt | ||
+++ b/modules/pinyinhelper/CMakeLists.txt | ||
@@ -5,6 +5,7 @@ set(PINYINHELPER_SOURCES | ||
) | ||
add_library(pinyinhelper MODULE ${PINYINHELPER_SOURCES}) | ||
target_link_libraries(pinyinhelper | ||
+-fexceptions | ||
Fcitx5::Core | ||
Fcitx5::Config | ||
LibIME::Core | ||
diff --git a/modules/pinyinhelper/stroke.cpp b/modules/pinyinhelper/stroke.cpp | ||
index 2e1dffa..4f8129e 100644 | ||
--- a/modules/pinyinhelper/stroke.cpp | ||
+++ b/modules/pinyinhelper/stroke.cpp | ||
@@ -25,11 +25,11 @@ namespace fcitx { | ||
Stroke::Stroke() {} | ||
|
||
void Stroke::loadAsync() { | ||
- if (loadFuture_.valid()) { | ||
+ if (loaded_) { | ||
return; | ||
} | ||
|
||
- loadFuture_ = std::async(std::launch::async, []() { | ||
+ loadFuture_ = ([]() { | ||
std::tuple<libime::DATrie<int32_t>, libime::DATrie<int32_t>> result; | ||
auto &dict = std::get<0>(result); | ||
auto &reverseDict = std::get<1>(result); | ||
@@ -80,18 +80,16 @@ void Stroke::loadAsync() { | ||
reverseDict.shrink_tail(); | ||
|
||
return result; | ||
- }); | ||
+ })(); | ||
} | ||
|
||
bool Stroke::load() { | ||
if (loaded_) { | ||
return loadResult_; | ||
} | ||
- if (!loadFuture_.valid()) { | ||
- loadAsync(); | ||
- } | ||
+ loadAsync(); | ||
try { | ||
- std::tie(dict_, revserseDict_) = loadFuture_.get(); | ||
+ std::tie(dict_, revserseDict_) = loadFuture_; | ||
loadResult_ = true; | ||
} catch (...) { | ||
loadResult_ = false; | ||
diff --git a/modules/pinyinhelper/stroke.h b/modules/pinyinhelper/stroke.h | ||
index 048e2a0..009c496 100644 | ||
--- a/modules/pinyinhelper/stroke.h | ||
+++ b/modules/pinyinhelper/stroke.h | ||
@@ -33,7 +33,7 @@ private: | ||
bool loaded_ = false; | ||
bool loadResult_ = false; | ||
|
||
- std::future<std::tuple<libime::DATrie<int32_t>, libime::DATrie<int32_t>>> | ||
+ std::tuple<libime::DATrie<int32_t>, libime::DATrie<int32_t>> | ||
loadFuture_; | ||
}; | ||
} // namespace fcitx | ||
diff --git a/modules/punctuation/CMakeLists.txt b/modules/punctuation/CMakeLists.txt | ||
index 2de1433..c19dda4 100644 | ||
--- a/modules/punctuation/CMakeLists.txt | ||
+++ b/modules/punctuation/CMakeLists.txt | ||
@@ -9,7 +9,7 @@ set(PUNCTUATION_DATA_FILES | ||
) | ||
|
||
add_library(punctuation MODULE ${PUNCTUATION_SOURCES}) | ||
-target_link_libraries(punctuation Fcitx5::Core Fcitx5::Config Boost::iostreams Fcitx5::Module::Notifications) | ||
+target_link_libraries(punctuation -fexceptions Fcitx5::Core Fcitx5::Config Boost::iostreams Fcitx5::Module::Notifications) | ||
install(TARGETS punctuation DESTINATION "${CMAKE_INSTALL_LIBDIR}/fcitx5") | ||
configure_file(punctuation.conf.in.in punctuation.conf.in) | ||
fcitx5_translate_desktop_file("${CMAKE_CURRENT_BINARY_DIR}/punctuation.conf.in" punctuation.conf) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from common import Builder, ensure | ||
|
||
src = 'build/sysroot/usr' | ||
dst = 'build/chinese-addons/usr' | ||
ensure('mkdir', ['-p', f'{dst}/lib']) | ||
ensure('mkdir', ['-p', f'{dst}/share']) | ||
ensure('cp', ['-r', f'{src}/lib/libime', f'{dst}/lib']) | ||
ensure('cp', ['-r', f'{src}/share/libime', f'{dst}/share']) | ||
ensure('cp', ['-r', f'{src}/share/opencc', f'{dst}/share']) | ||
|
||
Builder('chinese-addons', [ | ||
'-DENABLE_CLOUDPINYIN=OFF', | ||
'-DENABLE_TEST=OFF', | ||
'-DENABLE_GUI=OFF' | ||
]).exec() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters