From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 7A461138334 for ; Tue, 5 Nov 2019 21:20:56 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id BA652E09D7; Tue, 5 Nov 2019 21:20:52 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 39093E09B6 for ; Tue, 5 Nov 2019 21:20:52 +0000 (UTC) Received: from pomiot (c134-66.icpnet.pl [85.221.134.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mgorny) by smtp.gentoo.org (Postfix) with ESMTPSA id 83A9634C62D; Tue, 5 Nov 2019 21:20:50 +0000 (UTC) Message-ID: <759405ee4e4ae48d65cbac336e23f91ceec53ea1.camel@gentoo.org> Subject: Re: [gentoo-dev] [PATCH 1/3] ecm-utils.eclass: New eclass From: =?UTF-8?Q?Micha=C5=82_G=C3=B3rny?= To: gentoo-dev@lists.gentoo.org Date: Tue, 05 Nov 2019 22:20:46 +0100 In-Reply-To: <2344877.D1iEJ5bPx9@tuxbrain> References: <9898161.uzqcMZjEFU@tuxk10> <4600891.LxcutymfD9@tuxbrain> <2344877.D1iEJ5bPx9@tuxbrain> Organization: Gentoo Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-XXWV/2cleTub2yV9Bu0B" User-Agent: Evolution 3.32.4 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 X-Archives-Salt: 6cf4f411-e51b-4de7-9d4e-6446d930abb1 X-Archives-Hash: b25fb81912cd96b53bdc3270276e4fcc --=-XXWV/2cleTub2yV9Bu0B Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, 2019-11-05 at 00:30 +0100, Andreas Sturmlechner wrote: > Support eclass for packages that use KDE extra-cmake-modules. >=20 > This eclass is intended to streamline the creation of ebuilds for package= s > that follow KDE upstream packaging conventions. It's primarily intended f= or > the three upstream release groups (Frameworks, Plasma, Applications) but > is also for any package that follows similar conventions. >=20 > This eclass unconditionally inherits cmake-utils.eclass and all its publi= c > variables and helper functions (not phase functions) may be considered as= part > of this eclass's API. >=20 > When used together with kde.org.eclass this will replace kde5.eclass and > kde5-functions.eclass, most of the latter is becoming obsolete. >=20 > --- /dev/null > +++ b/eclass/ecm-utils.eclass I know we historically screwed this up repeatedly but please don't use '-utils' for eclasses that export phases. > @@ -0,0 +1,549 @@ > +# Copyright 1999-2019 Gentoo Authors > +# Distributed under the terms of the GNU General Public License v2 > + > +# @ECLASS: ecm-utils.eclass > +# @MAINTAINER: > +# kde@gentoo.org > +# @SUPPORTED_EAPIS: 7 > +# @BLURB: Support eclass for packages that use KDE extra-cmake-modules. > +# @DESCRIPTION: > +# This eclass is intended to streamline the creation of ebuilds for pack= ages > +# that follow KDE upstream packaging conventions. It's primarily intende= d for > +# the three upstream release groups (Frameworks, Plasma, Applications) b= ut > +# is also for any package that follows similar conventions. > +# > +# This eclass unconditionally inherits cmake-utils.eclass and all its pu= blic > +# variables and helper functions (not phase functions) may be considered= as=20 > part > +# of this eclass's API. > +# > +# This eclass's phase functions are not intended to be mixed and matched= , so=20 > if > +# any phase functions are overridden the version here should also be cal= led. > + > +if [[ -z ${_ECM_UTILS_ECLASS} ]]; then > +_ECM_UTILS_ECLASS=3D1 > + > +# @ECLASS-VARIABLE: VIRTUALX_REQUIRED > +# @DESCRIPTION: > +# For proper description see virtualx.eclass manpage. > +# Here we redefine default value to be manual, if your package needs vir= tualx > +# for tests you should proceed with setting VIRTUALX_REQUIRED=3Dtest. > +: ${VIRTUALX_REQUIRED:=3Dmanual} > + > +inherit cmake-utils flag-o-matic toolchain-funcs virtualx xdg > + > +case ${EAPI} in > + 7) ;; > + *) die "EAPI=3D${EAPI:-0} is not supported" ;; > +esac > + > +if [[ -v KDE_GCC_MINIMAL ]]; then > + EXPORT_FUNCTIONS pkg_pretend > +fi > + > +EXPORT_FUNCTIONS pkg_setup src_prepare src_configure src_test pkg_preins= t=20 > pkg_postinst pkg_postrm > + > +# @ECLASS-VARIABLE: ECM_KDEINSTALLDIRS > +# @DESCRIPTION: > +# If set to "false", do nothing. > +# For any other value, assume the package is using KDEInstallDirs macro = and=20 > switch > +# KDE_INSTALL_USE_QT_SYS_PATHS to ON. > +: ${ECM_KDEINSTALLDIRS:=3Dtrue} > + > +# @ECLASS-VARIABLE: ECM_NONGUI > +# @DESCRIPTION: > +# If set to "false", add dependency on kde-frameworks/breeze-icons > +# or kde-frameworks/oxygen-icons and run the xdg.eclass routines for > +# pkg_preinst, pkg_postinst and pkg_postrm. > +# For any other value, do nothing. > +if [[ ${CATEGORY} =3D kde-frameworks ]]; then > + : ${ECM_NONGUI:=3Dtrue} > +fi > +: ${ECM_NONGUI:=3Dfalse} I don't think eclassdoc is going to parse this correctly. > + > +# @ECLASS-VARIABLE: ECM_DEBUG > +# @DESCRIPTION: > +# If set to "false", add -DNDEBUG (via cmake-utils_src_configure) and > +# -DQT_NO_DEBUG to CPPFLAGS. > +# Otherwise, add debug to IUSE. > +: ${ECM_DEBUG:=3Dtrue} To be honest, I don't really like this 'anything-or-false' logic. It's rather confusing and error-prone. For example, if I misspell 'false' the eclass is going to silently assume true. > + > +# @ECLASS-VARIABLE: ECM_DESIGNERPLUGIN > +# @DESCRIPTION: > +# If set to "false", do nothing. > +# Otherwise, add "designer" to IUSE to toggle build of designer plugins > +# and add the necessary BDEPEND. > +: ${ECM_DESIGNERPLUGIN:=3Dfalse} > + > +# @ECLASS-VARIABLE: ECM_EXAMPLES > +# @DESCRIPTION: > +# If set to "false", unconditionally ignore a top-level examples=20 > subdirectory. > +# Otherwise, add "examples" to IUSE to toggle adding that subdirectory. > +: ${ECM_EXAMPLES:=3Dfalse} > + > +# @ECLASS-VARIABLE: ECM_HANDBOOK > +# @DESCRIPTION: > +# If set to "false", do nothing. > +# Otherwise, add "+handbook" to IUSE, add the appropriate dependency, an= d let > +# KF5DocTools generate and install the handbook from docbook file(s) fou= nd in > +# ECM_HANDBOOK_DIR. However if USE handbook is disabled, disable build o= f > +# ECM_HANDBOOK_DIR in CMakeLists.txt. > +# If set to "optional", config with - > DCMAKE_DISABLE_FIND_PACKAGE_KF5DocTools=3DON > +# when USE=3D!handbook. In case package requires KF5KDELibs4Support, see= next: > +# If set to "forceoptional", remove a KF5DocTools dependency from the ro= ot > +# CMakeLists.txt in addition to the above. > +: ${ECM_HANDBOOK:=3Dfalse} > + > +# @ECLASS-VARIABLE: ECM_HANDBOOK_DIR > +# @DESCRIPTION: > +# Specifies the directory containing the docbook file(s) relative to ${S= } to=20 > be > +# processed by KF5DocTools (kdoctools_install) if not the default. > +: ${ECM_HANDBOOK_DIR:=3Ddoc} > + > +# @ECLASS-VARIABLE: ECM_PO_DIRS > +# @DESCRIPTION: > +# Specifies the top-level directories of l10n files relative to ${S} to = be > +# processed by KF5I18n (ki18n_install) if not the default. If IUSE nls e= xists > +# and is disabled then disable build of these directories in CMakeLists.= txt. > +: ${ECM_PO_DIRS:=3D"po poqm"} > + > +# @ECLASS-VARIABLE: ECM_QTHELP > +# @DESCRIPTION: > +# If set to "false", do nothing. > +# Otherwise, add "doc" to IUSE, add the appropriate dependency, generate > +# and install Qt compressed help files with -DBUILD_QCH=3DON when USE=3D= doc. > +if [[ ${CATEGORY} =3D kde-frameworks ]]; then > + : ${ECM_QTHELP:=3Dtrue} > +fi > +: ${ECM_QTHELP:=3Dfalse} Again, I believe this and below won't be processed by eclassdoc correctly. > + > +# @ECLASS-VARIABLE: ECM_TEST > +# @DESCRIPTION: > +# If set to "false", do nothing. > +# For any other value, add test to IUSE and add a dependency on dev-qt/ > qttest:5. > +# If set to "optional", configure with - > DCMAKE_DISABLE_FIND_PACKAGE_Qt5Test=3DON > +# when USE=3D!test. > +# If set to "forceoptional", remove a Qt5Test dependency and comment tes= t > +# subdirs from the root CMakeLists.txt in addition to the above. > +# If set to "forceoptional-recursive", remove Qt5Test dependencies and m= ake > +# autotest(s), unittest(s) and test(s) subdirs from *any* CMakeLists.txt= in $ > {S} > +# and below conditional on BUILD_TESTING. This is always meant as a shor= t- > term > +# fix and creates ${T}/${P}-tests-optional.patch to refine and submit= =20 > upstream. > +if [[ ${CATEGORY} =3D kde-frameworks ]]; then > + : ${ECM_TEST:=3Dtrue} > +fi > +: ${ECM_TEST:=3Dfalse} > + > +case ${ECM_NONGUI} in There's a @PRE_INHERIT thingie to indicate variables that need to be set before 'inherit' to work correctly. > + false) > + # gui applications need breeze or oxygen icons for basic iconset,=20 > bug #564838 > + RDEPEND+=3D" || ( kde-frameworks/breeze-icons:5 kde-frameworks/ > oxygen-icons:* )" > + ;; > + *) ;; > +esac > + > +case ${ECM_DEBUG} in > + false) ;; > + *) > + IUSE+=3D" debug" > + ;; > +esac > + > +case ${ECM_DESIGNERPLUGIN} in > + false) ;; > + *) > + IUSE+=3D" designer" > + BDEPEND+=3D" designer? ( dev-qt/designer:5 )" > + ;; > +esac > + > +# @ECLASS-VARIABLE: KDE_DESIGNERPLUGIN > +# @DESCRIPTION: > +# If set to "false", do nothing. > +# Otherwise, add "designer" to IUSE to toggle build of designer plugins > +# and add the necessary BDEPEND. > +# TODO: drop after KDE Applications 19.08.3 removal > +: ${KDE_DESIGNERPLUGIN:=3Dfalse} > +case ${KDE_DESIGNERPLUGIN} in > + false) ;; > + *) > + IUSE+=3D" designer" > + BDEPEND+=3D" designer? ( kde-frameworks/kdesignerplugin:5 )" > + ;; > +esac > + > +case ${ECM_EXAMPLES} in > + false) ;; > + *) > + IUSE+=3D" examples" > + ;; > +esac > + > +case ${ECM_HANDBOOK} in > + false) ;; > + *) > + IUSE+=3D" +handbook" > + BDEPEND+=3D" handbook? ( kde-frameworks/kdoctools:5 )" > + ;; > +esac > + > +case ${ECM_QTHELP} in > + false) ;; > + *) > + IUSE+=3D" doc" > + COMMONDEPEND+=3D" doc? ( dev-qt/qt-docs:5 )" > + BDEPEND+=3D" doc? ( > + >=3Dapp-doc/doxygen-1.8.13-r1 > + dev-qt/qthelp:5 > + )" > + ;; > +esac > + > +case ${ECM_TEST} in > + false) ;; > + *) > + IUSE+=3D" test" > + DEPEND+=3D" test? ( dev-qt/qttest:5 )" > + RESTRICT+=3D" !test? ( test )" > + ;; > +esac > + > +BDEPEND+=3D" >=3Dkde-frameworks/extra-cmake-modules-5.60.0" > +RDEPEND+=3D" >=3Dkde-frameworks/kf-env-4" > +COMMONDEPEND+=3D" dev-qt/qtcore:5" > + > +DEPEND+=3D" ${COMMONDEPEND}" > +RDEPEND+=3D" ${COMMONDEPEND}" > +unset COMMONDEPEND > + > +# @ECLASS-VARIABLE: KDE_GCC_MINIMAL > +# @DEFAULT_UNSET > +# @DESCRIPTION: > +# Minimum version of active GCC to require. This is checked in > +# ecm-utils_pkg_pretend and ecm-utils_pkg_setup. > + > +# @FUNCTION: _check_gcc_version Would be nice to prefix it with _ecm*. > +# @INTERNAL > +# @DESCRIPTION: > +# Determine if the current GCC version is acceptable, otherwise die. > +_check_gcc_version() { > + if [[ ${MERGE_TYPE} !=3D binary && -v KDE_GCC_MINIMAL ]] && tc-is-gcc;= =20 > then > + > + local version=3D$(gcc-version) > + local major=3D${version%.*} > + local minor=3D${version#*.} > + local min_major=3D${KDE_GCC_MINIMAL%.*} > + local min_minor=3D${KDE_GCC_MINIMAL#*.} > + > + debug-print "GCC version check activated" > + debug-print "Version detected:" > + debug-print " - Full: ${version}" > + debug-print " - Major: ${major}" > + debug-print " - Minor: ${minor}" > + debug-print "Version required:" > + debug-print " - Major: ${min_major}" > + debug-print " - Minor: ${min_minor}" > + > + [[ ${major} -lt ${min_major} ]] || \ > + ( [[ ${major} -eq ${min_major} && ${minor} -lt $ > {min_minor} ]] ) \ > + && die "Sorry, but gcc-${KDE_GCC_MINIMAL} or later is=20 > required for this package (found ${version})." Why not use ver_cmp from EAPI 7? > + fi > +} > + > +# @FUNCTION: ecm_punt_bogus_dep > +# @USAGE: > +# @DESCRIPTION: > +# Removes a specified dependency from a find_package call with multiple= =20 > components. > +ecm_punt_bogus_dep() { > + local prefix=3D${1} > + local dep=3D${2} > + > + if [[ ! -e "CMakeLists.txt" ]]; then Can this really ever happen in a valid use case? Maybe it should be an error instead. > + return > + fi > + > + pcregrep -Mni "(?s)find_package\s*\(\s*${prefix}[^)]*?${dep}.*?\)"=20 > CMakeLists.txt > "${T}/bogus${dep}" > + > + # pcregrep returns non-zero on no matches/error > + if [[ $? !=3D 0 ]] ; then -ne > + return > + fi > + > + local length=3D$(wc -l "${T}/bogus${dep}" | cut -d " " -f 1) 'wc -l < ...' and you won't have to cut. > + local first=3D$(head -n 1 "${T}/bogus${dep}" | cut -d ":" -f 1) > + local last=3D$(( ${length} + ${first} - 1)) $(( length + first - 1 )) > + > + sed -e "${first},${last}s/${dep}//" -i CMakeLists.txt || die > + > + if [[ ${length} =3D 1 ]] ; then -eq > + sed -e "/find_package\s*(\s*${prefix}\(\s\+\(REQUIRED\|CONFIG\| > COMPONENTS\|\${[A-Z0-9_]*}\)\)\+\s*)/Is/^/# removed by kde5-functions.ecl= ass -=20 > /" -i CMakeLists.txt || die > + fi > +} > + > +# @FUNCTION: ecm-utils_pkg_pretend > +# @DESCRIPTION: > +# Checks if the active compiler meets the minimum version requirements. > +# phase function is only exported if KDE_GCC_MINIMAL is defined. > +ecm-utils_pkg_pretend() { > + debug-print-function ${FUNCNAME} "$@" > + _check_gcc_version > +} > + > +# @FUNCTION: ecm-utils_pkg_setup > +# @DESCRIPTION: > +# Checks if the active compiler meets the minimum version requirements. > +ecm-utils_pkg_setup() { > + debug-print-function ${FUNCNAME} "$@" > + _check_gcc_version > +} > + > +# @FUNCTION: ecm-utils_src_prepare > +# @DESCRIPTION: > +# Wrapper for cmake-utils_src_prepare with lots of extra logic for magic > +# handling of linguas, tests, handbook etc. > +ecm-utils_src_prepare() { > + debug-print-function ${FUNCNAME} "$@" > + > + cmake-utils_src_prepare > + > + # only build examples when required > + if ! { in_iuse examples && use examples; } ; then > + cmake_comment_add_subdirectory examples > + fi > + > + # only enable handbook when required > + if in_iuse handbook && ! use handbook ; then > + cmake_comment_add_subdirectory ${ECM_HANDBOOK_DIR} > + > + if [[ ${ECM_HANDBOOK} =3D forceoptional ]] ; then > + punt_bogus_dep KF5 DocTools > + sed -i -e "/kdoctools_install/ s/^/#DONT/" CMakeLists.txt ||=20 > die > + fi > + fi > + > + # drop translations when nls is not wanted > + if in_iuse nls && ! use nls ; then > + local po > + for po in ${ECM_PO_DIRS}; do > + if [[ -d ${po} ]] ; then Do you have a valid case for ${po} not being a directory? If not, I think the whole thing could be simplified to: rm -rf ${ECM_PO_DIRS} > + rm -r ${po} || die > + fi > + done > + fi > + > + # enable only the requested translations when required > + # always install unconditionally for kconfigwidgets - if you use=20 > language > + # X as system language, and there is a combobox with language names, th= e > + # translated language name for language Y is taken from > + # /usr/share/locale/Y/kf5_entry.desktop > + if [[ -v LINGUAS && ${PN} !=3D kconfigwidgets ]] ; then > + local po > + for po in ${ECM_PO_DIRS}; do > + if [[ -d ${po} ]] ; then Missing indent? > + pushd ${po} > /dev/null || die > + local lang > + for lang in *; do > + if [[ -e ${lang} ]] && ! has ${lang/.po/} ${LINGUAS} ;=20 > then > + case ${lang} in > + cmake_modules | \ > + CMakeLists.txt | \ > + ${PN}.pot) ;; > + *) rm -r ${lang} || die ;; > + esac > + if [[ -e CMakeLists.txt ]] ; then > + cmake_comment_add_subdirectory ${lang} > + sed -e "/add_subdirectory([[:space:]]*$ > {lang}\/.*[[:space:]]*)/d" \ > + -i CMakeLists.txt || die > + fi > + fi > + done > + popd > /dev/null || die > + fi > + done > + fi > + Overall, I find this whole thing disgusting and fragile but up to you. >=20 --=20 Best regards, Micha=C5=82 G=C3=B3rny --=-XXWV/2cleTub2yV9Bu0B Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQGTBAABCgB9FiEEx2qEUJQJjSjMiybFY5ra4jKeJA4FAl3B565fFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldEM3 NkE4NDUwOTQwOThEMjhDQzhCMjZDNTYzOUFEQUUyMzI5RTI0MEUACgkQY5ra4jKe JA5sIAgAi2FwiXM4uFoeWy0Xun85YFaYzCifqrBo0lOG2tD+Dk+xGoRFiiY+qxB7 TzUcn7/325kItipNhkAzJxqWeJTFXCPcCeZoOE3Nd3aJn5ipwAubxtEN/qwNrqpz /xnucIy3I+Hsye8Y5VBKoHM0JJGN1KzKKMiscTFiruvxv785ldQsGDcgURnkDLVc R+RDD8jzaO/AKzsmfMzSicH4DsyH/mVKjxSiESiRneixt8DIWApPwxLYS+Y8H1mn hreipIcllHa4UKzSCZpy/xudHMVlUOL2nZAtCzwnwu80m4JnT7B4iOfj9UluRiXB oQ7cge7QFTsYKkdy6Z/xWh0U14bwgQ== =Va/7 -----END PGP SIGNATURE----- --=-XXWV/2cleTub2yV9Bu0B--