Re: [gentoo-dev] [PATCH 1/3] ecm-utils.eclass: New eclass

2019-11-05 Thread Michał Górny
On Wed, 2019-11-06 at 02:19 +0100, Andreas Sturmlechner wrote:
> > > +# @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} = kde-frameworks ]]; then
> > > + : ${ECM_NONGUI:=true}
> > > +fi
> > > +: ${ECM_NONGUI:=false}
> > 
> > I don't think eclassdoc is going to parse this correctly.
> 
> Can we do something about that? I need to be able to set (overrideable) 
> defaults for a category without being limited by eclassdoc. @DEFAULT_UNSET 
> would not be precise. Same as ECM_QTHELP, this is what we do in kde5.eclass 
> already.
> 

If I knew, I would've told you.  I've personally settled for
@DEFAULT_UNSET, and explained what happens when it's unset. 
Alternatively, you could set default earlier in a separate var, then do
something like:

: ${ECM_NONGUI:=${ECM_NONGUI_DEFAULT}}

but I don't think that will be very helpful.  Maybe sth like:

: ${ECM_NONGUI:=${IS_KDE_FRAMEWORKS}}

but then, it's just a hack.

-- 
Best regards,
Michał Górny



signature.asc
Description: This is a digitally signed message part


Re: [gentoo-dev] [PATCH 1/3] ecm-utils.eclass: New eclass

2019-11-05 Thread Andreas Sturmlechner
On Tuesday, 5 November 2019 22:20:46 CET Michał Górny wrote:
> On Tue, 2019-11-05 at 00:30 +0100, Andreas Sturmlechner wrote:
> > --- /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.

Fine, I would then choose ecm.eclass instead.

> > +# @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} = kde-frameworks ]]; then
> > +   : ${ECM_NONGUI:=true}
> > +fi
> > +: ${ECM_NONGUI:=false}
> 
> I don't think eclassdoc is going to parse this correctly.

Can we do something about that? I need to be able to set (overrideable) 
defaults for a category without being limited by eclassdoc. @DEFAULT_UNSET 
would not be precise. Same as ECM_QTHELP, this is what we do in kde5.eclass 
already.

> > +# @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:=true}
> 
> 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.

Making all options explicit then and erroring out on unknown input.

> > +# @FUNCTION: ecm_punt_bogus_dep
> > +# @USAGE:  
> > +# @DESCRIPTION:
> > +# Removes a specified dependency from a find_package call with multiple
> > components.
> > +ecm_punt_bogus_dep() {
> > +   local prefix=${1}
> > +   local dep=${2}
> > +
> > +   if [[ ! -e "CMakeLists.txt" ]]; then
> 
> Can this really ever happen in a valid use case?  Maybe it should be
> an error instead.

Even cmake-utils.eclass makes that check in cmake_comment_add_subdirectory and 
leaves the erroring out if the file's missing central to src_prepare(), I 
guess is why it was done that way.


Thanks for looking over it!

Regards,
Andreas





Re: [gentoo-dev] [PATCH 1/3] ecm-utils.eclass: New eclass

2019-11-05 Thread Michał Górny
On Tue, 2019-11-05 at 00:30 +0100, Andreas Sturmlechner wrote:
> Support eclass for packages that use KDE extra-cmake-modules.
> 
> This eclass is intended to streamline the creation of ebuilds for packages
> that follow KDE upstream packaging conventions. It's primarily intended for
> the three upstream release groups (Frameworks, Plasma, Applications) but
> is also for any package that follows similar conventions.
> 
> This eclass unconditionally inherits cmake-utils.eclass and all its public
> variables and helper functions (not phase functions) may be considered as part
> of this eclass's API.
> 
> When used together with kde.org.eclass this will replace kde5.eclass and
> kde5-functions.eclass, most of the latter is becoming obsolete.
> 
> --- /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:
> +# k...@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 packages
> +# that follow KDE upstream packaging conventions. It's primarily intended for
> +# the three upstream release groups (Frameworks, Plasma, Applications) but
> +# is also for any package that follows similar conventions.
> +#
> +# This eclass unconditionally inherits cmake-utils.eclass and all its public
> +# variables and helper functions (not phase functions) may be considered as 
> part
> +# of this eclass's API.
> +#
> +# This eclass's phase functions are not intended to be mixed and matched, so 
> if
> +# any phase functions are overridden the version here should also be called.
> +
> +if [[ -z ${_ECM_UTILS_ECLASS} ]]; then
> +_ECM_UTILS_ECLASS=1
> +
> +# @ECLASS-VARIABLE: VIRTUALX_REQUIRED
> +# @DESCRIPTION:
> +# For proper description see virtualx.eclass manpage.
> +# Here we redefine default value to be manual, if your package needs virtualx
> +# for tests you should proceed with setting VIRTUALX_REQUIRED=test.
> +: ${VIRTUALX_REQUIRED:=manual}
> +
> +inherit cmake-utils flag-o-matic toolchain-funcs virtualx xdg
> +
> +case ${EAPI} in
> + 7) ;;
> + *) die "EAPI=${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_preinst 
> 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 
> switch
> +# KDE_INSTALL_USE_QT_SYS_PATHS to ON.
> +: ${ECM_KDEINSTALLDIRS:=true}
> +
> +# @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} = kde-frameworks ]]; then
> + : ${ECM_NONGUI:=true}
> +fi
> +: ${ECM_NONGUI:=false}

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:=true}

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:=false}
> +
> +# @ECLASS-VARIABLE: ECM_EXAMPLES
> +# @DESCRIPTION:
> +# If set to "false", unconditionally ignore a top-level examples 
> subdirectory.
> +# Otherwise, add "examples" to IUSE to toggle adding that subdirectory.
> +: ${ECM_EXAMPLES:=false}
> +
> +# @ECLASS-VARIABLE: ECM_HANDBOOK
> +# @DESCRIPTION:
> +# If set to "false", do nothing.
> +# Otherwise, add "+handbook" to IUSE, add the appropriate dependency, and let
> +# KF5DocTools generate and install the handbook from docbook file(s) found in
> +# ECM_HANDBOOK_DIR. However if USE handbook is disabled, disable build of
> +# ECM_HANDBOOK_DIR in CMakeLists.txt.
> +# If set to "optional", config with -
> DCMAKE_DISABLE_FIND_PACKAGE_KF5DocTools=ON
> +# when USE=!handbook. In case package requires KF5KDELibs4Support, see next:
> +# If set to "forceoptional", remove a KF5DocTools dependency from the root
> +# CMakeLists.txt in addition to the above.
> +: ${ECM_HANDBOOK:=false}
> +
> +# @ECLASS-VARIABLE: ECM_HANDBOOK_DI

[gentoo-dev] [PATCH 1/3] ecm-utils.eclass: New eclass

2019-11-04 Thread Andreas Sturmlechner
Support eclass for packages that use KDE extra-cmake-modules.

This eclass is intended to streamline the creation of ebuilds for packages
that follow KDE upstream packaging conventions. It's primarily intended for
the three upstream release groups (Frameworks, Plasma, Applications) but
is also for any package that follows similar conventions.

This eclass unconditionally inherits cmake-utils.eclass and all its public
variables and helper functions (not phase functions) may be considered as part
of this eclass's API.

When used together with kde.org.eclass this will replace kde5.eclass and
kde5-functions.eclass, most of the latter is becoming obsolete.

--- /dev/null
+++ b/eclass/ecm-utils.eclass
@@ -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:
+# k...@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 packages
+# that follow KDE upstream packaging conventions. It's primarily intended for
+# the three upstream release groups (Frameworks, Plasma, Applications) but
+# is also for any package that follows similar conventions.
+#
+# This eclass unconditionally inherits cmake-utils.eclass and all its public
+# variables and helper functions (not phase functions) may be considered as 
part
+# of this eclass's API.
+#
+# This eclass's phase functions are not intended to be mixed and matched, so 
if
+# any phase functions are overridden the version here should also be called.
+
+if [[ -z ${_ECM_UTILS_ECLASS} ]]; then
+_ECM_UTILS_ECLASS=1
+
+# @ECLASS-VARIABLE: VIRTUALX_REQUIRED
+# @DESCRIPTION:
+# For proper description see virtualx.eclass manpage.
+# Here we redefine default value to be manual, if your package needs virtualx
+# for tests you should proceed with setting VIRTUALX_REQUIRED=test.
+: ${VIRTUALX_REQUIRED:=manual}
+
+inherit cmake-utils flag-o-matic toolchain-funcs virtualx xdg
+
+case ${EAPI} in
+   7) ;;
+   *) die "EAPI=${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_preinst 
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 
switch
+# KDE_INSTALL_USE_QT_SYS_PATHS to ON.
+: ${ECM_KDEINSTALLDIRS:=true}
+
+# @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} = kde-frameworks ]]; then
+   : ${ECM_NONGUI:=true}
+fi
+: ${ECM_NONGUI:=false}
+
+# @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:=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:=false}
+
+# @ECLASS-VARIABLE: ECM_EXAMPLES
+# @DESCRIPTION:
+# If set to "false", unconditionally ignore a top-level examples 
subdirectory.
+# Otherwise, add "examples" to IUSE to toggle adding that subdirectory.
+: ${ECM_EXAMPLES:=false}
+
+# @ECLASS-VARIABLE: ECM_HANDBOOK
+# @DESCRIPTION:
+# If set to "false", do nothing.
+# Otherwise, add "+handbook" to IUSE, add the appropriate dependency, and let
+# KF5DocTools generate and install the handbook from docbook file(s) found in
+# ECM_HANDBOOK_DIR. However if USE handbook is disabled, disable build of
+# ECM_HANDBOOK_DIR in CMakeLists.txt.
+# If set to "optional", config with -
DCMAKE_DISABLE_FIND_PACKAGE_KF5DocTools=ON
+# when USE=!handbook. In case package requires KF5KDELibs4Support, see next:
+# If set to "forceoptional", remove a KF5DocTools dependency from the root
+# CMakeLists.txt in addition to the above.
+: ${ECM_HANDBOOK:=false}
+
+# @ECLASS-VARIABLE: ECM_HANDBOOK_DIR
+# @DESCRIPTION:
+# Specifies the directory containing the docbook file(s) relative to ${S} to 
be
+# processed by KF5DocTools (kdoctools_install) if not the default.
+: ${ECM_HANDBOOK_DIR:=doc}
+
+# @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 exists
+# and is disabled then disable build of these directories in CMakeLists.txt.
+: ${ECM_PO_DIRS:="po poqm"}
+
+# @ECLASS-VARIABLE: ECM_QTHELP
+# @DESCRIPTION:
+# If set to "false", do nothing.
+# Otherwise, add "doc" to IUSE, add the appropriate dependen