Gentoo Archives: gentoo-dev

From: Andreas Sturmlechner <asturm@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: Re: [gentoo-dev] [PATCH v2 1/3] ecm.eclass: New eclass
Date: Sun, 10 Nov 2019 13:28:10
Message-Id: 17486305.dnObLhtpFU@tuxk10
In Reply to: Re: [gentoo-dev] [PATCH 1/3] ecm-utils.eclass: New eclass by "Michał Górny"
1 --- /dev/null
2 +++ b/eclass/ecm.eclass
3 @@ -0,0 +1,639 @@
4 +# Copyright 1999-2019 Gentoo Authors
5 +# Distributed under the terms of the GNU General Public License v2
6 +
7 +# @ECLASS: ecm.eclass
8 +# @MAINTAINER:
9 +# kde@g.o
10 +# @SUPPORTED_EAPIS: 7
11 +# @BLURB: Support eclass for packages that use KDE Frameworks with ECM.
12 +# @DESCRIPTION:
13 +# This eclass is intended to streamline the creation of ebuilds for packages
14 +# that use cmake and KDE Frameworks' extra-cmake-modules, thereby following
15 +# some of their packaging conventions. It is primarily intended for the tree
16 +# upstream release groups (Frameworks, Plasma, Applications) but also for any
17 +# other package that follows similar conventions.
18 +#
19 +# This eclass unconditionally inherits cmake-utils.eclass and all its public
20 +# variables and helper functions (not phase functions) may be considered as part
21 +# of this eclass's API.
22 +#
23 +# This eclass's phase functions are not intended to be mixed and matched, so if
24 +# any phase functions are overridden the version here should also be called.
25 +#
26 +# Porting from kde5.class
27 +# - Convert all add_*_dep dependency functions to regular dependencies
28 +# - Manually set LICENSE
29 +# - Manually set SLOT
30 +# - Rename vars and function names as needed, see kde5.eclass PORTING comments
31 +# - Instead of FRAMEWORKS_MINIMAL, define KFMIN in ebuilds and use it for deps
32 +
33 +if [[ -z ${_ECM_UTILS_ECLASS} ]]; then
34 +_ECM_UTILS_ECLASS=1
35 +
36 +# @ECLASS-VARIABLE: VIRTUALX_REQUIRED
37 +# @DESCRIPTION:
38 +# For proper description see virtualx.eclass manpage.
39 +# Here we redefine default value to be manual, if your package needs virtualx
40 +# for tests you should proceed with setting VIRTUALX_REQUIRED=test.
41 +: ${VIRTUALX_REQUIRED:=manual}
42 +
43 +inherit cmake-utils flag-o-matic toolchain-funcs virtualx xdg
44 +
45 +case ${EAPI} in
46 + 7) ;;
47 + *) die "EAPI=${EAPI:-0} is not supported" ;;
48 +esac
49 +
50 +if [[ -v KDE_GCC_MINIMAL ]]; then
51 + EXPORT_FUNCTIONS pkg_pretend
52 +fi
53 +
54 +EXPORT_FUNCTIONS pkg_setup src_prepare src_configure src_test pkg_preinst pkg_postinst pkg_postrm
55 +
56 +# @ECLASS-VARIABLE: ECM_KDEINSTALLDIRS
57 +# @DESCRIPTION:
58 +# Assume the package is using KDEInstallDirs macro and switch
59 +# KDE_INSTALL_USE_QT_SYS_PATHS to ON. If set to "false", do nothing.
60 +: ${ECM_KDEINSTALLDIRS:=true}
61 +
62 +# @ECLASS-VARIABLE: ECM_NONGUI
63 +# @DEFAULT_UNSET
64 +# @DESCRIPTION:
65 +# By default, for all CATEGORIES except kde-frameworks, assume we are building
66 +# a GUI application. Add dependency on kde-frameworks/breeze-icons or
67 +# kde-frameworks/oxygen-icons and run the xdg.eclass routines for pkg_preinst,
68 +# pkg_postinst and pkg_postrm. If set to "true", do nothing.
69 +if [[ ${CATEGORY} = kde-frameworks ]]; then
70 + : ${ECM_NONGUI:=true}
71 +fi
72 +: ${ECM_NONGUI:=false}
73 +
74 +# @ECLASS-VARIABLE: ECM_DEBUG
75 +# @DESCRIPTION:
76 +# Add "debug" to IUSE. If !debug, add -DNDEBUG (via cmake-utils_src_configure)
77 +# and -DQT_NO_DEBUG to CPPFLAGS. If set to "false", do nothing.
78 +: ${ECM_DEBUG:=true}
79 +
80 +# @ECLASS-VARIABLE: ECM_DESIGNERPLUGIN
81 +# @DESCRIPTION:
82 +# If set to "true", add "designer" to IUSE to toggle build of designer plugins
83 +# and add the necessary BDEPEND. If set to "false", do nothing.
84 +: ${ECM_DESIGNERPLUGIN:=false}
85 +
86 +# @ECLASS-VARIABLE: ECM_EXAMPLES
87 +# @DESCRIPTION:
88 +# By default unconditionally ignore a top-level examples subdirectory.
89 +# If set to "true", add "examples" to IUSE to toggle adding that subdirectory.
90 +: ${ECM_EXAMPLES:=false}
91 +
92 +# @ECLASS-VARIABLE: ECM_HANDBOOK
93 +# @DESCRIPTION:
94 +# Will accept "true", "false", "optional", "forceoptional". If set to "false",
95 +# do nothing.
96 +# Otherwise, add "+handbook" to IUSE, add the appropriate dependency, and let
97 +# KF5DocTools generate and install the handbook from docbook file(s) found in
98 +# ECM_HANDBOOK_DIR. However if !handbook, disable build of ECM_HANDBOOK_DIR
99 +# in CMakeLists.txt.
100 +# If set to "optional", build with -DCMAKE_DISABLE_FIND_PACKAGE_KF5DocTools=ON
101 +# when !handbook. In case package requires KF5KDELibs4Support, see next:
102 +# If set to "forceoptional", remove a KF5DocTools dependency from the root
103 +# CMakeLists.txt in addition to the above.
104 +: ${ECM_HANDBOOK:=false}
105 +
106 +# @ECLASS-VARIABLE: ECM_HANDBOOK_DIR
107 +# @DESCRIPTION:
108 +# Specifies the directory containing the docbook file(s) relative to ${S} to
109 +# be processed by KF5DocTools (kdoctools_install).
110 +: ${ECM_HANDBOOK_DIR:=doc}
111 +
112 +# @ECLASS-VARIABLE: ECM_PO_DIRS
113 +# @DESCRIPTION:
114 +# Specifies directories of l10n files relative to ${S} to be processed by
115 +# KF5I18n (ki18n_install). If IUSE nls exists and is disabled then disable
116 +# build of these directories in CMakeLists.txt.
117 +: ${ECM_PO_DIRS:="po poqm"}
118 +
119 +# @ECLASS-VARIABLE: ECM_QTHELP
120 +# @DEFAULT_UNSET
121 +# @DESCRIPTION:
122 +# Default value for all CATEGORIES except kde-frameworks is "false".
123 +# If set to "true", add "doc" to IUSE, add the appropriate dependency, let
124 +# -DBUILD_QCH=ON generate and install Qt compressed help files when USE=doc.
125 +# If set to "false", do nothing.
126 +if [[ ${CATEGORY} = kde-frameworks ]]; then
127 + : ${ECM_QTHELP:=true}
128 +fi
129 +: ${ECM_QTHELP:=false}
130 +
131 +# @ECLASS-VARIABLE: ECM_TEST
132 +# @DEFAULT_UNSET
133 +# @DESCRIPTION:
134 +# Will accept "true", "false", "optional", "forceoptional",
135 +# "forceoptional-recursive".
136 +# Default value is "false", except for CATEGORY=kde-frameworks where it is
137 +# set to "true". If set to "false", do nothing.
138 +# For any other value, add "test" to IUSE and DEPEND on dev-qt/qttest:5.
139 +# If set to "optional", build with -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Test=ON
140 +# when USE=!test.
141 +# If set to "forceoptional", punt Qt5Test dependency and ignore "autotests",
142 +# "test", "tests" subdirs from top-level CMakeLists.txt when USE=!test.
143 +# If set to "forceoptional-recursive", punt Qt5Test dependencies and make
144 +# autotest(s), unittest(s) and test(s) subdirs from *any* CMakeLists.txt in
145 +# ${S} and below conditional on BUILD_TESTING when USE=!test. This is always
146 +# meant as a short-term fix and creates ${T}/${P}-tests-optional.patch to
147 +# refine and submit upstream.
148 +if [[ ${CATEGORY} = kde-frameworks ]]; then
149 + : ${ECM_TEST:=true}
150 +fi
151 +: ${ECM_TEST:=false}
152 +
153 +# @ECLASS-VARIABLE: KFMIN
154 +# @DESCRIPTION:
155 +# Minimum version of Frameworks to require. The default value is not going to
156 +# be changed unless we also bump EAPI, which usually implies (rev-)bumping.
157 +# Version will later be used to differentiate between KF5/Qt5 and KF6/Qt6.
158 +: ${KFMIN:=5.64.0}
159 +
160 +# @ECLASS-VARIABLE: KFSLOT
161 +# @INTERNAL
162 +# @DESCRIPTION:
163 +# KDE Frameworks and Qt slot dependency, implied by KFMIN version.
164 +: ${KFSLOT:=5}
165 +
166 +case ${ECM_NONGUI} in
167 + true) ;;
168 + false)
169 + # gui applications need breeze or oxygen for basic iconset, bug #564838
170 + if [[ -n ${_KDE5_ECLASS} ]] ; then
171 + RDEPEND+=" || (
172 + >=kde-frameworks/breeze-icons-${KFMIN}:${KFSLOT}
173 + kde-frameworks/oxygen-icons:*
174 + )"
175 + else
176 + RDEPEND+=" || (
177 + kde-frameworks/breeze-icons:*
178 + kde-frameworks/oxygen-icons:*
179 + )"
180 + fi
181 + ;;
182 + *)
183 + eerror "Unknown value for \${ECM_NONGUI}"
184 + die "Value ${ECM_NONGUI} is not supported"
185 + ;;
186 +esac
187 +
188 +case ${ECM_DEBUG} in
189 + true)
190 + IUSE+=" debug"
191 + ;;
192 + false) ;;
193 + *)
194 + eerror "Unknown value for \${ECM_DEBUG}"
195 + die "Value ${ECM_DEBUG} is not supported"
196 + ;;
197 +esac
198 +
199 +case ${ECM_DESIGNERPLUGIN} in
200 + true)
201 + IUSE+=" designer"
202 + if [[ -n ${_KDE5_ECLASS} ]] ; then
203 + BDEPEND+=" designer? ( >=dev-qt/designer-5.12.3:${KFSLOT} )"
204 + else
205 + BDEPEND+=" designer? ( dev-qt/designer:${KFSLOT} )"
206 + fi
207 + ;;
208 + false) ;;
209 + *)
210 + eerror "Unknown value for \${ECM_DESIGNERPLUGIN}"
211 + die "Value ${ECM_DESIGNERPLUGIN} is not supported"
212 + ;;
213 +esac
214 +
215 +# @ECLASS-VARIABLE: KDE_DESIGNERPLUGIN
216 +# @DESCRIPTION:
217 +# If set to "false", do nothing.
218 +# Otherwise, add "designer" to IUSE to toggle build of designer plugins
219 +# and add the necessary BDEPEND.
220 +# TODO: drop after KDE Applications 19.08.3 removal
221 +: ${KDE_DESIGNERPLUGIN:=false}
222 +case ${KDE_DESIGNERPLUGIN} in
223 + true)
224 + IUSE+=" designer"
225 + BDEPEND+="
226 + designer? ( >=kde-frameworks/kdesignerplugin-${KFMIN}:${KFSLOT} )
227 + "
228 + ;;
229 + false) ;;
230 + *)
231 + eerror "Unknown value for \${KDE_DESIGNERPLUGIN}"
232 + die "Value ${KDE_DESIGNERPLUGIN} is not supported"
233 + ;;
234 +esac
235 +
236 +case ${ECM_EXAMPLES} in
237 + true)
238 + IUSE+=" examples"
239 + ;;
240 + false) ;;
241 + *)
242 + eerror "Unknown value for \${ECM_EXAMPLES}"
243 + die "Value ${ECM_EXAMPLES} is not supported"
244 + ;;
245 +esac
246 +
247 +case ${ECM_HANDBOOK} in
248 + true|optional|forceoptional)
249 + IUSE+=" +handbook"
250 + BDEPEND+=" handbook? ( >=kde-frameworks/kdoctools-${KFMIN}:${KFSLOT} )"
251 + ;;
252 + false) ;;
253 + *)
254 + eerror "Unknown value for \${ECM_HANDBOOK}"
255 + die "Value ${ECM_HANDBOOK} is not supported"
256 + ;;
257 +esac
258 +
259 +case ${ECM_QTHELP} in
260 + true)
261 + IUSE+=" doc"
262 + if [[ -n ${_KDE5_ECLASS} ]] ; then
263 + COMMONDEPEND+=" doc? ( >=dev-qt/qt-docs-5.12.3:${KFSLOT} )"
264 + BDEPEND+=" >=dev-qt/qthelp-5.12.3:${KFSLOT} )"
265 + else
266 + COMMONDEPEND+=" doc? ( dev-qt/qt-docs:${KFSLOT} )"
267 + BDEPEND+=" dev-qt/qthelp:${KFSLOT} )"
268 + fi
269 + BDEPEND+=" doc? ( >=app-doc/doxygen-1.8.13-r1 )"
270 + ;;
271 + false) ;;
272 + *)
273 + eerror "Unknown value for \${ECM_QTHELP}"
274 + die "Value ${ECM_QTHELP} is not supported"
275 + ;;
276 +esac
277 +
278 +case ${ECM_TEST} in
279 + true|optional|forceoptional|forceoptional-recursive)
280 + IUSE+=" test"
281 + if [[ -n ${_KDE5_ECLASS} ]] ; then
282 + DEPEND+=" test? ( >=dev-qt/qttest-5.12.3:${KFSLOT} )"
283 + else
284 + DEPEND+=" test? ( dev-qt/qttest:${KFSLOT} )"
285 + fi
286 + RESTRICT+=" !test? ( test )"
287 + ;;
288 + false) ;;
289 + *)
290 + eerror "Unknown value for \${ECM_TEST}"
291 + die "Value ${ECM_TEST} is not supported"
292 + ;;
293 +esac
294 +
295 +BDEPEND+=" >=kde-frameworks/extra-cmake-modules-${KFMIN}:${KFSLOT}"
296 +RDEPEND+=" >=kde-frameworks/kf-env-4"
297 +if [[ -n ${_KDE5_ECLASS} ]] ; then
298 + COMMONDEPEND+=" >=dev-qt/qtcore-5.12.3:${KFSLOT}"
299 +else
300 + COMMONDEPEND+=" dev-qt/qtcore:${KFSLOT}"
301 +fi
302 +
303 +DEPEND+=" ${COMMONDEPEND}"
304 +RDEPEND+=" ${COMMONDEPEND}"
305 +unset COMMONDEPEND
306 +
307 +# @ECLASS-VARIABLE: KDE_GCC_MINIMAL
308 +# @DEFAULT_UNSET
309 +# @DESCRIPTION:
310 +# Minimum version of active GCC to require. This is checked in
311 +# ecm_pkg_pretend and ecm_pkg_setup.
312 +
313 +# @FUNCTION: _ecm_check_gcc_version
314 +# @INTERNAL
315 +# @DESCRIPTION:
316 +# Determine if the current GCC version is acceptable, otherwise die.
317 +_ecm_check_gcc_version() {
318 + if [[ ${MERGE_TYPE} != binary && -v KDE_GCC_MINIMAL ]] && tc-is-gcc; then
319 +
320 + local version=$(gcc-version)
321 +
322 + debug-print "GCC version check activated"
323 + debug-print "Version detected: ${version}"
324 + debug-print "Version required: ${KDE_GCC_MINIMAL}"
325 +
326 + ver_test ${version} -lt ${KDE_GCC_MINIMAL} &&
327 + die "Sorry, but gcc-${KDE_GCC_MINIMAL} or later is required for this package (found ${version})."
328 + fi
329 +}
330 +
331 +# @FUNCTION: _ecm_strip_handbook_translations
332 +# @INTERNAL
333 +# @DESCRIPTION:
334 +# If LINGUAS is defined, enable only the requested translations when required.
335 +_ecm_strip_handbook_translations() {
336 + if ! [[ -v LINGUAS ]]; then
337 + return
338 + fi
339 +
340 + local lang po
341 + for po in ${ECM_PO_DIRS}; do
342 + if [[ -d ${po} ]] ; then
343 + pushd ${po} > /dev/null || die
344 + local lang
345 + for lang in *; do
346 + if [[ -e ${lang} ]] && ! has ${lang/.po/} ${LINGUAS} ; then
347 + case ${lang} in
348 + cmake_modules | \
349 + CMakeLists.txt | \
350 + ${PN}.pot) ;;
351 + *) rm -r ${lang} || die ;;
352 + esac
353 + if [[ -e CMakeLists.txt ]] ; then
354 + cmake_comment_add_subdirectory ${lang}
355 + sed -e "/add_subdirectory([[:space:]]*${lang}\/.*[[:space:]]*)/d" \
356 + -i CMakeLists.txt || die
357 + fi
358 + fi
359 + done
360 + popd > /dev/null || die
361 + fi
362 + done
363 +}
364 +
365 +# @FUNCTION: ecm_punt_bogus_dep
366 +# @USAGE: <prefix> <dependency>
367 +# @DESCRIPTION:
368 +# Removes a specified dependency from a find_package call with multiple
369 +# components.
370 +ecm_punt_bogus_dep() {
371 + local prefix=${1}
372 + local dep=${2}
373 +
374 + if [[ ! -e "CMakeLists.txt" ]]; then
375 + return
376 + fi
377 +
378 + pcregrep -Mni "(?s)find_package\s*\(\s*${prefix}[^)]*?${dep}.*?\)" CMakeLists.txt > "${T}/bogus${dep}"
379 +
380 + # pcregrep returns non-zero on no matches/error
381 + if [[ $? -ne 0 ]] ; then
382 + return
383 + fi
384 +
385 + local length=$(wc -l "${T}/bogus${dep}" | cut -d " " -f 1)
386 + local first=$(head -n 1 "${T}/bogus${dep}" | cut -d ":" -f 1)
387 + local last=$(( length + first - 1))
388 +
389 + sed -e "${first},${last}s/${dep}//" -i CMakeLists.txt || die
390 +
391 + if [[ ${length} -eq 1 ]] ; then
392 + sed -e "/find_package\s*(\s*${prefix}\(\s\+\(REQUIRED\|CONFIG\|COMPONENTS\|\${[A-Z0-9_]*}\)\)\+\s*)/Is/^/# removed by ecm.eclass - /" -i CMakeLists.txt || die
393 + fi
394 +}
395 +
396 +# @FUNCTION: ecm_pkg_pretend
397 +# @DESCRIPTION:
398 +# Checks if the active compiler meets the minimum version requirements.
399 +# phase function is only exported if KDE_GCC_MINIMAL is defined.
400 +ecm_pkg_pretend() {
401 + debug-print-function ${FUNCNAME} "$@"
402 + _ecm_check_gcc_version
403 +}
404 +
405 +# @FUNCTION: ecm_pkg_setup
406 +# @DESCRIPTION:
407 +# Checks if the active compiler meets the minimum version requirements.
408 +ecm_pkg_setup() {
409 + debug-print-function ${FUNCNAME} "$@"
410 + _ecm_check_gcc_version
411 +}
412 +
413 +# @FUNCTION: ecm_src_prepare
414 +# @DESCRIPTION:
415 +# Wrapper for cmake-utils_src_prepare with lots of extra logic for magic
416 +# handling of linguas, tests, handbook etc.
417 +ecm_src_prepare() {
418 + debug-print-function ${FUNCNAME} "$@"
419 +
420 + cmake-utils_src_prepare
421 +
422 + # only build examples when required
423 + if ! { in_iuse examples && use examples; } ; then
424 + cmake_comment_add_subdirectory examples
425 + fi
426 +
427 + # only enable handbook when required
428 + if in_iuse handbook && ! use handbook ; then
429 + cmake_comment_add_subdirectory ${ECM_HANDBOOK_DIR}
430 +
431 + if [[ ${ECM_HANDBOOK} = forceoptional ]] ; then
432 + punt_bogus_dep KF5 DocTools
433 + sed -i -e "/kdoctools_install/ s/^/#DONT/" CMakeLists.txt || die
434 + fi
435 + fi
436 +
437 + # drop translations when nls is not wanted
438 + if in_iuse nls && ! use nls ; then
439 + local po
440 + for po in ${ECM_PO_DIRS}; do
441 + rm -rf ${po} || die
442 + done
443 + fi
444 +
445 + # don't change behaviour for kde5.eclass consumers
446 + # for ported ebuilds, limit playing field of this to kde-*/ categories
447 + if [[ -n ${_KDE5_ECLASS} ]] ; then
448 + _ecm_strip_handbook_translations # TODO: kde5.eclass cleanup
449 + elif [[ ${CATEGORY} = kde-* ]] ; then
450 + # always install unconditionally for kconfigwidgets - if you use
451 + # language X as system language, and there is a combobox with language
452 + # names, the translated language name for language Y is taken from
453 + # /usr/share/locale/Y/kf5_entry.desktop
454 + [[ ${PN} != kconfigwidgets ]] && _ecm_strip_handbook_translations
455 + fi
456 +
457 + # only build unit tests when required
458 + if ! { in_iuse test && use test; } ; then
459 + if [[ ${ECM_TEST} = forceoptional ]] ; then
460 + punt_bogus_dep Qt5 Test
461 + # if forceoptional, also cover non-kde categories
462 + cmake_comment_add_subdirectory autotests test tests
463 + elif [[ ${ECM_TEST} = forceoptional-recursive ]] ; then
464 + punt_bogus_dep Qt5 Test
465 + local f pf="${T}/${P}"-tests-optional.patch
466 + touch ${pf} || die "Failed to touch patch file"
467 + for f in $(find . -type f -name "CMakeLists.txt" -exec \
468 + grep -l "^\s*add_subdirectory\s*\(\s*.*\(auto|unit\)\?tests\?\s*)\s*\)" {} \;); do
469 + cp ${f} ${f}.old || die "Failed to prepare patch origfile"
470 + pushd ${f%/*} > /dev/null || die
471 + punt_bogus_dep Qt5 Test
472 + sed -i CMakeLists.txt -e \
473 + "/^#/! s/add_subdirectory\s*\(\s*.*\(auto|unit\)\?tests\?\s*)\s*\)/if(BUILD_TESTING)\n&\nendif()/" \
474 + || die
475 + popd > /dev/null || die
476 + diff -Naur ${f}.old ${f} 1>>${pf}
477 + rm ${f}.old || die "Failed to clean up"
478 + done
479 + eqawarn "Build system was modified by ECM_TEST=forceoptional-recursive."
480 + eqawarn "Unified diff file ready for pickup in:"
481 + eqawarn " ${pf}"
482 + eqawarn "Push it upstream to make this message go away."
483 + elif [[ ${CATEGORY} = kde-frameworks || ${CATEGORY} = kde-plasma || ${CATEGORY} = kde-apps ]] ; then
484 + cmake_comment_add_subdirectory autotests test tests
485 + fi
486 + fi
487 +
488 + # in frameworks, tests = manual tests so never build them
489 + if [[ ${CATEGORY} = kde-frameworks ]] && [[ ${PN} != extra-cmake-modules ]]; then
490 + cmake_comment_add_subdirectory tests
491 + fi
492 +}
493 +
494 +# @FUNCTION: ecm_src_configure
495 +# @DESCRIPTION:
496 +# Wrapper for cmake-utils_src_configure with extra logic for magic handling of
497 +# handbook, tests etc.
498 +ecm_src_configure() {
499 + debug-print-function ${FUNCNAME} "$@"
500 +
501 + # we rely on cmake-utils.eclass to append -DNDEBUG too
502 + if in_iuse debug && ! use debug; then
503 + append-cppflags -DQT_NO_DEBUG
504 + fi
505 +
506 + local cmakeargs
507 +
508 + if in_iuse test && ! use test ; then
509 + cmakeargs+=( -DBUILD_TESTING=OFF )
510 +
511 + if [[ ${ECM_TEST} = optional ]] ; then
512 + cmakeargs+=( -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Test=ON )
513 + fi
514 + fi
515 +
516 + if [[ ${ECM_HANDBOOK} = optional ]] ; then
517 + cmakeargs+=( -DCMAKE_DISABLE_FIND_PACKAGE_KF5DocTools=$(usex handbook) )
518 + fi
519 +
520 + if in_iuse designer && [[ ${ECM_DESIGNERPLUGIN} = true ]]; then
521 + cmakeargs+=( -DBUILD_DESIGNERPLUGIN=$(usex designer) )
522 + fi
523 +
524 + # TODO: drop after KDE Applications 19.08.3 removal
525 + if in_iuse designer && [[ ${KDE_DESIGNERPLUGIN} != false ]] ; then
526 + cmakeargs+=( $(cmake-utils_use_find_package designer KF5DesignerPlugin) )
527 + fi
528 +
529 + if [[ ${ECM_QTHELP} = true ]]; then
530 + cmakeargs+=( -DBUILD_QCH=$(usex doc) )
531 + fi
532 +
533 + if [[ ${ECM_KDEINSTALLDIRS} = true ]] ; then
534 + cmakeargs+=(
535 + # install mkspecs in the same directory as Qt stuff
536 + -DKDE_INSTALL_USE_QT_SYS_PATHS=ON
537 + # move handbook outside of doc dir, bug 667138
538 + -DKDE_INSTALL_DOCBUNDLEDIR="${EPREFIX}/usr/share/help"
539 + )
540 + fi
541 +
542 + # allow the ebuild to override what we set here
543 + mycmakeargs=("${cmakeargs[@]}" "${mycmakeargs[@]}")
544 +
545 + cmake-utils_src_configure
546 +}
547 +
548 +# @FUNCTION: ecm_src_compile
549 +# @DESCRIPTION:
550 +# Wrapper for cmake-utils_src_compile. Currently doesn't do anything extra, but
551 +# is included as part of the API just in case it's needed in the future.
552 +ecm_src_compile() {
553 + debug-print-function ${FUNCNAME} "$@"
554 +
555 + cmake-utils_src_compile "$@"
556 +}
557 +
558 +# @FUNCTION: ecm_src_test
559 +# @DESCRIPTION:
560 +# Wrapper for cmake-utils_src_test with extra logic for magic handling of dbus
561 +# and virtualx.
562 +ecm_src_test() {
563 + debug-print-function ${FUNCNAME} "$@"
564 +
565 + _test_runner() {
566 + if [[ -n "${VIRTUALDBUS_TEST}" ]]; then
567 + export $(dbus-launch)
568 + fi
569 +
570 + cmake-utils_src_test
571 + }
572 +
573 + # When run as normal user during ebuild development with the ebuild command,
574 + # tests tend to access the session DBUS. This however is not possible in a
575 + # real emerge or on the tinderbox.
576 + # make sure it does not happen, so bad tests can be recognized and disabled
577 + unset DBUS_SESSION_BUS_ADDRESS DBUS_SESSION_BUS_PID
578 +
579 + if [[ ${VIRTUALX_REQUIRED} = always || ${VIRTUALX_REQUIRED} = test ]]; then
580 + virtx _test_runner
581 + else
582 + _test_runner
583 + fi
584 +
585 + if [[ -n "${DBUS_SESSION_BUS_PID}" ]] ; then
586 + kill ${DBUS_SESSION_BUS_PID}
587 + fi
588 +}
589 +
590 +# @FUNCTION: ecm_src_install
591 +# @DESCRIPTION:
592 +# Wrapper for cmake-utils_src_install. Currently doesn't do anything extra, but
593 +# is included as part of the API just in case it's needed in the future.
594 +ecm_src_install() {
595 + debug-print-function ${FUNCNAME} "$@"
596 +
597 + cmake-utils_src_install
598 +}
599 +
600 +# @FUNCTION: ecm_pkg_preinst
601 +# @DESCRIPTION:
602 +# Sets up environment variables required in ecm_pkg_postinst.
603 +ecm_pkg_preinst() {
604 + debug-print-function ${FUNCNAME} "$@"
605 +
606 + case ${ECM_NONGUI} in
607 + false) xdg_pkg_preinst ;;
608 + *) ;;
609 + esac
610 +}
611 +
612 +# @FUNCTION: ecm_pkg_postinst
613 +# @DESCRIPTION:
614 +# Updates the various XDG caches (icon, desktop, mime) if necessary.
615 +ecm_pkg_postinst() {
616 + debug-print-function ${FUNCNAME} "$@"
617 +
618 + case ${ECM_NONGUI} in
619 + false) xdg_pkg_postinst ;;
620 + *) ;;
621 + esac
622 +
623 + if [[ -n ${_KDE_ORG_ECLASS} ]] && [[ -z ${I_KNOW_WHAT_I_AM_DOING} ]] && [[ ${KDE_BUILD_TYPE} = live ]]; then
624 + einfo "WARNING! This is an experimental live ebuild of ${CATEGORY}/${PN}"
625 + einfo "Use it at your own risk."
626 + einfo "Do _NOT_ file bugs at bugs.gentoo.org because of this ebuild!"
627 + fi
628 +}
629 +
630 +# @FUNCTION: ecm_pkg_postrm
631 +# @DESCRIPTION:
632 +# Updates the various XDG caches (icon, desktop, mime) if necessary.
633 +ecm_pkg_postrm() {
634 + debug-print-function ${FUNCNAME} "$@"
635 +
636 + case ${ECM_NONGUI} in
637 + false) xdg_pkg_postrm ;;
638 + *) ;;
639 + esac
640 +}
641 +
642 +fi

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies

Subject Author
Re: [gentoo-dev] [PATCH v2 1/3] ecm.eclass: New eclass Gokturk Yuksek <gokturk@g.o>