sys-kernel/liquorix-sources: Bump to new version, drop old version.
[gentoo-zh.git] / app-i18n / mozc / mozc-2.26.4220_p20211115025624_p20220214004422.ebuild
blob5c65f69ee033b710a13f8307d644b652323c30e6
1 # Copyright 2010-2022 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
4 EAPI="8"
5 PYTHON_COMPAT=( python3_{8..10} )
7 inherit elisp-common multiprocessing python-any-r1 toolchain-funcs desktop xdg
9 if [[ "${PV}" == "9999" ]]; then
10 inherit git-r3
12 EGIT_REPO_URI="https://github.com/google/mozc"
13 EGIT_SUBMODULES=(src/third_party/japanese_usage_dictionary)
14 else
15 MOZC_GIT_REVISION="c9c46b8fb015c13465053eeecb380c8e736d79e9"
16 MOZC_DATE="${PV#*_p}"
17 MOZC_DATE="${MOZC_DATE%%_p*}"
19 FCITX_MOZC_GIT_REVISION="36fb17175ceb2ade323ad729e0d7cfb06f98e675"
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="a4a66772e33746b91e99caceecced9a28507e925"
25 JAPANESE_USAGE_DICTIONARY_DATE="20180701040110"
28 DESCRIPTION="Mozc - Japanese input method editor"
29 HOMEPAGE="https://github.com/google/mozc"
30 if [[ "${PV}" == "9999" ]]; then
31 SRC_URI=""
32 else
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"
38 # Mozc: BSD
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"
43 SLOT="0"
44 #KEYWORDS="~amd64 ~arm64 ~ppc64 x86"
45 KEYWORDS="~amd64 ~x86"
46 IUSE="debug emacs fcitx4 fcitx5 +gui ibus renderer test"
47 REQUIRED_USE="|| ( emacs fcitx4 fcitx5 ibus )"
48 RESTRICT="!test? ( test )"
50 BDEPEND="$(python_gen_any_dep 'dev-python/six[${PYTHON_USEDEP}]')
51 >=dev-libs/protobuf-3.0.0
52 dev-util/gyp
53 dev-util/ninja
54 virtual/pkgconfig
55 emacs? ( app-editors/emacs:* )
56 fcitx4? ( sys-devel/gettext )
57 fcitx5? ( sys-devel/gettext )"
58 DEPEND=">=dev-cpp/abseil-cpp-20211102[cxx17(+)]
59 >=dev-libs/protobuf-3.0.0:=
60 fcitx4? (
61 app-i18n/fcitx:4
62 virtual/libintl
64 fcitx5? (
65 app-i18n/fcitx:5
66 app-i18n/libime
67 sys-devel/gettext
68 virtual/libintl
70 gui? (
71 dev-qt/qtcore:5
72 dev-qt/qtgui:5
73 dev-qt/qtwidgets:5
75 ibus? (
76 >=app-i18n/ibus-1.4.1
77 dev-libs/glib:2
78 x11-libs/libxcb
80 renderer? (
81 dev-libs/glib:2
82 x11-libs/cairo
83 x11-libs/gtk+:2
84 x11-libs/pango
86 test? (
87 >=dev-cpp/gtest-1.8.0
88 dev-libs/jsoncpp
90 RDEPEND=">=dev-cpp/abseil-cpp-20211102[cxx17(+)]
91 >=dev-libs/protobuf-3.0.0:=
92 emacs? ( app-editors/emacs:* )
93 fcitx4? (
94 app-i18n/fcitx:4
95 virtual/libintl
97 fcitx5? (
98 app-i18n/fcitx:5
99 app-i18n/libime
100 sys-devel/gettext
101 virtual/libintl
103 gui? (
104 dev-qt/qtcore:5
105 dev-qt/qtgui:5
106 dev-qt/qtwidgets:5
108 ibus? (
109 >=app-i18n/ibus-1.4.1
110 dev-libs/glib:2
111 x11-libs/libxcb
113 renderer? (
114 dev-libs/glib:2
115 x11-libs/cairo
116 x11-libs/gtk+:2
117 x11-libs/pango
120 S="${WORKDIR}/${P}/src"
122 SITEFILE="50${PN}-gentoo.el"
124 execute() {
125 einfo "$@"
126 "$@"
129 python_check_deps() {
130 has_version -b "dev-python/six[${PYTHON_USEDEP}]"
133 src_unpack() {
134 if [[ "${PV}" == "9999" ]]; then
135 git-r3_src_unpack
137 if use fcitx4 || use fcitx5; then
138 local EGIT_SUBMODULES=()
139 git-r3_fetch https://github.com/fcitx/mozc refs/heads/fcitx
140 git-r3_checkout https://github.com/fcitx/mozc "${WORKDIR}/fcitx-mozc"
142 if use fcitx5; then
143 cp -pr "${WORKDIR}"/fcitx{,5}-mozc || die
145 else
146 unpack ${PN}-${PV%%_p*}-${MOZC_DATE}.tar.gz
147 mv mozc-${MOZC_GIT_REVISION} ${P} || die
149 unpack japanese-usage-dictionary-${JAPANESE_USAGE_DICTIONARY_DATE}.tar.gz
150 cp -p japanese-usage-dictionary-${JAPANESE_USAGE_DICTIONARY_GIT_REVISION}/usage_dict.txt ${P}/src/third_party/japanese_usage_dictionary || die
152 unpack fcitx-${PN}-${PV%%_p*}-${FCITX_MOZC_DATE}.tar.gz
153 if use fcitx4; then
154 cp -pr mozc-${FCITX_MOZC_GIT_REVISION} fcitx-${PN} || die
156 if use fcitx5; then
157 cp -pr mozc-${FCITX_MOZC_GIT_REVISION} fcitx5-${PN} || die
160 xz -cd "${FILESDIR}"/${PN}-2.26.4220-system_abseil-cpp-20211102.patch.xz > \
161 "${S}"/${PN}-2.26.4220-system_abseil-cpp-20211102.patch || die
164 src_prepare() {
165 if use fcitx4; then
166 cp -pr "${WORKDIR}/fcitx-mozc/src/unix/fcitx" unix || die
168 if use fcitx5; then
169 cp -pr "${WORKDIR}/fcitx5-mozc/src/unix/fcitx5" unix || die
172 pushd "${WORKDIR}/${P}" > /dev/null || die
174 eapply "${S}/${PN}-2.26.4220-system_abseil-cpp-20211102.patch"
175 eapply "${FILESDIR}/${PN}-2.26.4220-system_gtest.patch"
176 eapply "${FILESDIR}/${PN}-2.26.4220-system_jsoncpp.patch"
177 eapply "${FILESDIR}/${PN}-2.26.4220-environmental_variables.patch"
178 # eapply "${FILESDIR}/${PN}-2.26.4220-server_path_check-20211102.patch"
180 eapply_user
182 popd > /dev/null || die
184 sed \
185 -e "s/def GypMain(options, unused_args):/def GypMain(options, gyp_args):/" \
186 -e "s/RunOrDie(gyp_command + gyp_options)/RunOrDie(gyp_command + gyp_options + gyp_args)/" \
187 -e "s/RunOrDie(\[ninja/&, '-j$(makeopts_jobs "${MAKEOPTS}" 999)', '-l$(makeopts_loadavg "${MAKEOPTS}" 0)', '-v'/" \
188 -i build_mozc.py || die
190 local ar=($(tc-getAR))
191 local cc=($(tc-getCC))
192 local cxx=($(tc-getCXX))
193 local ld=($(tc-getLD))
194 local nm=($(tc-getNM))
195 local readelf=($(tc-getREADELF))
197 # Use absolute paths. Non-absolute paths are mishandled by GYP.
198 ar[0]=$(type -P ${ar[0]})
199 cc[0]=$(type -P ${cc[0]})
200 cxx[0]=$(type -P ${cxx[0]})
201 ld[0]=$(type -P ${ld[0]})
202 nm[0]=$(type -P ${nm[0]})
203 readelf[0]=$(type -P ${readelf[0]})
205 sed \
206 -e "s:<!(which ar):${ar[@]}:" \
207 -e "s:<!(which clang):${cc[@]}:" \
208 -e "s:<!(which clang++):${cxx[@]}:" \
209 -e "s:<!(which ld):${ld[@]}:" \
210 -e "s:<!(which nm):${nm[@]}:" \
211 -e "s:<!(which readelf):${readelf[@]}:" \
212 -i gyp/common.gypi || die
214 # https://github.com/google/mozc/issues/489
215 sed \
216 -e "/'-lc++'/d" \
217 -e "/'-stdlib=libc++'/d" \
218 -e "/'linux_ldflags'/a\ '-Wl,--copy-dt-needed-entries'," \
219 -i gyp/common.gypi || die
222 src_configure() {
223 if use debug; then
224 BUILD_TYPE="Debug"
225 else
226 BUILD_TYPE="Release"
229 local gyp_arguments=()
231 if tc-is-gcc; then
232 gyp_arguments+=(-D compiler_host=gcc -D compiler_target=gcc)
233 elif tc-is-clang; then
234 gyp_arguments+=(-D compiler_host=clang -D compiler_target=clang)
235 else
236 gyp_arguments+=(-D compiler_host=unknown -D compiler_target=unknown)
239 gyp_arguments+=(-D debug_extra_cflags=)
240 gyp_arguments+=(-D release_extra_cflags=)
242 gyp_arguments+=(-D use_fcitx=$(usex fcitx4 YES NO))
243 gyp_arguments+=(-D use_fcitx5=$(usex fcitx5 YES NO))
244 gyp_arguments+=(-D use_libibus=$(usex ibus 1 0))
245 gyp_arguments+=(-D use_libprotobuf=1)
246 gyp_arguments+=(-D use_system_abseil_cpp=1)
247 gyp_arguments+=(-D use_system_gtest=$(usex test 1 0))
248 gyp_arguments+=(-D use_system_jsoncpp=$(usex test 1 0))
249 gyp_arguments+=(-D enable_gtk_renderer=$(usex renderer 1 0))
251 gyp_arguments+=(-D server_dir="${EPREFIX}/usr/libexec/mozc")
252 gyp_arguments+=(-D document_dir="${EPREFIX}/usr/libexec/mozc/documents")
254 if use ibus; then
255 gyp_arguments+=(-D ibus_mozc_path="${EPREFIX}/usr/libexec/ibus-engine-mozc")
256 gyp_arguments+=(-D ibus_mozc_icon_path="${EPREFIX}/usr/share/ibus-mozc/product_icon.png")
259 unset AR CC CXX LD NM READELF
261 execute "${PYTHON}" build_mozc.py gyp \
262 --gypdir="${EPREFIX}/usr/bin" \
263 --server_dir="${EPREFIX}/usr/libexec/mozc" \
264 --verbose \
265 $(usex gui "" --noqt) \
266 -- "${gyp_arguments[@]}" || die "Configuration failed"
269 src_compile() {
270 local targets=(server/server.gyp:mozc_server)
271 if use emacs; then
272 targets+=(unix/emacs/emacs.gyp:mozc_emacs_helper)
274 if use fcitx4; then
275 targets+=(unix/fcitx/fcitx.gyp:fcitx-mozc)
277 if use fcitx5; then
278 targets+=(unix/fcitx5/fcitx5.gyp:fcitx5-mozc)
280 if use gui; then
281 targets+=(gui/gui.gyp:mozc_tool)
283 if use ibus; then
284 targets+=(unix/ibus/ibus.gyp:ibus_mozc)
286 if use renderer; then
287 targets+=(renderer/renderer.gyp:mozc_renderer)
289 if use test; then
290 targets+=(gyp/tests.gyp:unittests)
293 execute "${PYTHON}" build_mozc.py build -c ${BUILD_TYPE} -v "${targets[@]}" || die "Building failed"
295 if use emacs; then
296 elisp-compile unix/emacs/*.el
300 src_test() {
301 execute "${PYTHON}" build_mozc.py runtests -c ${BUILD_TYPE} --test_jobs 1 || die "Testing failed"
304 src_install() {
305 exeinto /usr/libexec/mozc
306 doexe out_linux/${BUILD_TYPE}/mozc_server
308 if use gui; then
309 doexe out_linux/${BUILD_TYPE}/mozc_tool
312 if use renderer; then
313 doexe out_linux/${BUILD_TYPE}/mozc_renderer
316 insinto /usr/libexec/mozc/documents
317 doins data/installer/credits_en.html
319 if use emacs; then
320 dobin out_linux/${BUILD_TYPE}/mozc_emacs_helper
321 elisp-install ${PN} unix/emacs/*.{el,elc}
322 elisp-site-file-install "${FILESDIR}/${SITEFILE}" ${PN}
325 if use fcitx4; then
326 exeinto /usr/$(get_libdir)/fcitx
327 doexe out_linux/${BUILD_TYPE}/fcitx-mozc.so
329 insinto /usr/share/fcitx/addon
330 doins unix/fcitx/fcitx-mozc.conf
332 insinto /usr/share/fcitx/inputmethod
333 doins unix/fcitx/mozc.conf
335 insinto /usr/share/fcitx/mozc/icon
336 newins data/images/product_icon_32bpp-128.png mozc.png
337 local image
338 for image in ../../fcitx-${PN}/src/data/images/unix/ui-*.png; do
339 newins "${image}" "mozc-${image#../../fcitx-${PN}/src/data/images/unix/ui-}"
340 done
342 local locale mo_file
343 for mo_file in out_linux/${BUILD_TYPE}/gen/unix/fcitx/po/*.mo; do
344 locale="${mo_file##*/}"
345 locale="${locale%.mo}"
346 insinto /usr/share/locale/${locale}/LC_MESSAGES
347 newins "${mo_file}" fcitx-mozc.mo
348 done
350 if use fcitx5; then
351 exeinto /usr/$(get_libdir)/fcitx5
352 doexe out_linux/${BUILD_TYPE}/fcitx5-mozc.so
354 insinto /usr/share/fcitx5/addon
355 newins unix/fcitx5/mozc-addon.conf mozc.conf
357 insinto /usr/share/fcitx5/inputmethod
358 doins unix/fcitx5/mozc.conf
360 local orgfcitx5="org.fcitx.Fcitx5.fcitx-mozc"
361 newicon -s 128 data/images/product_icon_32bpp-128.png ${orgfcitx5}.png
362 newicon -s 128 data/images/product_icon_32bpp-128.png fcitx-mozc.png
363 newicon -s 32 data/images/unix/ime_product_icon_opensource-32.png ${orgfcitx5}.png
364 newicon -s 32 data/images/unix/ime_product_icon_opensource-32.png fcitx-mozc.png
365 for uiimg in ../../fcitx5-mozc/scripts/icons/ui-*.png; do
366 dimg=${uiimg#*ui-}
367 newicon -s 48 ${uiimg} ${orgfcitx5}-${dimg/_/-}
368 newicon -s 48 ${uiimg} fcitx-mozc-${dimg/_/-}
369 done
371 local locale mo_file
372 for mo_file in unix/fcitx5/po/*.po; do
373 locale="${mo_file##*/}"
374 locale="${locale%.po}"
375 msgfmt ${mo_file} -o ${mo_file/.po/.mo} || die
376 insinto /usr/share/locale/${locale}/LC_MESSAGES
377 newins "${mo_file/.po/.mo}" fcitx5-mozc.mo
378 done
379 msgfmt --xml -d unix/fcitx5/po/ --template unix/fcitx5/org.fcitx.Fcitx5.Addon.Mozc.metainfo.xml.in -o \
380 unix/fcitx5/org.fcitx.Fcitx5.Addon.Mozc.metainfo.xml || die
381 insinto /usr/share/metainfo
382 doins unix/fcitx5/org.fcitx.Fcitx5.Addon.Mozc.metainfo.xml
385 if use ibus; then
386 exeinto /usr/libexec
387 newexe out_linux/${BUILD_TYPE}/ibus_mozc ibus-engine-mozc
389 insinto /usr/share/ibus/component
390 doins out_linux/${BUILD_TYPE}/gen/unix/ibus/mozc.xml
392 insinto /usr/share/ibus-mozc
393 newins data/images/unix/ime_product_icon_opensource-32.png product_icon.png
394 local image
395 for image in data/images/unix/ui-*.png; do
396 newins "${image}" "${image#data/images/unix/ui-}"
397 done
401 pkg_postinst() {
402 elog
403 elog "ENVIRONMENTAL VARIABLES"
404 elog
405 elog "MOZC_SERVER_DIRECTORY"
406 elog " Mozc server directory"
407 elog " Value used by default: \"${EPREFIX}/usr/libexec/mozc\""
408 elog "MOZC_DOCUMENTS_DIRECTORY"
409 elog " Mozc documents directory"
410 elog " Value used by default: \"${EPREFIX}/usr/libexec/mozc/documents\""
411 elog "MOZC_CONFIGURATION_DIRECTORY"
412 elog " Mozc configuration directory"
413 elog " Value used by default: \"~/.mozc\""
414 elog
415 if use emacs; then
416 elog
417 elog "USAGE IN EMACS"
418 elog
419 elog "mozc-mode is minor mode to input Japanese text using Mozc server."
420 elog "mozc-mode can be used via LEIM (Library of Emacs Input Method)."
421 elog
422 elog "In order to use mozc-mode by default, the following settings should be added to"
423 elog "Emacs init file (~/.emacs.d/init.el or ~/.emacs):"
424 elog
425 elog " (require 'mozc)"
426 elog " (set-language-environment \"Japanese\")"
427 elog " (setq default-input-method \"japanese-mozc\")"
428 elog
429 elog "With the above settings, typing C-\\ (which is bound to \"toggle-input-method\""
430 elog "by default) will enable mozc-mode."
431 elog
432 elog "Alternatively, at run time, after loading mozc.el, mozc-mode can be activated by"
433 elog "calling \"set-input-method\" and entering \"japanese-mozc\"."
434 elog
436 elisp-site-regen
438 xdg_pkg_postinst
441 pkg_postrm() {
442 if use emacs; then
443 elisp-site-regen
445 xdg_pkg_postrm