[PATCH v2 1/5] qt-utils.eclass: Introduce new "qt_"-prefixed query functions

Andreas Sturmlechner <[email protected]> Sat, 11 Jul 2026 11:55:25 +0200
Newsgroups gmane.linux.gentoo.devel
Message-ID <[email protected]>
--nextPart0nPPqVtBQyivO4bbLso1rg
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="utf-8"; protected-headers="v1"
From: Andreas Sturmlechner <[email protected]>
To: [email protected], [email protected]
Date: Sat, 11 Jul 2026 11:55:25 +0200
Message-ID: <[email protected]>
MIME-Version: 1.0

See also (+ ebuild porting examples): https://github.com/gentoo/gentoo/pull/46526

Consistently *don't* prepend EPREFIX or similar to paths in these functions
New function qt_get_archdatadir, which echoes /usr/$(get_libdir)/qt<qt_maj_ver>

Signed-off-by: Andreas Sturmlechner <[email protected]>
---
 eclass/qt-utils.eclass | 86 +++++++++++++++++++++++++++++++++++++++---
 1 file changed, 81 insertions(+), 5 deletions(-)

diff --git a/eclass/qt-utils.eclass b/eclass/qt-utils.eclass
index e340d76329f0..d5dda9d1b318 100644
--- a/eclass/qt-utils.eclass
+++ b/eclass/qt-utils.eclass
@@ -22,19 +22,95 @@ case ${EAPI} in
 	*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
 esac
 
+# @FUNCTION: _qt_get_check_func_call
+# @INTERNAL
+# @DESCRIPTION:
+# Checks parameters of public, parent qt_get_* functions for validity.
+_qt_get_check_func_call() {
+	[[ $# -ne 1 ]] && die "${FUNCNAME[1]}: must be passed exactly one argument"
+	case ${1} in
+		6) ;;
+		*) die "${FUNCNAME[1]}: Qt ${1} is not supported" ;;
+	esac
+}
+
+# @FUNCTION: _qt_get_archdatadir
+# @INTERNAL
+# @USAGE: <qt_maj_ver>
+# @DESCRIPTION:
+# Internal base function to retrieve archdatadir part of path.
+_qt_get_archdatadir() {
+	echo "/usr/$(get_libdir)/qt${1}"
+}
+
+# @FUNCTION: qt_get_archdatadir
+# @USAGE: <qt_maj_ver>
+# @DESCRIPTION:
+# Echoes the base directory beneath which Qt binaries, modules, plugins, ...
+# are installed.
+qt_get_archdatadir() {
+	_qt_get_check_func_call "$@"
+	_qt_get_archdatadir "$@"
+}
+
+# @FUNCTION: qt_get_bindir
+# @USAGE: <qt_maj_ver>
+# @DESCRIPTION:
+# Echoes the directory where Qt binaries are installed.
+qt_get_bindir() {
+	_qt_get_check_func_call "$@"
+	echo "$(_qt_get_archdatadir "$@")/bin"
+}
+
+# @FUNCTION: qt_get_headerdir
+# @USAGE: <qt_maj_ver>
+# @DESCRIPTION:
+# Echoes the directory where Qt headers are installed.
+qt_get_headerdir() {
+	_qt_get_check_func_call "$@"
+	echo "/usr/include/qt${1}"
+}
+
+# @FUNCTION: qt_get_libexecdir
+# @USAGE: <qt_maj_ver>
+# @DESCRIPTION:
+# Echoes the directory where Qt libexec bins are installed.
+qt_get_libexecdir() {
+	_qt_get_check_func_call "$@"
+	echo "$(_qt_get_archdatadir "$@")/libexec"
+}
+
+# @FUNCTION: qt_get_mkspecsdir
+# @USAGE: <qt_maj_ver>
+# @DESCRIPTION:
+# Echoes the directory where Qt mkspecs are installed.
+qt_get_mkspecsdir() {
+	_qt_get_check_func_call "$@"
+	echo "$(_qt_get_archdatadir "$@")/mkspecs"
+}
+
+# @FUNCTION: qt_get_plugindir
+# @USAGE: <qt_maj_ver>
+# @DESCRIPTION:
+# Echoes the directory where Qt plugins are installed.
+qt_get_plugindir() {
+	_qt_get_check_func_call "$@"
+	echo "$(_qt_get_archdatadir "$@")/plugins"
+}
+
 # @FUNCTION: qt6_get_bindir
 # @DESCRIPTION:
 # Echoes the directory where Qt6 binaries are installed.
 # EPREFIX is already prepended to the returned path.
 qt6_get_bindir() {
-	echo "${EPREFIX}$(qt6_get_libdir)/qt6/bin"
+	echo "${EPREFIX}$(qt_get_bindir 6)"
 }
 
 # @FUNCTION: qt6_get_headerdir
 # @DESCRIPTION:
 # Echoes the directory where Qt6 headers are installed.
 qt6_get_headerdir() {
-	echo "/usr/include/qt6"
+	qt_get_headerdir 6
 }
 
 # @FUNCTION: qt6_get_libdir
@@ -48,21 +124,21 @@ qt6_get_libdir() {
 # @DESCRIPTION:
 # Echoes the directory where Qt6 libexec bins are installed.
 qt6_get_libexecdir() {
-	echo "$(qt6_get_libdir)/qt6/libexec"
+	qt_get_libexecdir 6
 }
 
 # @FUNCTION: qt6_get_mkspecsdir
 # @DESCRIPTION:
 # Echoes the directory where Qt6 mkspecs are installed.
 qt6_get_mkspecsdir() {
-	echo "$(qt6_get_libdir)/qt6/mkspecs"
+	qt_get_mkspecsdir 6
 }
 
 # @FUNCTION: qt6_get_plugindir
 # @DESCRIPTION:
 # Echoes the directory where Qt6 plugins are installed.
 qt6_get_plugindir() {
-	echo "$(qt6_get_libdir)/qt6/plugins"
+	qt_get_plugindir 6
 }
 
 fi
-- 
2.55.0

--nextPart0nPPqVtBQyivO4bbLso1rg
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part.
Content-Transfer-Encoding: 7Bit

-----BEGIN PGP SIGNATURE-----

iQIvBAABCgCZFiEE34gXUSooizdYNDu3S5FW4z0PgBkFAmpSEw0bFIAAAAAABAAO
bWFudTIsMi41KzEuMTIsMiwyXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25z
Lm9wZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXRERjg4MTc1MTJBMjg4QjM3NTgzNDNC
Qjc0QjkxNTZFMzNEMEY4MDE5AAoJEEuRVuM9D4AZk5ML/3wDZeAh4Hu5Vnm1Tas0
UL0OgKgJwzmeIQ3FOCTD/8Ucwx5zrjMJyTjhohoRN90UhXFmt9rQl7MQth+nItDC
HK1ufLttEjcmqZ4w53QoC8l93pSgfZxJSrjkYZFFdwI4jPOc6oNRnDmSmBz1/mR6
isd+pVIvlZ25p5ghxJj5azzpPLpS5tDwd71Rnm3eYzcLXfAV5ZskNMvYWmAxWlsQ
tdXWRr8014H2CpN3CcvVUOeNC7+yzV7cDk4JwPS6CxN+MetYlpmC/d6ZLqu1sDXv
9uZAhsgnDTMCC+xS83rUhXxfBeD6Ii03lsEMyb1mcuUJt2bX/i7Bd9lySFsKwqae
KerCHYwSJ1dQHwgIDdOP3RqXPD0SuBKtSY4WhsyT8eNl0GPLOVle3VJbqZnf52f4
0OdJnt/HS3JNNBKfdYETSa3aDfFAffuLhSlNKrmdBOz0Vwzlp3NKzZ71lyLTeLDJ
eLqP0b1XpVGIZnebKB0A06F9uoJhR3LUtlbjSTYIBbX0dg==
=2Sz8
-----END PGP SIGNATURE-----

--nextPart0nPPqVtBQyivO4bbLso1rg--