1 # Copyright 2010-2022 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
5 PYTHON_COMPAT
=( python3_
{8.
.10} )
7 inherit elisp-common multiprocessing python-any-r1 toolchain-funcs desktop xdg
9 if [[ "${PV}" == "9999" ]]; then
12 EGIT_REPO_URI
="https://github.com/google/mozc"
13 EGIT_SUBMODULES
=(src
/third_party
/japanese_usage_dictionary
)
17 MOZC_DATE
="${MOZC_DATE%%_p*}"
19 FCITX_MOZC_GIT_REVISION
=""
20 FCITX_MOZC_DATE
="${PV#*_p}"
21 FCITX_MOZC_DATE
="${FCITX_MOZC_DATE#*_p}"
22 FCITX_MOZC_DATE
="${FCITX_MOZC_DATE%%_p*}"
24 JAPANESE_USAGE_DICTIONARY_GIT_REVISION
=""
25 JAPANESE_USAGE_DICTIONARY_DATE
=""
28 DESCRIPTION
="Mozc - Japanese input method editor"
29 HOMEPAGE
="https://github.com/google/mozc"
30 if [[ "${PV}" == "9999" ]]; then
33 SRC_URI
="https://github.com/google/${PN}/archive/${MOZC_GIT_REVISION}.tar.gz -> ${PN}-${PV%%_p*}-${MOZC_DATE}.tar.gz
34 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
35 https://github.com/fcitx/${PN}/archive/${FCITX_MOZC_GIT_REVISION}.tar.gz -> fcitx-${PN}-${PV%%_p*}-${FCITX_MOZC_DATE}.tar.gz"
39 # src/data/dictionary_oss: ipadic, public-domain
40 # src/data/unicode: unicode
41 # japanese-usage-dictionary: BSD-2
42 LICENSE
="BSD BSD-2 ipadic public-domain unicode"
45 IUSE
="debug emacs fcitx4 fcitx5 +gui ibus renderer test"
46 REQUIRED_USE
="|| ( emacs fcitx4 fcitx5 ibus )"
47 RESTRICT
="!test? ( test )"
49 BDEPEND
="$(python_gen_any_dep 'dev-python/six[${PYTHON_USEDEP}]')
50 >=dev-libs/protobuf-3.0.0
54 emacs? ( app-editors/emacs:* )
55 fcitx4? ( sys-devel/gettext )
56 fcitx5? ( sys-devel/gettext )"
57 DEPEND
=">=dev-cpp/abseil-cpp-20200923[cxx17(+)]
58 >=dev-libs/protobuf-3.0.0:=
89 RDEPEND
=">=dev-cpp/abseil-cpp-20200923[cxx17(+)]
90 >=dev-libs/protobuf-3.0.0:=
91 emacs? ( app-editors/emacs:* )
108 >=app-i18n/ibus-1.4.1
119 S
="${WORKDIR}/${P}/src"
121 SITEFILE
="50${PN}-gentoo.el"
128 python_check_deps
() {
129 has_version
-b "dev-python/six[${PYTHON_USEDEP}]"
133 if [[ "${PV}" == "9999" ]]; then
136 if use fcitx4 || use fcitx5
; then
137 local EGIT_SUBMODULES
=()
138 git-r3_fetch https
://github.com
/fcitx
/mozc refs
/heads
/fcitx
139 git-r3_checkout https
://github.com
/fcitx
/mozc
"${WORKDIR}/fcitx-mozc"
142 cp -pr "${WORKDIR}"/fcitx
{,5}-mozc
145 unpack
${PN}-${PV%%_p*}-${MOZC_DATE}.
tar.gz
146 mv mozc-
${MOZC_GIT_REVISION} ${P} || die
148 unpack japanese-usage-dictionary-
${JAPANESE_USAGE_DICTIONARY_DATE}.
tar.gz
149 cp -p japanese-usage-dictionary-
${JAPANESE_USAGE_DICTIONARY_GIT_REVISION}/usage_dict.txt
${P}/src
/third_party
/japanese_usage_dictionary || die
151 unpack fcitx-
${PN}-${PV%%_p*}-${FCITX_MOZC_DATE}.
tar.gz
153 cp -pr mozc-
${FCITX_MOZC_GIT_REVISION} fcitx-
${PN} || die
156 cp -pr mozc-
${FCITX_MOZC_GIT_REVISION} fcitx5-
${PN} || die
163 cp -pr "${WORKDIR}/fcitx-mozc/src/unix/fcitx" unix || die
166 cp -pr "${WORKDIR}/fcitx5-mozc/src/unix/fcitx5" unix || die
169 pushd "${WORKDIR}/${P}" > /dev
/null || die
171 eapply
"${FILESDIR}/${PN}-2.26.4220-system_abseil-cpp.patch"
172 eapply
"${FILESDIR}/${PN}-2.26.4220-system_gtest.patch"
173 eapply
"${FILESDIR}/${PN}-2.26.4220-system_jsoncpp.patch"
174 eapply
"${FILESDIR}/${PN}-2.26.4220-environmental_variables.patch"
175 eapply
"${FILESDIR}/${PN}-2.26.4220-server_path_check.patch"
179 popd > /dev
/null || die
182 -e "s/def GypMain(options, unused_args):/def GypMain(options, gyp_args):/" \
183 -e "s/RunOrDie(gyp_command + gyp_options)/RunOrDie(gyp_command + gyp_options + gyp_args)/" \
184 -e "s/RunOrDie(\[ninja/&, '-j$(makeopts_jobs "${MAKEOPTS}" 999)', '-l$(makeopts_loadavg "${MAKEOPTS}" 0)', '-v'/" \
185 -i build_mozc.py || die
187 local ar=($
(tc-getAR
))
188 local cc
=($
(tc-getCC
))
189 local cxx
=($
(tc-getCXX
))
190 local ld
=($
(tc-getLD
))
191 local nm
=($
(tc-getNM
))
192 local readelf
=($
(tc-getREADELF
))
194 # Use absolute paths. Non-absolute paths are mishandled by GYP.
195 ar[0]=$
(type -P ${ar[0]})
196 cc
[0]=$
(type -P ${cc[0]})
197 cxx
[0]=$
(type -P ${cxx[0]})
198 ld
[0]=$
(type -P ${ld[0]})
199 nm
[0]=$
(type -P ${nm[0]})
200 readelf
[0]=$
(type -P ${readelf[0]})
203 -e "s:<!(which ar):${ar[@]}:" \
204 -e "s:<!(which clang):${cc[@]}:" \
205 -e "s:<!(which clang++):${cxx[@]}:" \
206 -e "s:<!(which ld):${ld[@]}:" \
207 -e "s:<!(which nm):${nm[@]}:" \
208 -e "s:<!(which readelf):${readelf[@]}:" \
209 -i gyp
/common.gypi || die
211 # https://github.com/google/mozc/issues/489
214 -e "/'-stdlib=libc++'/d" \
215 -i gyp
/common.gypi || die
225 local gyp_arguments
=()
228 gyp_arguments
+=(-D compiler_host
=gcc
-D compiler_target
=gcc
)
229 elif tc-is-clang
; then
230 gyp_arguments
+=(-D compiler_host
=clang
-D compiler_target
=clang
)
232 gyp_arguments
+=(-D compiler_host
=unknown
-D compiler_target
=unknown
)
235 gyp_arguments
+=(-D debug_extra_cflags
=)
236 gyp_arguments
+=(-D release_extra_cflags
=)
238 gyp_arguments
+=(-D use_fcitx
=$
(usex fcitx4 YES NO
))
239 gyp_arguments
+=(-D use_fcitx5
=$
(usex fcitx5 YES NO
))
240 gyp_arguments
+=(-D use_libibus
=$
(usex ibus
1 0))
241 gyp_arguments
+=(-D use_libprotobuf
=1)
242 gyp_arguments
+=(-D use_system_abseil_cpp
=1)
243 gyp_arguments
+=(-D use_system_gtest
=$
(usex
test 1 0))
244 gyp_arguments
+=(-D use_system_jsoncpp
=$
(usex
test 1 0))
245 gyp_arguments
+=(-D enable_gtk_renderer
=$
(usex renderer
1 0))
247 gyp_arguments
+=(-D server_dir
="${EPREFIX}/usr/libexec/mozc")
248 gyp_arguments
+=(-D document_dir
="${EPREFIX}/usr/libexec/mozc/documents")
251 gyp_arguments
+=(-D ibus_mozc_path
="${EPREFIX}/usr/libexec/ibus-engine-mozc")
252 gyp_arguments
+=(-D ibus_mozc_icon_path
="${EPREFIX}/usr/share/ibus-mozc/product_icon.png")
255 unset AR CC CXX LD NM READELF
257 execute
"${PYTHON}" build_mozc.py gyp \
258 --gypdir="${EPREFIX}/usr/bin" \
259 --server_dir="${EPREFIX}/usr/libexec/mozc" \
261 $
(usex gui
"" --noqt) \
262 -- "${gyp_arguments[@]}" || die
"Configuration failed"
266 local targets
=(server
/server.gyp
:mozc_server
)
268 targets
+=(unix
/emacs
/emacs.gyp
:mozc_emacs_helper
)
271 targets
+=(unix
/fcitx
/fcitx.gyp
:fcitx-mozc
)
274 targets
+=(unix
/fcitx
5/fcitx5.gyp
:fcitx5-mozc
)
277 targets
+=(gui
/gui.gyp
:mozc_tool
)
280 targets
+=(unix
/ibus
/ibus.gyp
:ibus_mozc
)
282 if use renderer
; then
283 targets
+=(renderer
/renderer.gyp
:mozc_renderer
)
286 targets
+=(gyp
/tests.gyp
:unittests
)
289 execute
"${PYTHON}" build_mozc.py build -c ${BUILD_TYPE} -v "${targets[@]}" || die
"Building failed"
292 elisp-compile unix
/emacs
/*.el
297 execute
"${PYTHON}" build_mozc.py runtests
-c ${BUILD_TYPE} --test_jobs 1 || die
"Testing failed"
301 exeinto
/usr
/libexec
/mozc
302 doexe out_linux
/${BUILD_TYPE}/mozc_server
305 doexe out_linux
/${BUILD_TYPE}/mozc_tool
308 if use renderer
; then
309 doexe out_linux
/${BUILD_TYPE}/mozc_renderer
312 insinto
/usr
/libexec
/mozc
/documents
313 doins data
/installer
/credits_en.html
316 dobin out_linux
/${BUILD_TYPE}/mozc_emacs_helper
317 elisp-install
${PN} unix
/emacs
/*.
{el
,elc
}
318 elisp-site-file-install
"${FILESDIR}/${SITEFILE}" ${PN}
322 exeinto /usr/$(get_libdir)/fcitx
323 doexe out_linux/${BUILD_TYPE}/fcitx-mozc.so
325 insinto /usr/share/fcitx/addon
326 doins unix/fcitx/fcitx-mozc.conf
328 insinto /usr/share/fcitx/inputmethod
329 doins unix/fcitx/mozc.conf
331 insinto /usr/share/fcitx/mozc/icon
332 newins data/images/product_icon_32bpp-128.png mozc.png
334 for image in ../../fcitx-${PN}/src/data/images/unix/ui-*.png; do
335 newins "${image}" "mozc-${image#../../fcitx-${PN}/src/data/images/unix/ui-}"
339 for mo_file in out_linux/${BUILD_TYPE}/gen/unix/fcitx/po/*.mo; do
340 locale="${mo_file##*/}"
341 locale="${locale%.mo}"
342 insinto /usr/share/locale/${locale}/LC_MESSAGES
343 newins "${mo_file}" fcitx-mozc.mo
347 exeinto /usr/$(get_libdir)/fcitx5
348 doexe out_linux/${BUILD_TYPE}/fcitx5-mozc.so
350 insinto /usr/share/fcitx5/addon
351 newins unix/fcitx5/mozc-addon.conf mozc.conf
353 insinto /usr/share/fcitx5/inputmethod
354 doins unix/fcitx5/mozc.conf
356 local orgfcitx5="org.fcitx.Fcitx5.fcitx-mozc
"
357 newicon -s 128 data/images/product_icon_32bpp-128.png ${orgfcitx5}.png
358 newicon -s 128 data/images/product_icon_32bpp-128.png fcitx-mozc.png
359 newicon -s 32 data/images/unix/ime_product_icon_opensource-32.png ${orgfcitx5}.png
360 newicon -s 32 data/images/unix/ime_product_icon_opensource-32.png fcitx-mozc.png
361 for uiimg in ../../fcitx5-mozc/scripts/icons/ui-*.png; do
363 newicon -s 48 ${uiimg} ${orgfcitx5}-${dimg/_/-}
364 newicon -s 48 ${uiimg} fcitx-mozc-${dimg/_/-}
368 for mo_file in unix/fcitx5/po/*.po; do
369 locale="${mo_file##*/}"
370 locale="${locale%.po}"
371 msgfmt ${mo_file} -o ${mo_file/.po/.mo} || die
372 insinto /usr/share/locale/${locale}/LC_MESSAGES
373 newins "${mo_file/.po/.mo}" fcitx5-mozc.mo
379 newexe out_linux/${BUILD_TYPE}/ibus_mozc ibus-engine-mozc
381 insinto /usr/share/ibus/component
382 doins out_linux/${BUILD_TYPE}/gen/unix/ibus/mozc.xml
384 insinto /usr/share/ibus-mozc
385 newins data/images/unix/ime_product_icon_opensource-32.png product_icon.png
387 for image in data/images/unix/ui-*.png; do
388 newins "${image}" "${image#data/images/unix/ui-}"
395 elog "ENVIRONMENTAL VARIABLES
"
397 elog "MOZC_SERVER_DIRECTORY
"
398 elog " Mozc server directory
"
399 elog " Value used by default
: \"${EPREFIX}/usr
/libexec
/mozc
\""
400 elog "MOZC_DOCUMENTS_DIRECTORY
"
401 elog " Mozc documents directory
"
402 elog " Value used by default
: \"${EPREFIX}/usr
/libexec
/mozc
/documents
\""
403 elog "MOZC_CONFIGURATION_DIRECTORY
"
404 elog " Mozc configuration directory
"
405 elog " Value used by default
: \"~
/.mozc
\""
409 elog "USAGE IN EMACS
"
411 elog "mozc-mode is minor mode to input Japanese text using Mozc server.
"
412 elog "mozc-mode can be used via LEIM
(Library of Emacs Input Method
).
"
414 elog "In order to use mozc-mode by default
, the following settings should be added to
"
415 elog "Emacs init
file (~
/.emacs.d
/init.el or ~
/.emacs
):"
417 elog " (require
'mozc)"
418 elog " (set-language-environment \"Japanese\")"
419 elog " (setq default-input-method \"japanese-mozc\")"
421 elog "With the above settings, typing C-\\ (which is bound to \"toggle-input-method\""
422 elog "by default) will enable mozc-mode."
424 elog "Alternatively, at run time, after loading mozc.el, mozc-mode can be activated by"
425 elog "calling \"set-input-method\" and entering \"japanese-mozc\"."