Skip to content

Commit 83bfb56

Browse files
authored
kkc (#237)
1 parent fde0b94 commit 83bfb56

File tree

11 files changed

+94
-5
lines changed

11 files changed

+94
-5
lines changed

.github/workflows/js.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ jobs:
5959
git apply --directory=libime patches/libime.patch
6060
git apply --directory=fcitx5-chinese-addons patches/chinese-addons.patch
6161
git apply --directory=fcitx5-jyutping patches/jyutping.patch
62+
git apply --directory=fcitx5-kkc patches/kkc.patch
6263
git apply --directory=fcitx5-rime patches/rime.log.patch
6364
git apply --directory=fcitx5-rime patches/rime.js.patch
65+
git apply --directory=fcitx5-skk patches/skk.patch
6466
emcmake cmake -B build/js -G Ninja -DCMAKE_BUILD_TYPE=Release
6567
cmake --build build/js
6668
./scripts/install.sh js

.github/workflows/macos.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ jobs:
6767
run: |
6868
git apply --directory=libime patches/libime.patch
6969
git apply --directory=fcitx5-jyutping patches/jyutping.patch
70+
git apply --directory=fcitx5-kkc patches/kkc.patch
7071
git apply --directory=fcitx5-rime patches/rime.log.patch
72+
git apply --directory=fcitx5-skk patches/skk.patch
7173
cmake -B build/macos-${{ matrix.arch }} -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }}
7274
cmake --build build/macos-${{ matrix.arch }}
7375
./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 -DHANGUL=OFF -DJYUTPING=OFF -DKEYMAN=OFF -DM17N=OFF -DMOZC=OFF -DRIME=OFF -DSKK=OFF -DTABLE_EXTRA=OFF \
58+
-DANTHY=OFF -DBAMBOO=OFF -DCHEWING=OFF -DCHINESE_ADDONS=OFF -DHANGUL=OFF -DJYUTPING=OFF -DKEYMAN=OFF -DKKC=OFF -DM17N=OFF -DMOZC=OFF -DRIME=OFF -DSKK=OFF -DTABLE_EXTRA=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
@@ -25,6 +25,9 @@
2525
[submodule "fcitx5-keyman"]
2626
path = fcitx5-keyman
2727
url = https://github.com/fcitx/fcitx5-keyman
28+
[submodule "fcitx5-kkc"]
29+
path = fcitx5-kkc
30+
url = https://github.com/fcitx/fcitx5-kkc
2831
[submodule "fcitx5-lua"]
2932
path = fcitx5-lua
3033
url = https://github.com/fcitx/fcitx5-lua

CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ option(HALLELUJAH "" ON)
1010
option(HANGUL "" ON)
1111
option(JYUTPING "" ON)
1212
option(KEYMAN "" ON)
13+
option(KKC "" ON)
1314
option(M17N "" ON)
1415
option(MOZC "" ON)
1516
option(RIME "" ON)
@@ -50,6 +51,8 @@ if (APPLE)
5051
"${FIND_ROOT_PATH}"
5152
)
5253
set(CMAKE_INSTALL_RPATH "${APP_CONTENTS_PATH}/lib") # scel2org5, libime_*
54+
set(SKK_PATH "$XDG_DATA_DIRS/skk/" CACHE STRING "") # skk
55+
set(SKK_DEFAULT_PATH "$XDG_DATA_DIRS/skk/" CACHE STRING "") # kkc
5356
elseif (WIN32)
5457
list(PREPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/relative")
5558
add_compile_definitions(-DFcitx5Core_EXPORTS -DFcitx5Utils_EXPORTS)
@@ -143,6 +146,12 @@ if (KEYMAN)
143146
add_subdirectory(fcitx5-keyman)
144147
endif()
145148

149+
# kkc
150+
if (KKC)
151+
add_subdirectory(fcitx5-kkc)
152+
target_link_libraries(kkc "${PREBUILDER_LIB_DIR}/libmarisa.a")
153+
endif()
154+
146155
# m17n
147156
if (M17N)
148157
add_library(m17n_static STATIC IMPORTED)
@@ -222,7 +231,6 @@ endif()
222231

223232
# skk
224233
if (SKK)
225-
set(SKK_DEFAULT_PATH "$XDG_DATA_DIRS/skk/SKK-JISYO.L" CACHE STRING "")
226234
add_subdirectory(fcitx5-skk)
227235
target_include_directories(skk PRIVATE "${PREBUILDER_INCLUDE_DIR}/gee-0.8")
228236
set(SKK_LINK_LIBS "-L${PREBUILDER_LIB_DIR}" -lgee-0.8 -lgio-2.0 -lgmodule-2.0 -ljson-glib-1.0 -lz)

fcitx5-kkc

Submodule fcitx5-kkc added at ed03d44

patches/kkc.patch

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
diff --git a/src/kkc.cpp b/src/kkc.cpp
2+
index 3924b92..0d40f7b 100644
3+
--- a/src/kkc.cpp
4+
+++ b/src/kkc.cpp
5+
@@ -637,6 +637,11 @@ void KkcEngine::loadDictionary() {
6+
}
7+
8+
if (mode == 1) {
9+
+ std::string_view partialpath = path;
10+
+ if (stringutils::consumePrefix(partialpath, "$XDG_DATA_DIRS/")) {
11+
+ path = StandardPaths::global().locate(StandardPathsType::Data,
12+
+ partialpath);
13+
+ }
14+
auto dict = makeGObjectUnique(reinterpret_cast<KkcDictionary *>(
15+
kkc_system_segment_dictionary_new(path.c_str(), "EUC-JP",
16+
NULL)));

patches/skk.patch

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index a44053f..9d08988 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -21,7 +21,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
6+
7+
include("${FCITX_INSTALL_CMAKECONFIG_DIR}/Fcitx5Utils/Fcitx5CompilerSettings.cmake")
8+
9+
-set(SKK_DEFAULT_PATH "/usr/share/skk/SKK-JISYO.L" CACHE STRING "Default path of SKK")
10+
+set(SKK_PATH "/usr/share/skk/" CACHE STRING "Default path of SKK directory that has SKK-JISYO.L, could start with \$XDG_DATA_DIRS/")
11+
12+
include(GNUInstallDirs)
13+
14+
diff --git a/src/dictionary_list.in b/src/dictionary_list.in
15+
index c12a4e5..e8a925e 100644
16+
--- a/src/dictionary_list.in
17+
+++ b/src/dictionary_list.in
18+
@@ -1,2 +1,2 @@
19+
type=file,file=$FCITX_CONFIG_DIR/skk/user.dict,mode=readwrite
20+
-type=file,file=@SKK_DEFAULT_PATH@,mode=readonly
21+
+type=file,file=@SKK_PATH@SKK-JISYO.L,mode=readonly

scripts/install-deps.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ macos=(
1313
libchewing
1414
libgee
1515
libhangul
16+
libkkc
1617
libmozc
1718
librime
1819
libskk
@@ -41,6 +42,7 @@ js=(
4142
libchewing
4243
libgee
4344
libhangul
45+
libkkc
4446
libmozc
4547
librime
4648
libskk

scripts/install.sh

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ macos=(
99
hangul
1010
jyutping
1111
keyman
12+
kkc
1213
lua
1314
m17n
1415
mozc
@@ -35,6 +36,7 @@ js=(
3536
hangul
3637
jyutping
3738
keyman
39+
kkc
3840
lua
3941
m17n
4042
mozc
@@ -55,7 +57,7 @@ extract_dep() {
5557
local plugin=$1
5658
local dep=$2
5759
local file=$dep$POSTFIX.tar.bz2
58-
tar xjf $CACHE_DIR/$file -C $TARGET_DIR/$plugin/usr --exclude include --exclude lib
60+
tar xf $CACHE_DIR/$file -C $TARGET_DIR/$plugin/usr --exclude include --exclude lib
5961
}
6062

6163
package() {
@@ -79,7 +81,7 @@ package() {
7981

8082
cache_plugin() {
8183
local file=$1
82-
[[ -f $ROOT/cache/$file ]] || wget -P $ROOT/cache https://github.com/fcitx-contrib/fcitx5-plugins/releases/download/macos-latest/$file
84+
[[ -f $ROOT/cache/$file ]] || curl -LO --output-dir $ROOT/cache https://github.com/fcitx-contrib/fcitx5-plugins/releases/download/macos-latest/$file
8385
}
8486

8587
for plugin in "${plugins[@]}"; do
@@ -133,7 +135,7 @@ skk_share_dir=$TARGET_DIR/skk/usr/share
133135
mkdir -p $skk_share_dir/skk
134136
cp -r $TARGET_DIR/usr/share/libskk $skk_share_dir
135137
skk_dict=SKK-JISYO.L.gz
136-
[[ -f $ROOT/cache/$skk_dict ]] || wget -P $ROOT/cache https://skk-dev.github.io/dict/$skk_dict
138+
[[ -f $ROOT/cache/$skk_dict ]] || curl -LO --output-dir $ROOT/cache https://skk-dev.github.io/dict/$skk_dict
137139
gunzip -fc $ROOT/cache/$skk_dict > $skk_share_dir/skk/SKK-JISYO.L
138140
fi
139141
fi
@@ -176,13 +178,26 @@ if [[ $PLATFORM != "windows" ]]; then
176178
fi
177179
fi
178180

181+
# kkc
182+
if [[ $PLATFORM != "windows" ]]; then
183+
libkkc_data=libkkc-data.tar.bz2
184+
[[ -f $ROOT/cache/$libkkc_data ]] || curl -LO --output-dir $ROOT/cache https://github.com/fcitx-contrib/libkkc-data/releases/download/latest/$libkkc_data
185+
# Model files are under lib/
186+
if [[ $PLATFORM == "macos" ]]; then
187+
tar xf $ROOT/cache/$libkkc_data -C $TARGET_DIR/kkc/data
188+
else
189+
tar xf $ROOT/cache/$libkkc_data -C $TARGET_DIR/kkc/usr
190+
fi
191+
fi
192+
179193
if [[ $PLATFORM != "windows" ]]; then
180194
package anthy anthy
181195
package chewing chewing
182196
package chinese-addons pinyin
183197
package hangul hangul
184198
package jyutping jyutping
185199
package keyman
200+
package kkc kkc
186201
package lua
187202
package m17n
188203
package mozc mozc

0 commit comments

Comments
 (0)