Skip to content

Commit 0f74d4c

Browse files
authored
zhuyin !windows (#243)
1 parent ef27e9d commit 0f74d4c

File tree

11 files changed

+117
-1
lines changed

11 files changed

+117
-1
lines changed

.github/workflows/js.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ jobs:
6464
git apply --directory=fcitx5-rime patches/rime.log.patch
6565
git apply --directory=fcitx5-rime patches/rime.js.patch
6666
git apply --directory=fcitx5-skk patches/skk.patch
67+
git apply --directory=fcitx5-zhuyin patches/zhuyin.patch
6768
emcmake cmake -B build/js -G Ninja -DCMAKE_BUILD_TYPE=Release
6869
cmake --build build/js
6970
./scripts/install.sh js

.github/workflows/macos.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ jobs:
7171
git apply --directory=fcitx5-rime patches/rime.log.patch
7272
git apply --directory=fcitx5-skk patches/skk.patch
7373
git apply --directory=fcitx5-table-other patches/table-other.patch
74+
git apply --directory=fcitx5-zhuyin patches/zhuyin.patch
7475
cmake -B build/macos-${{ matrix.arch }} -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }}
7576
cmake --build build/macos-${{ matrix.arch }}
7677
./scripts/install.sh macos ${{ matrix.arch }}

.github/workflows/windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
shell: bash
5656
run: |
5757
cmake -B build/windows-${{ matrix.arch }} -G Ninja \
58-
-DANTHY=OFF -DBAMBOO=OFF -DCHEWING=OFF -DCHINESE_ADDONS=OFF -DCSKK=OFF -DHANGUL=OFF -DJYUTPING=OFF -DKEYMAN=OFF -DKKC=OFF -DM17N=OFF -DMOZC=OFF -DRIME=OFF -DSKK=OFF -DTABLE_EXTRA=OFF \
58+
-DANTHY=OFF -DBAMBOO=OFF -DCHEWING=OFF -DCHINESE_ADDONS=OFF -DCSKK=OFF -DHANGUL=OFF -DJYUTPING=OFF -DKEYMAN=OFF -DKKC=OFF -DM17N=OFF -DMOZC=OFF -DRIME=OFF -DSKK=OFF -DTABLE_EXTRA=OFF -DZHUYIN=OFF \
5959
-DCMAKE_BUILD_TYPE=Release \
6060
-DCMAKE_TOOLCHAIN_FILE='windows-cross/msys2.toolchain.cmake' \
6161
-DARCH=${{ matrix.cmake_arch }}

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,6 @@
7676
[submodule "windows-cross"]
7777
path = windows-cross
7878
url = https://github.com/fcitx-contrib/windows-cross
79+
[submodule "fcitx5-zhuyin"]
80+
path = fcitx5-zhuyin
81+
url = https://github.com/fcitx/fcitx5-zhuyin

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ option(SKK "" ON)
2020
option(TABLE_EXTRA "" ON)
2121
option(THAI "" ON)
2222
option(UNIKEY "" ON)
23+
option(ZHUYIN "" ON)
2324

2425
list(PREPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
2526
set(CMAKE_INSTALL_PREFIX /usr)
@@ -273,3 +274,9 @@ if (WIN32)
273274
target_compile_definitions(unikey-lib PUBLIC -DUNIKEYHOOK)
274275
endif()
275276
endif()
277+
278+
# zhuyin
279+
if (ZHUYIN)
280+
add_subdirectory(fcitx5-zhuyin)
281+
target_link_libraries(zhuyin "-L${PREBUILDER_LIB_DIR}" -lkyotocabinet -lz)
282+
endif()

docs/debug-js.zh-CN.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Uncaught RuntimeError: function signature mismatch
2+
3+
WASM 不允许函数指针的签名和实际函数的签名不一致。glib 巨量滥用这个 UB,因此出了很多问题。
4+
5+
将库开启调试,插件使用 `-DCMAKE_BUILD_TYPE=Debug`
6+
7+
可能需要带 `--enable-features=WebAssemblyUnlimitedSyncCompilation` 启动 Chrome。
8+
9+
复现问题后,在 `call_indirect` 处断点。命中后在 Sources -> Scope -> Expression 展开 `stack`,序号最大的整数即为实际函数地址。
10+
11+
在 Module 展开 `tables``$env.__indirect_function_table` 找到实际函数。
12+
13+
# 产物包含绝对路径
14+
15+
`tar xf -C` 解包,`grep` 找到具体的 .o,`wasm2wat`
16+
17+
在 wat 里找到 `(data $.L.str.x (i32.const y) "绝对路径")`,搜索 `(i32.const y)`,查看所在函数源码。

fcitx5-zhuyin

Submodule fcitx5-zhuyin added at 2f06f07

patches/zhuyin.patch

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index 8336d50..ca40c0d 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -37,9 +37,7 @@ include("${FCITX_INSTALL_CMAKECONFIG_DIR}/Fcitx5Utils/Fcitx5CompilerSettings.cma
6+
7+
add_subdirectory(po)
8+
add_subdirectory(src)
9+
-add_subdirectory(data)
10+
enable_testing()
11+
-add_subdirectory(test)
12+
13+
fcitx5_translate_desktop_file(org.fcitx.Fcitx5.Addon.Zhuyin.metainfo.xml.in
14+
org.fcitx.Fcitx5.Addon.Zhuyin.metainfo.xml XML)
15+
diff --git a/src/zhuyinengine.cpp b/src/zhuyinengine.cpp
16+
index c886797..d0e220c 100644
17+
--- a/src/zhuyinengine.cpp
18+
+++ b/src/zhuyinengine.cpp
19+
@@ -306,17 +306,17 @@ ZhuyinEngine::ZhuyinEngine(Instance *instance)
20+
: instance_(instance), factory_([this](InputContext &ic) {
21+
return new ZhuyinState(this, &ic);
22+
}) {
23+
- auto userDir =
24+
- StandardPaths::global().userDirectory(StandardPathsType::PkgData) /
25+
- "zhuyin";
26+
+ const auto &sp = StandardPaths::global();
27+
+ auto userDir = sp.userDirectory(StandardPathsType::PkgData) / "zhuyin";
28+
if (!fs::makePath(userDir)) {
29+
if (fs::isdir(userDir)) {
30+
ZHUYIN_DEBUG() << "Failed to create user directory: " << userDir;
31+
}
32+
}
33+
- context_.reset(zhuyin_init(
34+
- StandardPaths::fcitxPath("pkgdatadir", "zhuyin").string().c_str(),
35+
- userDir.string().c_str()));
36+
+ std::string tablePath =
37+
+ sp.locate(StandardPathsType::PkgData, "zhuyin/table.conf");
38+
+ context_.reset(zhuyin_init(fcitx::fs::dirName(tablePath).c_str(),
39+
+ userDir.string().c_str()));
40+
41+
instance->inputContextManager().registerProperty("zhuyinState", &factory_);
42+
reloadConfig();
43+
@@ -553,11 +553,6 @@ void ZhuyinEngine::reloadConfig() {
44+
45+
zhuyin_set_options(context_.get(), options);
46+
47+
- instance_->inputContextManager().foreach([this](InputContext *ic) {
48+
- auto *state = ic->propertyFor(&factory_);
49+
- state->reset();
50+
- return true;
51+
- });
52+
53+
zhuyin_load_phrase_library(context_.get(), USER_DICTIONARY);
54+
}

scripts/install-deps.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ macos=(
1010
json
1111
json-glib
1212
keyman-core
13+
kyotocabinet
1314
leveldb
1415
libchewing
1516
libgee
1617
libhangul
1718
libkkc
1819
libmozc
20+
libpinyin
1921
librime
2022
libskk
2123
libthai
@@ -40,12 +42,14 @@ js=(
4042
json
4143
json-glib
4244
keyman-core
45+
kyotocabinet
4346
leveldb
4447
libchewing
4548
libgee
4649
libhangul
4750
libkkc
4851
libmozc
52+
libpinyin
4953
librime
5054
libskk
5155
libthai

scripts/install.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ macos=(
2121
table-other
2222
thai
2323
unikey
24+
zhuyin
2425
)
2526

2627
windows=(
@@ -48,6 +49,7 @@ js=(
4849
skk
4950
thai
5051
unikey
52+
zhuyin
5153
)
5254

5355
. scripts/platform.sh "$@"
@@ -144,6 +146,13 @@ gunzip -fc $ROOT/cache/$skk_dict > $skk_share_dir/skk/SKK-JISYO.L
144146
fi
145147
fi
146148

149+
# zhuyin
150+
if [[ $PLATFORM != "windows" ]]; then
151+
zhuyin_data=zhuyin-data.tar.bz2
152+
[[ -f $ROOT/cache/$zhuyin_data ]] || curl -LO --output-dir $ROOT/cache https://github.com/fcitx-contrib/zhuyin-data/releases/download/latest/$zhuyin_data
153+
tar xf $ROOT/cache/$zhuyin_data -C $TARGET_DIR/zhuyin/usr
154+
fi
155+
147156
if [[ $PLATFORM == "macos" || $PLATFORM == "windows" ]]; then
148157
# split arch-specific files with data
149158
for plugin in "${plugins[@]}"; do
@@ -208,6 +217,7 @@ package m17n
208217
package mozc mozc
209218
package rime rime
210219
package skk skk
220+
package zhuyin zhuyin
211221
fi
212222
package hallelujah hallelujah
213223
package sayura sayura

0 commit comments

Comments
 (0)