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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id B0FA4159C9B for ; Mon, 12 Aug 2024 20:09:33 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id CA3C9E2B90; Mon, 12 Aug 2024 20:09:28 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 77138E2B8C for ; Mon, 12 Aug 2024 20:09:28 +0000 (UTC) From: Andreas Sturmlechner To: gentoo-dev@lists.gentoo.org Subject: [gentoo-dev] RFC: ecm-common.eclass: New eclass for easy outsourcing of common files for KDE packages Date: Mon, 12 Aug 2024 22:09:23 +0200 Message-ID: <3580024.iIbC2pHGDl@tuxbrain.fritz.box> 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 Content-Type: multipart/signed; boundary="nextPart9320492.CDJkKcVGEf"; micalg="pgp-sha512"; protocol="application/pgp-signature" X-Archives-Salt: ddeecad3-e558-45a7-a6d1-b697e4c7ea7a X-Archives-Hash: 202152147f202c4fbcef851334ba58ab --nextPart9320492.CDJkKcVGEf Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8"; protected-headers="v1" From: Andreas Sturmlechner To: gentoo-dev@lists.gentoo.org Date: Mon, 12 Aug 2024 22:09:23 +0200 Message-ID: <3580024.iIbC2pHGDl@tuxbrain.fritz.box> MIME-Version: 1.0 ECM = extra-cmake-modules, used basically everywhere in kde.org What does it do? - Work with KF5 or KF6 in the background, so BDEPENDs are defined as :* - Create a very simple root CMakeLists.txt in place of upstream's - KDE projects are *very* standardised, so a few lines of CMake will already provide us with translations, docs, translated docs for 95% of packages. - On top of that, ebuild consumers can define icons and files to install - ... or inject their own Heredoc when ecm-common.eclass is not enough What's the goal? - Easily create ${PN}-common packages for other split ${PN} to depend upon - Be able to depend on ${PN}-common:0 packages from e.g. both SLOT 5 and 6 - ... cause less friction with not having to set compatibility USE flags and dropping many blockers When thought through to the end, it would enable us move *all* docs (currently USE=handbook in KDE packages) and translations into separate packages. Ongoing development and model revdep usage in: https://github.com/gentoo/kde/pull/999 --- /dev/null +++ b/eclass/ecm-common.eclass @@ -0,0 +1,188 @@ +# Copyright 2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# @ECLASS: ecm-common.eclass +# @MAINTAINER: +# kde@gentoo.org +# @SUPPORTED_EAPIS: 8 +# @PROVIDES: cmake +# @BLURB: Standalone CMake calling std. ECM macros to install common files only. +# @DESCRIPTION: +# This eclass is used for installing common files of packages using ECM macros, +# most of the time translations, but optionally also icons and kcfg files. This +# is mainly useful for packages split from a single upstream tarball, or for +# collision handling of slotted package versions, which need to share a common +# files package. +# Conventionally we will use ${PN}-common for these split packages. + +case ${EAPI} in + 8) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; +esac + +if [[ -z ${_ECM_COMMON_ECLASS} ]]; then +_ECM_COMMON_ECLASS=1 + +inherit cmake + +# @ECLASS_VARIABLE: ECM_I18N +# @PRE_INHERIT +# @DESCRIPTION: +# Will accept "true" (default) or "false". If set to "false", do nothing. +# Otherwise, add kde-frameworks/ki18n:* to BDEPEND, find KF[56]I18n and let +# ki18n_install(po) generate and install translations. +: "${ECM_I18N:=true}" + +# @ECLASS_VARIABLE: ECM_HANDBOOK +# @PRE_INHERIT +# @DESCRIPTION: +# Will accept "true" or "false" (default). If set to "false", do nothing. +# Otherwise, add "+handbook" to IUSE, add kde-frameworks/kdoctools:* to BDEPEND +# find KF[56]DocTools in CMake, call add_subdirectory(ECM_HANDBOOK_DIR) +# and let let kdoctools_install(po) generate and install translated docbook +# files. +: "${ECM_HANDBOOK:=false}" + +# @ECLASS_VARIABLE: ECM_HANDBOOK_DIR +# @PRE_INHERIT +# @DESCRIPTION: +# Default is "doc" which is correct for the vast majority of packages. Specifies +# the directory containing untranslated docbook file(s) relative to ${S} to +# be added via add_subdirectory. +: "${ECM_HANDBOOK_DIR:=doc}" + +DESCRIPTION="Common files for ${PN/-common/}" + +case ${ECM_I18N} in + true) + BDEPEND+=" kde-frameworks/ki18n:*" + ;; + false) ;; + *) + eerror "Unknown value for \${ECM_I18N}" + die "Value ${ECM_I18N} is not supported" + ;; +esac + +case ${ECM_HANDBOOK} in + true) + IUSE+=" +handbook" + BDEPEND+=" handbook? ( kde-frameworks/kdoctools:* )" + ;; + false) ;; + *) + eerror "Unknown value for \${ECM_HANDBOOK}" + die "Value ${ECM_HANDBOOK} is not supported" + ;; +esac + +# @ECLASS_VARIABLE: ECM_INSTALL_ICONS +# @DEFAULT_UNSET +# @DESCRIPTION: +# Array of : tuples feed to ECMInstallIcons via +# ecm_install_icons(ICONS DESTINATION : tuples to install by CMake via +# install(FILES DESTINATION ) +if [[ ${ECM_INSTALL_FILES} ]]; then + [[ ${ECM_INSTALL_FILES@a} == *a* ]] || + die "ECM_INSTALL_FILES must be an array" +fi + +# @FUNCTION: ecm-common_inject_heredoc +# @DESCRIPTION: +# Override this to inject custom Heredoc into the root CMakeLists.txt +ecm-common_inject_heredoc() { + debug-print-function ${FUNCNAME} "$@" + # put your stuff here +} + +# @FUNCTION: ecm-common_src_prepare +# @DESCRIPTION: +# Wrapper for cmake_src_prepare with a Heredoc replacing the standard +# root CMakeLists.txt file to only generate and install translations. +ecm-common_src_prepare() { + debug-print-function ${FUNCNAME} "$@" + + local i + +cat <<-EOF > CMakeLists.txt +cmake_minimum_required(VERSION 3.16) +project(${PN} VERSION ${PV}) + +find_package(ECM "5.115.0" REQUIRED NO_MODULE) +set(CMAKE_MODULE_PATH \${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules \$ {ECM_MODULE_PATH}) + +set(KDE_INSTALL_DOCBUNDLEDIR "${EPREFIX}/usr/share/help" CACHE PATH "") + +include(KDEInstallDirs) +include(ECMOptionalAddSubdirectory) # commonly used +include(FeatureSummary) + +EOF + + if [[ ${ECM_I18N} == true ]]; then +cat <<-EOF >> CMakeLists.txt +find_package(KF6I18n) +if(NOT KF6I18n_FOUND) + find_package(KF5I18n REQUIRED) +endif() +ki18n_install(po) + +EOF + fi + + if in_iuse handbook && use handbook; then +cat <<-EOF >> CMakeLists.txt +find_package(KF6DocTools) +if(NOT KF6DocTools_FOUND) + find_package(KF5DocTools REQUIRED) +endif() +kdoctools_install(po) +EOF + if [[ -d ${ECM_HANDBOOK_DIR} ]]; then +cat <<-EOF >> CMakeLists.txt +add_subdirectory(${ECM_HANDBOOK_DIR}) + +EOF + fi + fi + + if [[ ${ECM_INSTALL_ICONS} ]]; then +cat <<-EOF >> CMakeLists.txt +include(ECMInstallIcons) +EOF + for i in "${ECM_INSTALL_ICONS[@]}"; do +cat <<-EOF >> CMakeLists.txt +ecm_install_icons(ICONS ${i%:*} DESTINATION ${i#*:}) +EOF + done + fi + + for i in "${ECM_INSTALL_FILES[@]}"; do +cat <<-EOF >> CMakeLists.txt +install(FILES ${i%:*} DESTINATION ${i#*:}) + +EOF + done + + ecm-common_inject_heredoc + +cat <<-EOF >> CMakeLists.txt + +feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) +EOF + + cmake_src_prepare +} + +fi + +EXPORT_FUNCTIONS src_prepare --nextPart9320492.CDJkKcVGEf Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part. Content-Transfer-Encoding: 7Bit -----BEGIN PGP SIGNATURE----- iQITBAABCgB9FiEESn1gz6RHOTQPAoX/ASQjMY0fts0FAma6a/NfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDRB N0Q2MENGQTQ0NzM5MzQwRjAyODVGRjAxMjQyMzMxOEQxRkI2Q0QACgkQASQjMY0f ts0fsAwA3PlcynNyrnb+A0hraELpgqjREeYWCigoWnu+HQ+rCmKJjfYakeqzza2e uHtGFbwAtDAm04KK46m5wug3iTde7zh/bThYxUp2jHi0Zs0T39p0SDIDbawxmXJY DpFhU7gbGDte1WCRRtCsdrN0dzhvgx18FVp5H84qVjCqkvWfg4cMB4lUw2sJqkR3 n3J1J4V+uZ7mOwTM1t3K4ADUkZ6xjLvWjLKua68P5YCy2RURp63n8DidTenwS71Q lsGauyD0ZEtrxLFxMpnkpVUjF/rP03tE6iZcWNf1Re64wMiHL+/nsaqvFabf8Qva L5DqUjpiQ9Fthy2zkRr7EMbt/8S/0VvQhAAMtgej2raSXYqTKR42vUOEzU3f+mDm 6LkOH4bBp9ny9tn6E6WFPMGYU6jbAb1gUmyRxFwIJzHQr10yuHrrue61snxfYM6e lTfKfueEiZHKj+zdrxPk9uM0coFhk9omRmZl5gs2HFOO5mg8uwr2Dlpj60ldFlR+ TJOEAHOx =NXcR -----END PGP SIGNATURE----- --nextPart9320492.CDJkKcVGEf--