1 # Copyright 2010-2024 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT
=( python3_
{10.
.12} )
8 inherit desktop edo elisp-common multiprocessing python-any-r1 savedconfig toolchain-funcs xdg
10 DESCRIPTION
="Mozc - Japanese input method editor"
11 HOMEPAGE
="https://github.com/google/mozc"
13 if [[ "${PV}" == "9999" ]]; then
16 EGIT_REPO_URI
="https://github.com/google/mozc"
17 EGIT_SUBMODULES
=(src
/third_party
/japanese_usage_dictionary
)
19 MOZC_GIT_REVISION
="305e9a7374254148474d067c46d55a4ee6081837"
21 MOZC_DATE
="${MOZC_DATE%%_p*}"
23 FCITX_MOZC_GIT_REVISION
="242b4f703cba27d4ff4dc123c713a478f964e001"
24 FCITX_MOZC_DATE
="${PV#*_p}"
25 FCITX_MOZC_DATE
="${FCITX_MOZC_DATE#*_p}"
26 FCITX_MOZC_DATE
="${FCITX_MOZC_DATE%%_p*}"
28 JAPANESE_USAGE_DICTIONARY_GIT_REVISION
="a4a66772e33746b91e99caceecced9a28507e925"
29 JAPANESE_USAGE_DICTIONARY_DATE
="20180701040110"
32 https://github.com/google/${PN}/archive/${MOZC_GIT_REVISION}.tar.gz -> ${PN}-${PV%%_p*}-${MOZC_DATE}.tar.gz
33 https://github.com/hiroyuki-komatsu/japanese-usage-dictionary/archive/${JAPANESE_USAGE_DICTIONARY_GIT_REVISION}.tar.gz -> japanese-usage-dictionary-${JAPANESE_USAGE_DICTIONARY_DATE}.tar.gz
34 https://dev.gentoo.org/~sam/distfiles/${CATEGORY}/${PN}/${PN}-2.28.5029.102-patches.tar.xz
35 fcitx4? ( https://github.com/fcitx/${PN}/archive/${FCITX_MOZC_GIT_REVISION}.tar.gz -> fcitx-${PN}-${PV%%_p*}-${FCITX_MOZC_DATE}.tar.gz )
36 fcitx5? ( https://github.com/fcitx/${PN}/archive/${FCITX_MOZC_GIT_REVISION}.tar.gz -> fcitx-${PN}-${PV%%_p*}-${FCITX_MOZC_DATE}.tar.gz )
41 # src/data/dictionary_oss: ipadic, public-domain
42 # src/data/unicode: unicode
43 # japanese-usage-dictionary: BSD-2
44 LICENSE
="BSD BSD-2 ipadic public-domain unicode"
46 KEYWORDS
="~amd64 ~x86"
47 IUSE
="debug emacs fcitx4 fcitx5 +gui ibus renderer test"
48 REQUIRED_USE
="|| ( emacs fcitx4 fcitx5 ibus )"
49 RESTRICT
="!test? ( test )"
52 $(python_gen_any_dep 'dev-python/six[${PYTHON_USEDEP}]')
53 >=dev-libs/protobuf-3.0.0
55 app-alternatives/ninja
57 emacs? ( app-editors/emacs:* )
58 fcitx4? ( sys-devel/gettext )
59 fcitx5? ( sys-devel/gettext )
62 >=dev-cpp/abseil-cpp-20230802.0:=[cxx17(+)]
63 >=dev-libs/protobuf-3.0.0:=
95 >=dev-cpp/abseil-cpp-20230802.0:=[cxx17(+)]
96 >=dev-libs/protobuf-3.0.0:=
97 emacs? ( app-editors/emacs:* )
114 >=app-i18n/ibus-1.4.1
126 S
="${WORKDIR}/${P}/src"
128 SITEFILE
="50${PN}-gentoo.el"
131 "${WORKDIR}"/mozc-2.28
.5029.102-patches
132 "${FILESDIR}"/mozc-2.28
.5029.102-abseil.
patch
133 "${FILESDIR}"/mozc-2.28
.5029.102-abseil-20230802.0.
patch
136 python_check_deps
() {
137 python_has_version
"dev-python/six[${PYTHON_USEDEP}]"
141 if [[ "${PV}" == "9999" ]]; then
144 if use fcitx4 || use fcitx5
; then
145 local EGIT_SUBMODULES
=()
146 git-r3_fetch https
://github.com
/fcitx
/mozc refs
/heads
/fcitx
147 git-r3_checkout https
://github.com
/fcitx
/mozc
"${WORKDIR}/fcitx-mozc"
150 cp -pr "${WORKDIR}"/fcitx
{,5}-mozc || die
153 unpack
${PN}-${PV%%_p*}-${MOZC_DATE}.
tar.gz
154 mv mozc-
${MOZC_GIT_REVISION} ${P} || die
156 unpack
${PN}-2.28
.5029.102-patches.
tar.xz
158 unpack japanese-usage-dictionary-
${JAPANESE_USAGE_DICTIONARY_DATE}.
tar.gz
159 cp -p japanese-usage-dictionary-
${JAPANESE_USAGE_DICTIONARY_GIT_REVISION}/usage_dict.txt
${P}/src
/third_party
/japanese_usage_dictionary || die
161 if use fcitx4 || use fcitx5
; then
162 unpack fcitx-
${PN}-${PV%%_p*}-${FCITX_MOZC_DATE}.
tar.gz
164 cp -pr mozc-
${FCITX_MOZC_GIT_REVISION} fcitx-
${PN} || die
167 cp -pr mozc-
${FCITX_MOZC_GIT_REVISION} fcitx5-
${PN} || die
169 rm -r mozc-
${FCITX_MOZC_GIT_REVISION} || die
176 cp -pr "${WORKDIR}/fcitx-mozc/src/unix/fcitx" unix || die
177 PATCHES
+=( "${FILESDIR}"/mozc-2.28
.5029.102-abseil-20230802.0
-fcitx4.
patch )
180 cp -pr "${WORKDIR}/fcitx5-mozc/src/unix/fcitx5" unix || die
181 PATCHES
+=( "${FILESDIR}"/mozc-2.28
.5029.102-abseil-20230802.0
-fcitx5.
patch )
184 pushd "${WORKDIR}/${P}" > /dev
/null || die
186 popd > /dev
/null || die
189 -e "s/def GypMain(options, unused_args):/def GypMain(options, gyp_args):/" \
190 -e "s/RunOrDie(gyp_command + gyp_options)/RunOrDie(gyp_command + gyp_options + gyp_args)/" \
191 -e "s/RunOrDie(\[ninja/&, '-j$(makeopts_jobs "${MAKEOPTS}" 999)', '-l$(makeopts_loadavg "${MAKEOPTS}" 0)', '-v'/" \
192 -i build_mozc.py || die
194 local ar=($
(tc-getAR
))
195 local cc
=($
(tc-getCC
))
196 local cxx
=($
(tc-getCXX
))
197 local ld
=($
(tc-getLD
))
198 local nm
=($
(tc-getNM
))
199 local readelf
=($
(tc-getREADELF
))
201 # Use absolute paths. Non-absolute paths are mishandled by GYP.
202 ar[0]=$
(type -P ${ar[0]})
203 cc
[0]=$
(type -P ${cc[0]})
204 cxx
[0]=$
(type -P ${cxx[0]})
205 ld
[0]=$
(type -P ${ld[0]})
206 nm
[0]=$
(type -P ${nm[0]})
207 readelf
[0]=$
(type -P ${readelf[0]})
210 -e "s:<!(which ar):${ar[@]}:" \
211 -e "s:<!(which clang):${cc[@]}:" \
212 -e "s:<!(which clang++):${cxx[@]}:" \
213 -e "s:<!(which ld):${ld[@]}:" \
214 -e "s:<!(which nm):${nm[@]}:" \
215 -e "s:<!(which readelf):${readelf[@]}:" \
216 -i gyp
/common.gypi || die
218 # https://github.com/google/mozc/issues/489
221 -e "/'-stdlib=libc++'/d" \
222 -i gyp
/common.gypi || die
225 restore_config mozcdic-ut.txt
226 if [[ -f /mozcdic-ut.txt
&& -s mozcdic-ut.txt
]]; then
227 einfo
"mozcdic-ut.txt found. Adding to mozc dictionary..."
228 cat mozcdic-ut.txt
>> "${WORKDIR}/${P}/src/data/dictionary_oss/dictionary00.txt" || die
239 local gyp_arguments
=()
242 gyp_arguments
+=(-D compiler_host
=gcc
-D compiler_target
=gcc
)
243 elif tc-is-clang
; then
244 gyp_arguments
+=(-D compiler_host
=clang
-D compiler_target
=clang
)
246 gyp_arguments
+=(-D compiler_host
=unknown
-D compiler_target
=unknown
)
249 gyp_arguments
+=(-D debug_extra_cflags
=)
250 gyp_arguments
+=(-D release_extra_cflags
=)
252 gyp_arguments
+=(-D use_fcitx
=$
(usex fcitx4 YES NO
))
253 gyp_arguments
+=(-D use_fcitx5
=$
(usex fcitx5 YES NO
))
254 gyp_arguments
+=(-D use_libibus
=$
(usex ibus
1 0))
255 gyp_arguments
+=(-D use_libprotobuf
=1)
256 gyp_arguments
+=(-D use_system_abseil_cpp
=1)
257 gyp_arguments
+=(-D use_system_gtest
=$
(usex
test 1 0))
258 gyp_arguments
+=(-D use_system_jsoncpp
=$
(usex
test 1 0))
259 gyp_arguments
+=(-D enable_gtk_renderer
=$
(usex renderer
1 0))
261 gyp_arguments
+=(-D server_dir
="${EPREFIX}/usr/libexec/mozc")
262 gyp_arguments
+=(-D document_dir
="${EPREFIX}/usr/libexec/mozc/documents")
265 gyp_arguments
+=(-D ibus_mozc_path
="${EPREFIX}/usr/libexec/ibus-engine-mozc")
266 gyp_arguments
+=(-D ibus_mozc_icon_path
="${EPREFIX}/usr/share/ibus-mozc/product_icon.png")
269 unset AR CC CXX LD NM READELF
271 edo
"${PYTHON}" build_mozc.py gyp \
272 --gypdir="${EPREFIX}/usr/bin" \
273 --server_dir="${EPREFIX}/usr/libexec/mozc" \
275 $
(usex gui
"" --noqt) \
276 -- "${gyp_arguments[@]}"
280 local targets
=(server
/server.gyp
:mozc_server
)
282 targets
+=(unix
/emacs
/emacs.gyp
:mozc_emacs_helper
)
285 targets
+=(unix
/fcitx
/fcitx.gyp
:fcitx-mozc
)
288 targets
+=(unix
/fcitx
5/fcitx5.gyp
:fcitx5-mozc
)
291 targets
+=(gui
/gui.gyp
:mozc_tool
)
294 targets
+=(unix
/ibus
/ibus.gyp
:ibus_mozc
)
296 if use renderer
; then
297 targets
+=(renderer
/renderer.gyp
:mozc_renderer
)
300 targets
+=(gyp
/tests.gyp
:unittests
)
304 GYP_IBUS_FLAG
="--use_gyp_for_ibus_build"
307 edo
"${PYTHON}" build_mozc.py build -c ${BUILD_TYPE} ${GYP_IBUS_FLAG} -v "${targets[@]}"
310 elisp-compile unix
/emacs
/*.el
315 edo
"${PYTHON}" build_mozc.py runtests
-c ${BUILD_TYPE} --test_jobs 1
319 exeinto
/usr
/libexec
/mozc
320 doexe out_linux
/${BUILD_TYPE}/mozc_server
322 [[ -s mozcdic-ut.txt
]] && save_config mozcdic-ut.txt
325 doexe out_linux
/${BUILD_TYPE}/mozc_tool
328 if use renderer
; then
329 doexe out_linux
/${BUILD_TYPE}/mozc_renderer
332 insinto
/usr
/libexec
/mozc
/documents
333 doins data
/installer
/credits_en.html
336 dobin out_linux
/${BUILD_TYPE}/mozc_emacs_helper
337 elisp-install
${PN} unix
/emacs
/*.
{el
,elc
}
338 elisp-site-file-install
"${FILESDIR}/${SITEFILE}" ${PN}
342 exeinto /usr/$(get_libdir)/fcitx
343 doexe out_linux/${BUILD_TYPE}/fcitx-mozc.so
345 insinto /usr/share/fcitx/addon
346 doins unix/fcitx/fcitx-mozc.conf
348 insinto /usr/share/fcitx/inputmethod
349 doins unix/fcitx/mozc.conf
351 insinto /usr/share/fcitx/mozc/icon
352 newins data/images/product_icon_32bpp-128.png mozc.png
354 for image in ../../fcitx-${PN}/src/data/images/unix/ui-*.png; do
355 newins "${image}" "mozc-${image#../../fcitx-${PN}/src/data/images/unix/ui-}"
359 for mo_file in out_linux/${BUILD_TYPE}/gen/unix/fcitx/po/*.mo; do
360 locale="${mo_file##*/}"
361 locale="${locale%.mo}"
362 insinto /usr/share/locale/${locale}/LC_MESSAGES
363 newins "${mo_file}" fcitx-mozc.mo
368 exeinto /usr/$(get_libdir)/fcitx5
369 doexe out_linux/${BUILD_TYPE}/fcitx5-mozc.so
371 insinto /usr/share/fcitx5/addon
372 newins unix/fcitx5/mozc-addon.conf mozc.conf
374 insinto /usr/share/fcitx5/inputmethod
375 doins unix/fcitx5/mozc.conf
377 local orgfcitx5="org.fcitx.Fcitx5.fcitx-mozc
"
378 newicon -s 128 data/images/product_icon_32bpp-128.png ${orgfcitx5}.png
379 newicon -s 128 data/images/product_icon_32bpp-128.png fcitx-mozc.png
380 newicon -s 32 data/images/unix/ime_product_icon_opensource-32.png ${orgfcitx5}.png
381 newicon -s 32 data/images/unix/ime_product_icon_opensource-32.png fcitx-mozc.png
382 for uiimg in ../../fcitx5-mozc/scripts/icons/ui-*.png; do
384 newicon -s 48 ${uiimg} ${orgfcitx5}-${dimg/_/-}
385 newicon -s 48 ${uiimg} fcitx-mozc-${dimg/_/-}
389 for mo_file in unix/fcitx5/po/*.po; do
390 locale="${mo_file##*/}"
391 locale="${locale%.po}"
392 msgfmt ${mo_file} -o ${mo_file/.po/.mo} || die
393 insinto /usr/share/locale/${locale}/LC_MESSAGES
394 newins "${mo_file/.po/.mo}" fcitx5-mozc.mo
396 msgfmt --xml -d unix/fcitx5/po/ --template unix/fcitx5/org.fcitx.Fcitx5.Addon.Mozc.metainfo.xml.in -o \
397 unix/fcitx5/org.fcitx.Fcitx5.Addon.Mozc.metainfo.xml || die
398 insinto /usr/share/metainfo
399 doins unix/fcitx5/org.fcitx.Fcitx5.Addon.Mozc.metainfo.xml
404 newexe out_linux/${BUILD_TYPE}/ibus_mozc ibus-engine-mozc
406 insinto /usr/share/ibus/component
407 doins out_linux/${BUILD_TYPE}/gen/unix/ibus/mozc.xml
409 insinto /usr/share/ibus-mozc
410 newins data/images/unix/ime_product_icon_opensource-32.png product_icon.png
412 for image in data/images/unix/ui-*.png; do
413 newins "${image}" "${image#data/images/unix/ui-}"
420 elog "ENVIRONMENTAL VARIABLES
"
422 elog "MOZC_SERVER_DIRECTORY
"
423 elog " Mozc server directory
"
424 elog " Value used by default
: \"${EPREFIX}/usr
/libexec
/mozc
\""
425 elog "MOZC_DOCUMENTS_DIRECTORY
"
426 elog " Mozc documents directory
"
427 elog " Value used by default
: \"${EPREFIX}/usr
/libexec
/mozc
/documents
\""
428 elog "MOZC_CONFIGURATION_DIRECTORY
"
429 elog " Mozc configuration directory
"
430 elog " Value used by default
: \"~
/.mozc
\""
434 elog "USAGE IN EMACS
"
436 elog "mozc-mode is minor mode to input Japanese text using Mozc server.
"
437 elog "mozc-mode can be used via LEIM
(Library of Emacs Input Method
).
"
439 elog "In order to use mozc-mode by default
, the following settings should be added to
"
440 elog "Emacs init
file (~
/.emacs.d
/init.el or ~
/.emacs
):"
442 elog " (require
'mozc)"
443 elog " (set-language-environment \"Japanese\")"
444 elog " (setq default-input-method \"japanese-mozc\")"
446 elog "With the above settings, typing C-\\ (which is bound to \"toggle-input-method\""
447 elog "by default) will enable mozc-mode."
449 elog "Alternatively, at run time, after loading mozc.el, mozc-mode can be activated by"
450 elog "calling \"set-input-method\" and entering \"japanese-mozc\"."