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