public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH] gstreamer-meson.eclass: New eclass required for gstreamer-1.18.0+
@ 2021-03-17  1:49 Haelwenn (lanodan) Monnier
  2021-03-17  1:57 ` Sam James
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Haelwenn (lanodan) Monnier @ 2021-03-17  1:49 UTC (permalink / raw
  To: gentoo-dev; +Cc: Haelwenn (lanodan) Monnier

Gstreamer switched to meson in 1.16.0 and removed autotools support in 1.18.0,
this eclass is an update of gstreamer.eclass.

One significant change between autotools and meson is that in the latter we
don't have easily extractable semantics in the buildsystem to get a list
of plugins with extraneous dependencies that we currently split in other
packages.
Hence the rather ugly but currently required GST_PLUGINS_DISABLED block.

Fixes: https://bugs.gentoo.org/690468

Signed-off-by: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
---
 eclass/gstreamer-meson.eclass | 293 ++++++++++++++++++++++++++++++++++
 1 file changed, 293 insertions(+)
 create mode 100644 eclass/gstreamer-meson.eclass

diff --git a/eclass/gstreamer-meson.eclass b/eclass/gstreamer-meson.eclass
new file mode 100644
index 00000000000..263deeb08aa
--- /dev/null
+++ b/eclass/gstreamer-meson.eclass
@@ -0,0 +1,293 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: gstreamer-meson.eclass
+# @MAINTAINER:
+# gstreamer@gentoo.org
+# @AUTHOR:
+# Michał Górny <mgorny@gentoo.org>
+# Gilles Dartiguelongue <eva@gentoo.org>
+# Saleem Abdulrasool <compnerd@gentoo.org>
+# foser <foser@gentoo.org>
+# zaheerm <zaheerm@gentoo.org>
+# Steven Newbury
+# Haelwenn (lanodan) Monnier <contact@hacktivis.me>
+# @SUPPORTED_EAPIS: 5 6
+# @BLURB: Helps building core & split gstreamer plugins.
+# @DESCRIPTION:
+# Eclass to make external gst-plugins emergable on a per-plugin basis
+# and to solve the problem with gst-plugins generating far too much
+# unneeded dependencies.
+#
+# GStreamer consuming applications should depend on the specific plugins
+# they need as defined in their source code. Usually you can find that
+# out by grepping the source tree for 'factory_make'. If it uses playbin
+# plugin, consider adding media-plugins/gst-plugins-meta dependency, but
+# also list any packages that provide explicitly requested plugins.
+
+inherit eutils multilib meson multilib-minimal toolchain-funcs versionator xdg-utils
+
+case "${EAPI:-0}" in
+	5|6)
+		;;
+	0|1|2|3|4)
+		die "EAPI=\"${EAPI:-0}\" is not supported anymore"
+		;;
+	*)
+		die "EAPI=\"${EAPI}\" is not supported yet"
+		;;
+esac
+
+# @ECLASS-VARIABLE: GST_PLUGINS_ENABLED
+# @DESCRIPTION:
+# Defines the plugins to be built.
+# May be set by an ebuild and contain more than one indentifier, space
+# seperated (only src_configure can handle mutiple plugins at this time).
+: ${GST_PLUGINS_ENABLED:=${PN/gst-plugins-/}}
+
+# @ECLASS-VARIABLE: GST_PLUGINS_DISABLED
+# @DESCRIPTION:
+# Defines the plugins to not be built, GST_PLUGINS_ENABLED overrides it.
+# May be set by an ebuild and contain more than one indentifier, space
+# seperated (only src_configure can handle mutiple plugins at this time).
+case "${GST_ORG_MODULE}" in
+	# copied GST_PLUGINS_DISABLED from media-libs/${GST_ORG_MODULE} then added GST_PLUGINS_ENABLED
+	gst-plugins-bad)
+		# removed from list: shm ipcpipeline gl
+		GST_PLUGINS_DISABLED="aom avtp androidmedia applemedia assrender bluez bs2b bz2 chromaprint closedcaption colormanagement curl curl-ssh2 d3dvideosink d3d11 dash dc1394 decklink directfb directsound dtls dts dvb faac faad fbdev fdkaac flite fluidsynth gme gsm iqa kate kms ladspa libde265 libmms lv2 mediafoundation microdns modplug mpeg2enc mplex msdk musepack neon nvcodec ofa openal openexr openh264 openjpeg openmpt openni2 opensles opus resindvd rsvg rtmp sbc sctp smoothstreaming sndfile soundtouch spandsp srt srtp svthevcenc teletext tinyalsa transcode ttml uvch264 va voaacenc voamrwbenc vulkan wasapi wasapi2 webp webrtc webrtcdsp wildmidi winks winscreencap x265 zbar zxing wpe magicleap v4l2codecs hls opencv"
+		GST_PLUGINS_DISABLED="${GST_PLUGINS_DISABLED} accurip adpcmdec adpcmenc aiff asfmux audiobuffersplit audiofxbad audiolatency audiomixmatrix audiovisualizers autoconvert bayer camerabin2 coloreffects deb ugutils dvbsubenc dvbsuboverlay dvdspu faceoverlay festival fieldanalysis freeverb frei0r gaudieffects gdp geometrictransform id3tag inter interlace ivfpars e ivtc jp2kdecimator jpegformat librfb midi mpegdemux mpegpsmux mpegtsdemux mpegtsmux mxf netsim onvif pcapparse pnm proxy rawparse removesilence rist rtmp2 rtp sdp segmentclip siren smooth speed subenc switchbin timecode videofilters videoframe_audiolevel videoparsers videosignal vmnc y4m"
+		;;
+	gst-plugins-base)
+		GST_PLUGINS_DISABLED="cdparanoia libvisual opus tremor"
+		GST_PLUGINS_DISABLED="${GST_PLUGINS_DISABLED} adder app audioconvert audiomixer audiorate audioresample audiotestsrc compositor encoding gio gio-typefinder overlaycomposition pbtypes playback rawparse subparse tcp typefind videoconvert videorate videoscale videotestsrc volume"
+		;;
+	gst-plugins-good)
+		GST_PLUGINS_DISABLED="aalib cairo directsound dv dv1394 flac gdk-pixbuf gtk3 jack jpeg lame libcaca mpg123 oss oss4 osxaudio osxvideo png pulse qt5 shout2 soup speex taglib twolame vpx waveform wavpack  rpicamsrc ximagesrc v4l2"
+		GST_PLUGINS_DISABLED="${GST_PLUGINS_DISABLED} alpha apetag audiofx audioparsers auparse autodetect avi cutter debugutils deinterlace dtmf effectv equalizer flv flx goom goom2k1 icydemux id3demux imagefreeze interleave isomp4 law level matroska monoscope multifile multipart replaygain rtp rtpmanager rtsp shapewipe smpte spectrum udp videobox videocrop videofilter videomixer wavenc wavparse y4m"
+		;;
+	gst-plugins-ugly)
+		GST_PLUGINS_DISABLED="a52dec amrnb amrwbdec cdio dvdread mpeg2dec sidplay x264"
+		GST_PLUGINS_DISABLED="${GST_PLUGINS_DISABLED} asfdemux dvdlpcmdec dvdsub realmedia xingmux"
+		;;
+esac
+
+# @ECLASS-VARIABLE: GST_PLUGINS_BUILD_DIR
+# @DESCRIPTION:
+# Actual build directory of the plugin.
+# Most often the same as the configure switch name.
+: ${GST_PLUGINS_BUILD_DIR:=${PN/gst-plugins-/}}
+
+# @ECLASS-VARIABLE: GST_TARBALL_SUFFIX
+# @DESCRIPTION:
+# Most projects hosted on gstreamer.freedesktop.org mirrors provide
+# tarballs as tar.bz2 or tar.xz. This eclass defaults to xz. This is
+# because the gstreamer mirrors are moving to only have xz tarballs for
+# new releases.
+: ${GST_TARBALL_SUFFIX:="xz"}
+
+# Even though xz-utils are in @system, they must still be added to DEPEND; see
+# https://archives.gentoo.org/gentoo-dev/msg_a0d4833eb314d1be5d5802a3b710e0a4.xml
+if [[ ${GST_TARBALL_SUFFIX} == "xz" ]]; then
+	DEPEND="${DEPEND} app-arch/xz-utils"
+fi
+
+# @ECLASS-VARIABLE: GST_ORG_MODULE
+# @DESCRIPTION:
+# Name of the module as hosted on gstreamer.freedesktop.org mirrors.
+# Leave unset if package name matches module name.
+: ${GST_ORG_MODULE:=$PN}
+
+# @ECLASS-VARIABLE: GST_ORG_PVP
+# @INTERNAL
+# @DESCRIPTION:
+# Major and minor numbers of the version number.
+: ${GST_ORG_PVP:=$(get_version_component_range 1-2)}
+
+
+DESCRIPTION="${BUILD_GST_PLUGINS} plugin for gstreamer"
+HOMEPAGE="https://gstreamer.freedesktop.org/"
+SRC_URI="https://gstreamer.freedesktop.org/src/${GST_ORG_MODULE}/${GST_ORG_MODULE}-${PV}.tar.${GST_TARBALL_SUFFIX}"
+
+LICENSE="GPL-2"
+case ${GST_ORG_PVP} in
+	1.*) SLOT="1.0"; GST_MIN_PV="1.2.4-r1" ;;
+	*) die "Unkown gstreamer release."
+esac
+
+S="${WORKDIR}/${GST_ORG_MODULE}-${PV}"
+
+RDEPEND="
+	>=dev-libs/glib-2.38.2-r1:2[${MULTILIB_USEDEP}]
+	>=media-libs/gstreamer-${GST_MIN_PV}:${SLOT}[${MULTILIB_USEDEP}]
+"
+DEPEND="
+	>=sys-apps/sed-4
+	>=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}]
+"
+
+# Export common multilib phases.
+multilib_src_configure() { gstreamer_multilib_src_configure; }
+
+if [[ ${PN} != ${GST_ORG_MODULE} ]]; then
+	# Do not run test phase for invididual plugin ebuilds.
+	RESTRICT="test"
+	RDEPEND="${RDEPEND}
+		>=media-libs/${GST_ORG_MODULE}-${PV}:${SLOT}[${MULTILIB_USEDEP}]"
+
+	# Export multilib phases used for split builds.
+	multilib_src_compile() { gstreamer_multilib_src_compile; }
+	multilib_src_install() { gstreamer_multilib_src_install; }
+	multilib_src_install_all() { gstreamer_multilib_src_install_all; }
+else
+	IUSE="nls"
+	DEPEND="${DEPEND} nls? ( >=sys-devel/gettext-0.17 )"
+
+	multilib_src_compile() { eninja; }
+	multilib_src_install() { DESTDIR="${D}" eninja install; }
+fi
+
+DEPEND="${DEPEND} ${RDEPEND}"
+
+# @FUNCTION: gstreamer_environment_reset
+# @INTERNAL
+# @DESCRIPTION:
+# Clean up environment for clean builds.
+# >=dev-lang/orc-0.4.23 rely on environment variables to find a place to
+# allocate files to mmap.
+gstreamer_environment_reset() {
+	xdg_environment_reset
+}
+
+# @FUNCTION: gstreamer_get_plugin_dir
+# @USAGE: gstreamer_get_plugin_dir [<build_dir>]
+# @INTERNAL
+# @DESCRIPTION:
+# Finds plugin build directory and output it.
+# Defaults to ${GST_PLUGINS_BUILD_DIR} if argument is not provided
+gstreamer_get_plugin_dir() {
+	local build_dir=${1:-${GST_PLUGINS_BUILD_DIR}}
+
+	if [[ ! -d ${S}/ext/${build_dir} ]]; then
+		if [[ ! -d ${S}/sys/${build_dir} ]]; then
+			ewarn "No such plugin directory"
+			die
+		fi
+		einfo "Building system plugin in ${build_dir}..." >&2
+		echo sys/${build_dir}
+	else
+		einfo "Building external plugin in ${build_dir}..." >&2
+		echo ext/${build_dir}
+	fi
+}
+
+# @FUNCTION: gstreamer_multilib_src_configure
+# @DESCRIPTION:
+# Handles logic common to configuring gstreamer plugins
+gstreamer_multilib_src_configure() {
+	local plugin emesonargs=() EMESON_SOURCE=${EMESON_SOURCE:-${S}}
+
+	gstreamer_environment_reset
+
+	# app-editor/vis regex for meson_options.txt: :x/option\('([^']*)'.*/ c/\1/
+	for plugin in ${GST_PLUGINS_DISABLED} ; do
+		emesonargs+=( -D${plugin}=disabled )
+	done
+
+	for plugin in ${GST_PLUGINS_ENABLED} ; do
+		emesonargs+=( -D${plugin}=enabled )
+	done
+
+	if grep -q "option(\'orc\'" "${EMESON_SOURCE}"/meson_options.txt ; then
+		if in_iuse orc ; then
+			emesonargs+=( -Dorc=$(usex orc enabled disabled) )
+		else
+			emesonargs+=( -Dorc=disabled )
+		fi
+	fi
+
+	if grep -q "option(\'maintainer-mode\'" "${EMESON_SOURCE}"/meson_options.txt ; then
+		gst_conf+=( -Dmaintainer-mode=disabled )
+	fi
+
+	if grep -q "option(\'schemas-compile\'" "${EMESON_SOURCE}"/meson_options.txt ; then
+		gst_conf+=( -Dschemas-compile=disabled )
+	fi
+
+	if [[ ${PN} == ${GST_ORG_MODULE} ]]; then
+		emesonargs+=( $(meson_feature nls) )
+	fi
+
+	einfo "Configuring to build ${GST_PLUGINS_ENABLED} plugin(s) ..."
+	emesonargs+=(
+		-Dexamples=disabled
+		-Dpackage-name="Gentoo GStreamer ebuild"
+		-Dpackage-origin="https://www.gentoo.org"
+		"${@}"
+	)
+	meson_src_configure
+}
+
+read -d '' __MESON_EXTRACT_TARGET_FILENAME <<"EOF"
+import json
+import sys
+
+with open("meson-info/intro-targets.json", "r") as targets_file:
+	data = json.load(targets_file)
+
+for i in range(len(data)):
+	target = data[i]
+	if target['installed']:
+		if sys.argv[1] in target['filename'][0]:
+			print(target['filename'][0] + ':' + target['install_filename'][0])
+EOF
+
+# @FUNCTION: _gstreamer_get_target_filename
+# @INTERNAL
+# @DESCRIPTION:
+# Extracts build and target filenames from meson-data for given submatch
+_gstreamer_get_target_filename() {
+	python -c "${__MESON_EXTRACT_TARGET_FILENAME}" "$@"
+}
+
+# @FUNCTION: gstreamer_multilib_src_compile
+# @DESCRIPTION:
+# Compiles requested gstreamer plugin.
+gstreamer_multilib_src_compile() {
+	local plugin_dir plugin
+
+	for plugin_dir in ${GST_PLUGINS_BUILD_DIR} ; do
+		plugin=$(_gstreamer_get_target_filename $(gstreamer_get_plugin_dir ${plugin_dir}))
+		plugin_path="${plugin%%:*}"
+		eninja "${plugin_path/"${BUILD_DIR}/"}"
+	done
+}
+
+# @FUNCTION: gstreamer_multilib_src_install
+# @DESCRIPTION:
+# Installs requested gstreamer plugin.
+gstreamer_multilib_src_install() {
+	local plugin_dir plugin
+
+	for plugin_dir in ${GST_PLUGINS_BUILD_DIR} ; do
+		for plugin in $(_gstreamer_get_target_filename $(gstreamer_get_plugin_dir ${plugin_dir})); do
+			local install_filename="${plugin##*:}"
+			insinto "${install_filename%/*}"
+			doins "${plugin%%:*}"
+		done
+	done
+}
+
+# @FUNCTION: gstreamer_multilib_src_install_all
+# @DESCRIPTION:
+# Installs documentation for requested gstreamer plugin, and removes .la
+# files.
+gstreamer_multilib_src_install_all() {
+	local plugin_dir
+
+	for plugin_dir in ${GST_PLUGINS_BUILD_DIR} ; do
+		local dir=$(gstreamer_get_plugin_dir ${plugin_dir})
+		[[ -e ${dir}/README ]] && dodoc "${dir}"/README
+	done
+
+	prune_libtool_files --modules
+}
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [gentoo-dev] [PATCH] gstreamer-meson.eclass: New eclass required for gstreamer-1.18.0+
  2021-03-17  1:49 [gentoo-dev] [PATCH] gstreamer-meson.eclass: New eclass required for gstreamer-1.18.0+ Haelwenn (lanodan) Monnier
@ 2021-03-17  1:57 ` Sam James
  2021-03-17  9:15   ` Mart Raudsepp
  2021-03-17 16:13 ` Alec Warner
  2021-03-23 12:44 ` [gentoo-dev] [PATCH v2] " Haelwenn (lanodan) Monnier
  2 siblings, 1 reply; 8+ messages in thread
From: Sam James @ 2021-03-17  1:57 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 3464 bytes --]



> On 17 Mar 2021, at 01:49, Haelwenn (lanodan) Monnier <contact@hacktivis.me> wrote:
> 
> Gstreamer switched to meson in 1.16.0 and removed autotools support in 1.18.0,
> this eclass is an update of gstreamer.eclass.
> 
> [snip]

Thanks for working on this!

> +#
> +# GStreamer consuming applications should depend on the specific plugins
> +# they need as defined in their source code. Usually you can find that
> +# out by grepping the source tree for 'factory_make'. If it uses playbin
> +# plugin, consider adding media-plugins/gst-plugins-meta dependency, but
> +# also list any packages that provide explicitly requested plugins.
> +
> +inherit eutils multilib meson multilib-minimal toolchain-funcs versionator xdg-utils

Do we need eutils here?

> +
> +case "${EAPI:-0}" in
> +	5|6)
> +		;;
> +	0|1|2|3|4)
> +		die "EAPI=\"${EAPI:-0}\" is not supported anymore"
> +		;;
> +	*)
> +		die "EAPI=\"${EAPI}\" is not supported yet"
> +		;;
> +esac

EAPI 7?

> [snip]

> +
> +# Even though xz-utils are in @system, they must still be added to DEPEND; see
> +# https://archives.gentoo.org/gentoo-dev/msg_a0d4833eb314d1be5d5802a3b710e0a4.xml
> +if [[ ${GST_TARBALL_SUFFIX} == "xz" ]]; then
> +	DEPEND="${DEPEND} app-arch/xz-utils"
> +fi
> +

BDEPEND in EAPI 7.

> [snip]

> +DEPEND="
> +	>=sys-apps/sed-4
> +	>=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}]
> +"
> +

BDEPEND in EAPI 7.

> [snip]
> +else
> +	IUSE="nls"
> +	DEPEND="${DEPEND} nls? ( >=sys-devel/gettext-0.17 )"

BDEPEND in EAPI 7 unless we’re really building against gettext.
> 
> +
> +read -d '' __MESON_EXTRACT_TARGET_FILENAME <<"EOF"
> +import json
> +import sys
> +
> +with open("meson-info/intro-targets.json", "r") as targets_file:
> +	data = json.load(targets_file)
> +
> +for i in range(len(data)):
> +	target = data[i]
> +	if target['installed']:
> +		if sys.argv[1] in target['filename'][0]:
> +			print(target['filename'][0] + ':' + target['install_filename'][0])
> +EOF
> +

It seems kind of odd to me to do this in global scope.

> +# @FUNCTION: _gstreamer_get_target_filename
> +# @INTERNAL
> +# @DESCRIPTION:
> +# Extracts build and target filenames from meson-data for given submatch
> +_gstreamer_get_target_filename() {
> +	python -c "${__MESON_EXTRACT_TARGET_FILENAME}" "$@"
> +}

|| die on external commands. We probably want ${EPYTHON} and to use
a Python eclass here.

> +
> +# @FUNCTION: gstreamer_multilib_src_compile
> +# @DESCRIPTION:
> +# Compiles requested gstreamer plugin.
> +gstreamer_multilib_src_compile() {
> +	local plugin_dir plugin
> +
> +	for plugin_dir in ${GST_PLUGINS_BUILD_DIR} ; do

“${GST_PLUGINS_BUILD_DIR}"

> +		plugin=$(_gstreamer_get_target_filename $(gstreamer_get_plugin_dir ${plugin_dir}))
> +		plugin_path="${plugin%%:*}"
> +		eninja "${plugin_path/"${BUILD_DIR}/"}"

No need for double quoting?

> +# @FUNCTION: gstreamer_multilib_src_install_all
> +# @DESCRIPTION:
> +# Installs documentation for requested gstreamer plugin, and removes .la
> +# files.
> +gstreamer_multilib_src_install_all() {
> +	local plugin_dir
> +
> +	for plugin_dir in ${GST_PLUGINS_BUILD_DIR} ; do
> +		local dir=$(gstreamer_get_plugin_dir ${plugin_dir})
> +		[[ -e ${dir}/README ]] && dodoc "${dir}"/README
> +	done
> +
> +	prune_libtool_files --modules

Deprecated in newer EAPIs, let’s do it manually.

> +}
> --
> 2.26.2
> 
> 


[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 618 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [gentoo-dev] [PATCH] gstreamer-meson.eclass: New eclass required for gstreamer-1.18.0+
  2021-03-17  1:57 ` Sam James
@ 2021-03-17  9:15   ` Mart Raudsepp
  2021-03-17  9:29     ` Haelwenn (lanodan) Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Mart Raudsepp @ 2021-03-17  9:15 UTC (permalink / raw
  To: gentoo-dev

Thanks for working on this, some very initial comments below

Ühel kenal päeval, K, 17.03.2021 kell 01:57, kirjutas Sam James:
> > +# @FUNCTION: gstreamer_multilib_src_install_all
> > +# @DESCRIPTION:
> > +# Installs documentation for requested gstreamer plugin, and
> > removes
> .la
> > +# files.
> > +gstreamer_multilib_src_install_all() {
> > +	local plugin_dir
> > +
> > +	for plugin_dir in ${GST_PLUGINS_BUILD_DIR} ; do
> > +		local dir=$(gstreamer_get_plugin_dir
> > ${plugin_dir})
> > +		[[ -e ${dir}/README ]] && dodoc "${dir}"/README
> > +	done
> > +
> > +	prune_libtool_files --modules
> 
> Deprecated in newer EAPIs, let’s do it manually.

I don't think that ought to be necessary at all, as a meson build
wouldn't be generating libtool files.


My main initial question on this version is:
How does it behave with helper libraries from the same tarball?

Basically what gstreamer_system_link function solved in the autotools
eclass.
E.g., if you build gst-plugins-libvisual, is it building gstreamer-
audio, gstreamer-video and gstreamer-pbutils as well again
(automatically due to generated ninja dependencies), or picks them up
from gst-plugins-base?

Some other quick notes:

* I would prefer this being EAPI-7 only
* Don't make nls optional
* It would be neat if we had a QA warning when a split plugin uses orc,
but doesn't have in IUSE for it (or vice-versa); maybe that's doable by
checking if the plugin meson.build uses orc_dep?


Mart



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [gentoo-dev] [PATCH] gstreamer-meson.eclass: New eclass required for gstreamer-1.18.0+
  2021-03-17  9:15   ` Mart Raudsepp
@ 2021-03-17  9:29     ` Haelwenn (lanodan) Monnier
  2021-03-17 14:24       ` Mart Raudsepp
  0 siblings, 1 reply; 8+ messages in thread
From: Haelwenn (lanodan) Monnier @ 2021-03-17  9:29 UTC (permalink / raw
  To: gentoo-dev

[2021-03-17 11:15:26+0200] Mart Raudsepp:
> Ühel kenal päeval, K, 17.03.2021 kell 01:57, kirjutas Sam James:
> > > +# @FUNCTION: gstreamer_multilib_src_install_all
> > > +# @DESCRIPTION:
> > > +# Installs documentation for requested gstreamer plugin, and
> > > removes
> > .la
> > > +# files.
> > > +gstreamer_multilib_src_install_all() {
> > > +	local plugin_dir
> > > +
> > > +	for plugin_dir in ${GST_PLUGINS_BUILD_DIR} ; do
> > > +		local dir=$(gstreamer_get_plugin_dir
> > > ${plugin_dir})
> > > +		[[ -e ${dir}/README ]] && dodoc "${dir}"/README
> > > +	done
> > > +
> > > +	prune_libtool_files --modules
> > 
> > Deprecated in newer EAPIs, let’s do it manually.
> 
> I don't think that ought to be necessary at all, as a meson build
> wouldn't be generating libtool files.
> 
> 
> My main initial question on this version is:
> How does it behave with helper libraries from the same tarball?

It has been in my overlay for a while (haven't included all the splitted plugins though).

ie. https://hacktivis.me/git/overlay/file/media-plugins/gst-plugins-hls/gst-plugins-hls-1.18.4.ebuild.html

> Basically what gstreamer_system_link function solved in the autotools
> eclass.
> E.g., if you build gst-plugins-libvisual, is it building gstreamer-
> audio, gstreamer-video and gstreamer-pbutils as well again
> (automatically due to generated ninja dependencies), or picks them up
> from gst-plugins-base?

I think this particular one isn't solved yet. Mainly because it doesn't
seems to have caused me issues yet.

> Some other quick notes:
> 
> * I would prefer this being EAPI-7 only

Yeah, as discussed in #gentoo-dev I'm doing this, pushed a WIP version in my
overlay if you want to take an early look.

> * Don't make nls optional

What's the reason for this? It's the case with gstreamer::gentoo.

> * It would be neat if we had a QA warning when a split plugin uses orc,
> but doesn't have in IUSE for it (or vice-versa); maybe that's doable by
> checking if the plugin meson.build uses orc_dep?

Yeah, orc should be automatically added.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [gentoo-dev] [PATCH] gstreamer-meson.eclass: New eclass required for gstreamer-1.18.0+
  2021-03-17  9:29     ` Haelwenn (lanodan) Monnier
@ 2021-03-17 14:24       ` Mart Raudsepp
  0 siblings, 0 replies; 8+ messages in thread
From: Mart Raudsepp @ 2021-03-17 14:24 UTC (permalink / raw
  To: gentoo-dev

Ühel kenal päeval, K, 17.03.2021 kell 10:29, kirjutas Haelwenn
(lanodan) Monnier:
> > My main initial question on this version is:
> > How does it behave with helper libraries from the same tarball?
> 
> It has been in my overlay for a while (haven't included all the
> splitted plugins though).
> 
> ie. 
> https://hacktivis.me/git/overlay/file/media-plugins/gst-plugins-hls/gst-plugins-hls-1.18.4.ebuild.html
> 
> > Basically what gstreamer_system_link function solved in the
> > autotools
> > eclass.
> > E.g., if you build gst-plugins-libvisual, is it building gstreamer-
> > audio, gstreamer-video and gstreamer-pbutils as well again
> > (automatically due to generated ninja dependencies), or picks them
> > up
> > from gst-plugins-base?
> 
> I think this particular one isn't solved yet. Mainly because it
> doesn't
> seems to have caused me issues yet.

I think it would be building it again, and then link it against that
new build, instead of the system version that it'll actually use at
runtime. That sounds like a recipe for hard to track issues down the
line.
But maybe if it works out fine right now, it's worth ignoring it at
first, and solving it later on.

> 
> > * Don't make nls optional
> 
> What's the reason for this? It's the case with gstreamer::gentoo.

OK, I guess we could keep it too - maybe someone needs for very
embedded builds.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [gentoo-dev] [PATCH] gstreamer-meson.eclass: New eclass required for gstreamer-1.18.0+
  2021-03-17  1:49 [gentoo-dev] [PATCH] gstreamer-meson.eclass: New eclass required for gstreamer-1.18.0+ Haelwenn (lanodan) Monnier
  2021-03-17  1:57 ` Sam James
@ 2021-03-17 16:13 ` Alec Warner
  2021-03-23 12:44 ` [gentoo-dev] [PATCH v2] " Haelwenn (lanodan) Monnier
  2 siblings, 0 replies; 8+ messages in thread
From: Alec Warner @ 2021-03-17 16:13 UTC (permalink / raw
  To: Gentoo Dev; +Cc: Haelwenn (lanodan) Monnier

On Tue, Mar 16, 2021 at 6:49 PM Haelwenn (lanodan) Monnier
<contact@hacktivis.me> wrote:
>
> Gstreamer switched to meson in 1.16.0 and removed autotools support in 1.18.0,
> this eclass is an update of gstreamer.eclass.
>
> One significant change between autotools and meson is that in the latter we
> don't have easily extractable semantics in the buildsystem to get a list
> of plugins with extraneous dependencies that we currently split in other
> packages.
> Hence the rather ugly but currently required GST_PLUGINS_DISABLED block.
>
> Fixes: https://bugs.gentoo.org/690468
>
> Signed-off-by: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
> ---
>  eclass/gstreamer-meson.eclass | 293 ++++++++++++++++++++++++++++++++++
>  1 file changed, 293 insertions(+)
>  create mode 100644 eclass/gstreamer-meson.eclass
>
> diff --git a/eclass/gstreamer-meson.eclass b/eclass/gstreamer-meson.eclass
> new file mode 100644
> index 00000000000..263deeb08aa
> --- /dev/null
> +++ b/eclass/gstreamer-meson.eclass
> @@ -0,0 +1,293 @@
> +# Copyright 1999-2021 Gentoo Authors
> +# Distributed under the terms of the GNU General Public License v2
> +
> +# @ECLASS: gstreamer-meson.eclass
> +# @MAINTAINER:
> +# gstreamer@gentoo.org
> +# @AUTHOR:
> +# Michał Górny <mgorny@gentoo.org>
> +# Gilles Dartiguelongue <eva@gentoo.org>
> +# Saleem Abdulrasool <compnerd@gentoo.org>
> +# foser <foser@gentoo.org>
> +# zaheerm <zaheerm@gentoo.org>
> +# Steven Newbury
> +# Haelwenn (lanodan) Monnier <contact@hacktivis.me>
> +# @SUPPORTED_EAPIS: 5 6
> +# @BLURB: Helps building core & split gstreamer plugins.
> +# @DESCRIPTION:
> +# Eclass to make external gst-plugins emergable on a per-plugin basis
> +# and to solve the problem with gst-plugins generating far too much
> +# unneeded dependencies.
> +#
> +# GStreamer consuming applications should depend on the specific plugins
> +# they need as defined in their source code. Usually you can find that
> +# out by grepping the source tree for 'factory_make'. If it uses playbin
> +# plugin, consider adding media-plugins/gst-plugins-meta dependency, but
> +# also list any packages that provide explicitly requested plugins.
> +
> +inherit eutils multilib meson multilib-minimal toolchain-funcs versionator xdg-utils
> +
> +case "${EAPI:-0}" in
> +       5|6)
> +               ;;
> +       0|1|2|3|4)
> +               die "EAPI=\"${EAPI:-0}\" is not supported anymore"
> +               ;;
> +       *)
> +               die "EAPI=\"${EAPI}\" is not supported yet"
> +               ;;
> +esac
> +
> +# @ECLASS-VARIABLE: GST_PLUGINS_ENABLED
> +# @DESCRIPTION:
> +# Defines the plugins to be built.
> +# May be set by an ebuild and contain more than one indentifier, space
> +# seperated (only src_configure can handle mutiple plugins at this time).
> +: ${GST_PLUGINS_ENABLED:=${PN/gst-plugins-/}}
> +
> +# @ECLASS-VARIABLE: GST_PLUGINS_DISABLED
> +# @DESCRIPTION:
> +# Defines the plugins to not be built, GST_PLUGINS_ENABLED overrides it.
> +# May be set by an ebuild and contain more than one indentifier, space
> +# seperated (only src_configure can handle mutiple plugins at this time).
> +case "${GST_ORG_MODULE}" in
> +       # copied GST_PLUGINS_DISABLED from media-libs/${GST_ORG_MODULE} then added GST_PLUGINS_ENABLED
> +       gst-plugins-bad)
> +               # removed from list: shm ipcpipeline gl
> +               GST_PLUGINS_DISABLED="aom avtp androidmedia applemedia assrender bluez bs2b bz2 chromaprint closedcaption colormanagement curl curl-ssh2 d3dvideosink d3d11 dash dc1394 decklink directfb directsound dtls dts dvb faac faad fbdev fdkaac flite fluidsynth gme gsm iqa kate kms ladspa libde265 libmms lv2 mediafoundation microdns modplug mpeg2enc mplex msdk musepack neon nvcodec ofa openal openexr openh264 openjpeg openmpt openni2 opensles opus resindvd rsvg rtmp sbc sctp smoothstreaming sndfile soundtouch spandsp srt srtp svthevcenc teletext tinyalsa transcode ttml uvch264 va voaacenc voamrwbenc vulkan wasapi wasapi2 webp webrtc webrtcdsp wildmidi winks winscreencap x265 zbar zxing wpe magicleap v4l2codecs hls opencv"
> +               GST_PLUGINS_DISABLED="${GST_PLUGINS_DISABLED} accurip adpcmdec adpcmenc aiff asfmux audiobuffersplit audiofxbad audiolatency audiomixmatrix audiovisualizers autoconvert bayer camerabin2 coloreffects deb ugutils dvbsubenc dvbsuboverlay dvdspu faceoverlay festival fieldanalysis freeverb frei0r gaudieffects gdp geometrictransform id3tag inter interlace ivfpars e ivtc jp2kdecimator jpegformat librfb midi mpegdemux mpegpsmux mpegtsdemux mpegtsmux mxf netsim onvif pcapparse pnm proxy rawparse removesilence rist rtmp2 rtp sdp segmentclip siren smooth speed subenc switchbin timecode videofilters videoframe_audiolevel videoparsers videosignal vmnc y4m"
> +               ;;
> +       gst-plugins-base)
> +               GST_PLUGINS_DISABLED="cdparanoia libvisual opus tremor"
> +               GST_PLUGINS_DISABLED="${GST_PLUGINS_DISABLED} adder app audioconvert audiomixer audiorate audioresample audiotestsrc compositor encoding gio gio-typefinder overlaycomposition pbtypes playback rawparse subparse tcp typefind videoconvert videorate videoscale videotestsrc volume"
> +               ;;
> +       gst-plugins-good)
> +               GST_PLUGINS_DISABLED="aalib cairo directsound dv dv1394 flac gdk-pixbuf gtk3 jack jpeg lame libcaca mpg123 oss oss4 osxaudio osxvideo png pulse qt5 shout2 soup speex taglib twolame vpx waveform wavpack  rpicamsrc ximagesrc v4l2"
> +               GST_PLUGINS_DISABLED="${GST_PLUGINS_DISABLED} alpha apetag audiofx audioparsers auparse autodetect avi cutter debugutils deinterlace dtmf effectv equalizer flv flx goom goom2k1 icydemux id3demux imagefreeze interleave isomp4 law level matroska monoscope multifile multipart replaygain rtp rtpmanager rtsp shapewipe smpte spectrum udp videobox videocrop videofilter videomixer wavenc wavparse y4m"
> +               ;;
> +       gst-plugins-ugly)
> +               GST_PLUGINS_DISABLED="a52dec amrnb amrwbdec cdio dvdread mpeg2dec sidplay x264"
> +               GST_PLUGINS_DISABLED="${GST_PLUGINS_DISABLED} asfdemux dvdlpcmdec dvdsub realmedia xingmux"
> +               ;;
> +esac
> +
> +# @ECLASS-VARIABLE: GST_PLUGINS_BUILD_DIR
> +# @DESCRIPTION:
> +# Actual build directory of the plugin.
> +# Most often the same as the configure switch name.
> +: ${GST_PLUGINS_BUILD_DIR:=${PN/gst-plugins-/}}
> +
> +# @ECLASS-VARIABLE: GST_TARBALL_SUFFIX
> +# @DESCRIPTION:
> +# Most projects hosted on gstreamer.freedesktop.org mirrors provide
> +# tarballs as tar.bz2 or tar.xz. This eclass defaults to xz. This is
> +# because the gstreamer mirrors are moving to only have xz tarballs for
> +# new releases.
> +: ${GST_TARBALL_SUFFIX:="xz"}
> +
> +# Even though xz-utils are in @system, they must still be added to DEPEND; see
> +# https://archives.gentoo.org/gentoo-dev/msg_a0d4833eb314d1be5d5802a3b710e0a4.xml
> +if [[ ${GST_TARBALL_SUFFIX} == "xz" ]]; then
> +       DEPEND="${DEPEND} app-arch/xz-utils"
> +fi
> +
> +# @ECLASS-VARIABLE: GST_ORG_MODULE
> +# @DESCRIPTION:
> +# Name of the module as hosted on gstreamer.freedesktop.org mirrors.
> +# Leave unset if package name matches module name.
> +: ${GST_ORG_MODULE:=$PN}
> +
> +# @ECLASS-VARIABLE: GST_ORG_PVP
> +# @INTERNAL
> +# @DESCRIPTION:
> +# Major and minor numbers of the version number.
> +: ${GST_ORG_PVP:=$(get_version_component_range 1-2)}
> +
> +
> +DESCRIPTION="${BUILD_GST_PLUGINS} plugin for gstreamer"
> +HOMEPAGE="https://gstreamer.freedesktop.org/"
> +SRC_URI="https://gstreamer.freedesktop.org/src/${GST_ORG_MODULE}/${GST_ORG_MODULE}-${PV}.tar.${GST_TARBALL_SUFFIX}"
> +
> +LICENSE="GPL-2"
> +case ${GST_ORG_PVP} in
> +       1.*) SLOT="1.0"; GST_MIN_PV="1.2.4-r1" ;;
> +       *) die "Unkown gstreamer release."
> +esac
> +
> +S="${WORKDIR}/${GST_ORG_MODULE}-${PV}"
> +
> +RDEPEND="
> +       >=dev-libs/glib-2.38.2-r1:2[${MULTILIB_USEDEP}]
> +       >=media-libs/gstreamer-${GST_MIN_PV}:${SLOT}[${MULTILIB_USEDEP}]
> +"
> +DEPEND="
> +       >=sys-apps/sed-4
> +       >=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}]
> +"
> +
> +# Export common multilib phases.
> +multilib_src_configure() { gstreamer_multilib_src_configure; }
> +
> +if [[ ${PN} != ${GST_ORG_MODULE} ]]; then
> +       # Do not run test phase for invididual plugin ebuilds.
> +       RESTRICT="test"
> +       RDEPEND="${RDEPEND}
> +               >=media-libs/${GST_ORG_MODULE}-${PV}:${SLOT}[${MULTILIB_USEDEP}]"
> +
> +       # Export multilib phases used for split builds.
> +       multilib_src_compile() { gstreamer_multilib_src_compile; }
> +       multilib_src_install() { gstreamer_multilib_src_install; }
> +       multilib_src_install_all() { gstreamer_multilib_src_install_all; }
> +else
> +       IUSE="nls"
> +       DEPEND="${DEPEND} nls? ( >=sys-devel/gettext-0.17 )"
> +
> +       multilib_src_compile() { eninja; }
> +       multilib_src_install() { DESTDIR="${D}" eninja install; }
> +fi
> +
> +DEPEND="${DEPEND} ${RDEPEND}"
> +
> +# @FUNCTION: gstreamer_environment_reset
> +# @INTERNAL
> +# @DESCRIPTION:
> +# Clean up environment for clean builds.
> +# >=dev-lang/orc-0.4.23 rely on environment variables to find a place to
> +# allocate files to mmap.
> +gstreamer_environment_reset() {
> +       xdg_environment_reset
> +}
> +
> +# @FUNCTION: gstreamer_get_plugin_dir
> +# @USAGE: gstreamer_get_plugin_dir [<build_dir>]
> +# @INTERNAL
> +# @DESCRIPTION:
> +# Finds plugin build directory and output it.
> +# Defaults to ${GST_PLUGINS_BUILD_DIR} if argument is not provided
> +gstreamer_get_plugin_dir() {
> +       local build_dir=${1:-${GST_PLUGINS_BUILD_DIR}}
> +
> +       if [[ ! -d ${S}/ext/${build_dir} ]]; then
> +               if [[ ! -d ${S}/sys/${build_dir} ]]; then
> +                       ewarn "No such plugin directory"
> +                       die
> +               fi
> +               einfo "Building system plugin in ${build_dir}..." >&2
> +               echo sys/${build_dir}
> +       else
> +               einfo "Building external plugin in ${build_dir}..." >&2
> +               echo ext/${build_dir}
> +       fi
> +}
> +
> +# @FUNCTION: gstreamer_multilib_src_configure
> +# @DESCRIPTION:
> +# Handles logic common to configuring gstreamer plugins
> +gstreamer_multilib_src_configure() {
> +       local plugin emesonargs=() EMESON_SOURCE=${EMESON_SOURCE:-${S}}
> +
> +       gstreamer_environment_reset
> +
> +       # app-editor/vis regex for meson_options.txt: :x/option\('([^']*)'.*/ c/\1/
> +       for plugin in ${GST_PLUGINS_DISABLED} ; do
> +               emesonargs+=( -D${plugin}=disabled )
> +       done
> +
> +       for plugin in ${GST_PLUGINS_ENABLED} ; do
> +               emesonargs+=( -D${plugin}=enabled )
> +       done
> +
> +       if grep -q "option(\'orc\'" "${EMESON_SOURCE}"/meson_options.txt ; then
> +               if in_iuse orc ; then
> +                       emesonargs+=( -Dorc=$(usex orc enabled disabled) )
> +               else
> +                       emesonargs+=( -Dorc=disabled )
> +               fi
> +       fi
> +
> +       if grep -q "option(\'maintainer-mode\'" "${EMESON_SOURCE}"/meson_options.txt ; then
> +               gst_conf+=( -Dmaintainer-mode=disabled )
> +       fi
> +
> +       if grep -q "option(\'schemas-compile\'" "${EMESON_SOURCE}"/meson_options.txt ; then
> +               gst_conf+=( -Dschemas-compile=disabled )
> +       fi
> +
> +       if [[ ${PN} == ${GST_ORG_MODULE} ]]; then
> +               emesonargs+=( $(meson_feature nls) )
> +       fi
> +
> +       einfo "Configuring to build ${GST_PLUGINS_ENABLED} plugin(s) ..."
> +       emesonargs+=(
> +               -Dexamples=disabled
> +               -Dpackage-name="Gentoo GStreamer ebuild"
> +               -Dpackage-origin="https://www.gentoo.org"
> +               "${@}"
> +       )
> +       meson_src_configure
> +}
> +
> +read -d '' __MESON_EXTRACT_TARGET_FILENAME <<"EOF"
> +import json
> +import sys
> +
> +with open("meson-info/intro-targets.json", "r") as targets_file:
> +       data = json.load(targets_file)
> +
> +for i in range(len(data)):

Not grokking this loop.

for target in data.values():
  if target['installed']:
    ...

Is likely sufficient.

Also this short script has no error handling, so any malformed json
will crash it, as well any json objects missing these fields; I assume
that's OK because...those all go to stderr, right; and print() goes to
stdout by default, so it won't hurt _gstreamer_get_target_filename ?

> +       target = data[i]
> +       if target['installed']:
> +               if sys.argv[1] in target['filename'][0]:
> +                       print(target['filename'][0] + ':' + target['install_filename'][0])
> +EOF
> +
> +# @FUNCTION: _gstreamer_get_target_filename
> +# @INTERNAL
> +# @DESCRIPTION:
> +# Extracts build and target filenames from meson-data for given submatch
> +_gstreamer_get_target_filename() {
> +       python -c "${__MESON_EXTRACT_TARGET_FILENAME}" "$@"
> +}
> +
> +# @FUNCTION: gstreamer_multilib_src_compile
> +# @DESCRIPTION:
> +# Compiles requested gstreamer plugin.
> +gstreamer_multilib_src_compile() {
> +       local plugin_dir plugin
> +
> +       for plugin_dir in ${GST_PLUGINS_BUILD_DIR} ; do
> +               plugin=$(_gstreamer_get_target_filename $(gstreamer_get_plugin_dir ${plugin_dir}))
> +               plugin_path="${plugin%%:*}"
> +               eninja "${plugin_path/"${BUILD_DIR}/"}"
> +       done
> +}
> +
> +# @FUNCTION: gstreamer_multilib_src_install
> +# @DESCRIPTION:
> +# Installs requested gstreamer plugin.
> +gstreamer_multilib_src_install() {
> +       local plugin_dir plugin
> +
> +       for plugin_dir in ${GST_PLUGINS_BUILD_DIR} ; do
> +               for plugin in $(_gstreamer_get_target_filename $(gstreamer_get_plugin_dir ${plugin_dir})); do
> +                       local install_filename="${plugin##*:}"
> +                       insinto "${install_filename%/*}"
> +                       doins "${plugin%%:*}"
> +               done
> +       done
> +}
> +
> +# @FUNCTION: gstreamer_multilib_src_install_all
> +# @DESCRIPTION:
> +# Installs documentation for requested gstreamer plugin, and removes .la
> +# files.
> +gstreamer_multilib_src_install_all() {
> +       local plugin_dir
> +
> +       for plugin_dir in ${GST_PLUGINS_BUILD_DIR} ; do
> +               local dir=$(gstreamer_get_plugin_dir ${plugin_dir})
> +               [[ -e ${dir}/README ]] && dodoc "${dir}"/README
> +       done
> +
> +       prune_libtool_files --modules
> +}
> --
> 2.26.2
>
>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [gentoo-dev] [PATCH v2] gstreamer-meson.eclass: New eclass required for gstreamer-1.18.0+
  2021-03-17  1:49 [gentoo-dev] [PATCH] gstreamer-meson.eclass: New eclass required for gstreamer-1.18.0+ Haelwenn (lanodan) Monnier
  2021-03-17  1:57 ` Sam James
  2021-03-17 16:13 ` Alec Warner
@ 2021-03-23 12:44 ` Haelwenn (lanodan) Monnier
  2021-03-23 13:05   ` Michał Górny
  2 siblings, 1 reply; 8+ messages in thread
From: Haelwenn (lanodan) Monnier @ 2021-03-23 12:44 UTC (permalink / raw
  To: gentoo-dev; +Cc: Haelwenn (lanodan) Monnier

Gstreamer switched to meson in 1.16.0 and removed autotools support in 1.18.0,
this eclass is an update of gstreamer.eclass.

One significant change between autotools and meson is that in the latter we
don't have easily extractable semantics in the buildsystem to get a list
of plugins with extraneous dependencies that we currently split in other
packages.
Hence the rather ugly but currently required GST_PLUGINS_DISABLED block.
The gstreamer_system_link function also got lost in translation.

Differences from version 1:
- Move to EAPI-7, including moving deps from DEPEND to BDEPEND when appropriate
- Port python script to perl, this allows to avoid having to add PYTHON_COMPAT
  into a python-unrelated eclass
- Drop errorneous MULTILIB_USEDEP on virtual/pkgconfig
- Fix running tests: defining multilib_src_test, media-libs/gstreamer[test] dep
- Fix ebuild emesonargs being ignored
- Remove legacy prune_libtool_files
- virtualx wrapped for testing

Fixes: https://bugs.gentoo.org/690468

Signed-off-by: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
---
 eclass/gstreamer-meson.eclass | 320 ++++++++++++++++++++++++++++++++++
 1 file changed, 320 insertions(+)
 create mode 100644 eclass/gstreamer-meson.eclass

diff --git a/eclass/gstreamer-meson.eclass b/eclass/gstreamer-meson.eclass
new file mode 100644
index 00000000000..14a825f76b5
--- /dev/null
+++ b/eclass/gstreamer-meson.eclass
@@ -0,0 +1,320 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: gstreamer-meson.eclass
+# @MAINTAINER:
+# gstreamer@gentoo.org
+# @AUTHOR:
+# Michał Górny <mgorny@gentoo.org>
+# Gilles Dartiguelongue <eva@gentoo.org>
+# Saleem Abdulrasool <compnerd@gentoo.org>
+# foser <foser@gentoo.org>
+# zaheerm <zaheerm@gentoo.org>
+# Steven Newbury
+# Haelwenn (lanodan) Monnier <contact@hacktivis.me>
+# @SUPPORTED_EAPIS: 7
+# @BLURB: Helps building core & split gstreamer plugins.
+# @DESCRIPTION:
+# Eclass to make external gst-plugins emergable on a per-plugin basis
+# and to solve the problem with gst-plugins generating far too much
+# unneeded dependencies.
+#
+# GStreamer consuming applications should depend on the specific plugins
+# they need as defined in their source code. Usually you can find that
+# out by grepping the source tree for 'factory_make'. If it uses playbin
+# plugin, consider adding media-plugins/gst-plugins-meta dependency, but
+# also list any packages that provide explicitly requested plugins.
+
+inherit multilib virtualx meson toolchain-funcs xdg-utils multilib-minimal
+
+case "${EAPI:-0}" in
+	7)
+		;;
+	*)
+		die "EAPI=\"${EAPI}\" is not supported"
+		;;
+esac
+
+# @ECLASS-VARIABLE: GST_PLUGINS_ENABLED
+# @DESCRIPTION:
+# Defines the plugins to be built.
+# May be set by an ebuild and contain more than one indentifier, space
+# seperated (only src_configure can handle mutiple plugins at this time).
+: ${GST_PLUGINS_ENABLED:=${PN/gst-plugins-/}}
+
+# @ECLASS-VARIABLE: GST_PLUGINS_DISABLED
+# @DESCRIPTION:
+# Defines the plugins to not be built, GST_PLUGINS_ENABLED overrides it.
+# May be set by an ebuild and contain more than one indentifier, space
+# seperated (only src_configure can handle mutiple plugins at this time).
+case "${GST_ORG_MODULE}" in
+	# copied GST_PLUGINS_DISABLED from media-libs/${GST_ORG_MODULE} then added GST_PLUGINS_ENABLED
+	gst-plugins-bad)
+		# removed from list: shm ipcpipeline gl
+		GST_PLUGINS_DISABLED="aom avtp androidmedia applemedia assrender bluez bs2b bz2 chromaprint closedcaption colormanagement curl curl-ssh2 d3dvideosink d3d11 dash dc1394 decklink directfb directsound dtls dts dvb faac faad fbdev fdkaac flite fluidsynth gme gsm iqa kate kms ladspa libde265 libmms lv2 mediafoundation microdns modplug mpeg2enc mplex msdk musepack neon nvcodec ofa openal openexr openh264 openjpeg openmpt openni2 opensles opus resindvd rsvg rtmp sbc sctp smoothstreaming sndfile soundtouch spandsp srt srtp svthevcenc teletext tinyalsa transcode ttml uvch264 va voaacenc voamrwbenc vulkan wasapi wasapi2 webp webrtc webrtcdsp wildmidi winks winscreencap x265 zbar zxing wpe magicleap v4l2codecs hls opencv"
+		GST_PLUGINS_DISABLED="${GST_PLUGINS_DISABLED} accurip adpcmdec adpcmenc aiff asfmux audiobuffersplit audiofxbad audiolatency audiomixmatrix audiovisualizers autoconvert bayer camerabin2 coloreffects deb ugutils dvbsubenc dvbsuboverlay dvdspu faceoverlay festival fieldanalysis freeverb frei0r gaudieffects gdp geometrictransform id3tag inter interlace ivfpars e ivtc jp2kdecimator jpegformat librfb midi mpegdemux mpegpsmux mpegtsdemux mpegtsmux mxf netsim onvif pcapparse pnm proxy rawparse removesilence rist rtmp2 rtp sdp segmentclip siren smooth speed subenc switchbin timecode videofilters videoframe_audiolevel videoparsers videosignal vmnc y4m"
+		;;
+	gst-plugins-base)
+		GST_PLUGINS_DISABLED="cdparanoia libvisual opus tremor"
+		GST_PLUGINS_DISABLED="${GST_PLUGINS_DISABLED} adder app audioconvert audiomixer audiorate audioresample audiotestsrc compositor encoding gio gio-typefinder overlaycomposition pbtypes playback rawparse subparse tcp typefind videoconvert videorate videoscale videotestsrc volume"
+		;;
+	gst-plugins-good)
+		GST_PLUGINS_DISABLED="aalib cairo directsound dv dv1394 flac gdk-pixbuf gtk3 jack jpeg lame libcaca mpg123 oss oss4 osxaudio osxvideo png pulse qt5 shout2 soup speex taglib twolame vpx waveform wavpack  rpicamsrc ximagesrc v4l2"
+		GST_PLUGINS_DISABLED="${GST_PLUGINS_DISABLED} alpha apetag audiofx audioparsers auparse autodetect avi cutter debugutils deinterlace dtmf effectv equalizer flv flx goom goom2k1 icydemux id3demux imagefreeze interleave isomp4 law level matroska monoscope multifile multipart replaygain rtp rtpmanager rtsp shapewipe smpte spectrum udp videobox videocrop videofilter videomixer wavenc wavparse y4m"
+		;;
+	gst-plugins-ugly)
+		GST_PLUGINS_DISABLED="a52dec amrnb amrwbdec cdio dvdread mpeg2dec sidplay x264"
+		GST_PLUGINS_DISABLED="${GST_PLUGINS_DISABLED} asfdemux dvdlpcmdec dvdsub realmedia xingmux"
+		;;
+esac
+
+# @ECLASS-VARIABLE: GST_PLUGINS_BUILD_DIR
+# @DESCRIPTION:
+# Actual build directories of the plugins.
+# Most often the same as the configure switch name.
+# FIXME: Change into a bash array
+: ${GST_PLUGINS_BUILD_DIR:=${PN/gst-plugins-/}}
+
+# @ECLASS-VARIABLE: GST_TARBALL_SUFFIX
+# @DESCRIPTION:
+# Most projects hosted on gstreamer.freedesktop.org mirrors provide
+# tarballs as tar.bz2 or tar.xz. This eclass defaults to xz. This is
+# because the gstreamer mirrors are moving to only have xz tarballs for
+# new releases.
+: ${GST_TARBALL_SUFFIX:="xz"}
+
+# Even though xz-utils are in @system, they must still be added to BDEPEND; see
+# https://archives.gentoo.org/gentoo-dev/msg_a0d4833eb314d1be5d5802a3b710e0a4.xml
+if [[ ${GST_TARBALL_SUFFIX} == "xz" ]]; then
+	BDEPEND="${BDEPEND} app-arch/xz-utils"
+fi
+
+# @ECLASS-VARIABLE: GST_ORG_MODULE
+# @DESCRIPTION:
+# Name of the module as hosted on gstreamer.freedesktop.org mirrors.
+# Leave unset if package name matches module name.
+: ${GST_ORG_MODULE:=$PN}
+
+# @ECLASS-VARIABLE: GST_ORG_PVP
+# @INTERNAL
+# @DESCRIPTION:
+# Major and minor numbers of the version number.
+: ${GST_ORG_PVP:=$(ver_cut 1-2)}
+
+
+DESCRIPTION="${BUILD_GST_PLUGINS} plugin for gstreamer"
+HOMEPAGE="https://gstreamer.freedesktop.org/"
+SRC_URI="https://gstreamer.freedesktop.org/src/${GST_ORG_MODULE}/${GST_ORG_MODULE}-${PV}.tar.${GST_TARBALL_SUFFIX}"
+
+LICENSE="GPL-2"
+case ${GST_ORG_PVP} in
+	1.*) SLOT="1.0"; GST_MIN_PV="1.2.4-r1" ;;
+	*) die "Unkown gstreamer release."
+esac
+
+S="${WORKDIR}/${GST_ORG_MODULE}-${PV}"
+
+RDEPEND="
+	>=dev-libs/glib-2.40.0:2[${MULTILIB_USEDEP}]
+	>=media-libs/gstreamer-${GST_MIN_PV}:${SLOT}[${MULTILIB_USEDEP}]
+"
+BDEPEND="
+	>=sys-apps/sed-4
+	virtual/pkgconfig
+	virtual/perl-JSON-PP
+"
+
+# Export common multilib phases.
+multilib_src_configure() { gstreamer_multilib_src_configure; }
+
+if [[ ${PN} != ${GST_ORG_MODULE} ]]; then
+	# Do not run test phase for invididual plugin ebuilds.
+	RESTRICT="test"
+	RDEPEND="${RDEPEND}
+		>=media-libs/${GST_ORG_MODULE}-${PV}:${SLOT}[${MULTILIB_USEDEP}]"
+
+	# Export multilib phases used for split builds.
+	multilib_src_compile() { gstreamer_multilib_src_compile; }
+	multilib_src_install() { gstreamer_multilib_src_install; }
+	multilib_src_install_all() { gstreamer_multilib_src_install_all; }
+else
+	IUSE="nls test"
+	RESTRICT="!test? ( test )"
+	BDEPEND="${DEPEND}
+		nls? ( >=sys-devel/gettext-0.17 )
+		test? ( media-libs/gstreamer[test] )
+	"
+
+	multilib_src_compile() { eninja; }
+	multilib_src_test() { gstreamer_multilib_src_test; }
+	multilib_src_install() { DESTDIR="${D}" eninja install; }
+fi
+
+DEPEND="${DEPEND} ${RDEPEND}"
+
+# @FUNCTION: gstreamer_environment_reset
+# @INTERNAL
+# @DESCRIPTION:
+# Clean up environment for clean builds.
+# >=dev-lang/orc-0.4.23 rely on environment variables to find a place to
+# allocate files to mmap.
+gstreamer_environment_reset() {
+	xdg_environment_reset
+}
+
+# @FUNCTION: gstreamer_get_plugin_dir
+# @USAGE: gstreamer_get_plugin_dir [<build_dir>]
+# @INTERNAL
+# @DESCRIPTION:
+# Finds plugin build directory and output it.
+# Defaults to ${GST_PLUGINS_BUILD_DIR} if argument is not provided
+gstreamer_get_plugin_dir() {
+	local build_dir=${1:-${GST_PLUGINS_BUILD_DIR}}
+
+	if [[ ! -d ${S}/ext/${build_dir} ]]; then
+		if [[ ! -d ${S}/sys/${build_dir} ]]; then
+			ewarn "No such plugin directory"
+			die
+		fi
+		einfo "Got system plugin in ${build_dir}..." >&2
+		echo sys/${build_dir}
+	else
+		einfo "Got external plugin in ${build_dir}..." >&2
+		echo ext/${build_dir}
+	fi
+}
+
+# @FUNCTION: gstreamer_multilib_src_configure
+# @DESCRIPTION:
+# Handles logic common to configuring gstreamer plugins
+gstreamer_multilib_src_configure() {
+	local plugin gst_conf=( ) EMESON_SOURCE=${EMESON_SOURCE:-${S}}
+
+	gstreamer_environment_reset
+
+	# app-editor/vis regex for meson_options.txt: :x/option\('([^']*)'.*/ c/\1/
+	for plugin in ${GST_PLUGINS_DISABLED} ; do
+		gst_conf+=( -D${plugin}=disabled )
+	done
+
+	for plugin in ${GST_PLUGINS_ENABLED} ; do
+		gst_conf+=( -D${plugin}=enabled )
+	done
+
+	if grep -q "option('orc'" "${EMESON_SOURCE}"/meson_options.txt ; then
+		if in_iuse orc ; then
+			gst_conf+=( -Dorc=$(usex orc enabled disabled) )
+		else
+			gst_conf+=( -Dorc=disabled )
+			eqawarn "QA: IUSE=orc is missing while plugin supports it"
+		fi
+	fi
+
+	if grep -q "option(\'maintainer-mode\'" "${EMESON_SOURCE}"/meson_options.txt ; then
+		gst_conf+=( -Dmaintainer-mode=disabled )
+	fi
+
+	if grep -q "option(\'schemas-compile\'" "${EMESON_SOURCE}"/meson_options.txt ; then
+		gst_conf+=( -Dschemas-compile=disabled )
+	fi
+
+	if [[ ${PN} == ${GST_ORG_MODULE} ]]; then
+		gst_conf+=(
+			$(meson_feature nls)
+			$(meson_feature test tests)
+		)
+	fi
+
+	einfo "Configuring to build ${GST_PLUGINS_ENABLED} plugin(s) ..."
+	gst_conf+=(
+		-Dexamples=disabled
+		-Dpackage-name="Gentoo GStreamer ebuild"
+		-Dpackage-origin="https://www.gentoo.org"
+		-Dgst_debug=false
+		"${@}"
+	)
+	meson_src_configure "${gst_conf[@]}"
+}
+
+
+# @FUNCTION: _gstreamer_get_target_filename
+# @INTERNAL
+# @DESCRIPTION:
+# Looks for first argument being present as a substring in install targets
+# Got ported from python to perl for greater language-stability
+_gstreamer_get_target_filename() {
+	cat >"${WORKDIR}/_gstreamer_get_target_filename.pl" <<"EOF"
+#!/usr/bin/env perl
+use strict;
+use utf8;
+use JSON::PP;
+
+open(my $targets_file, '<:encoding(UTF-8)', 'meson-info/intro-targets.json') || die $!;
+my $data = decode_json <$targets_file>;
+close($targets_file) || die $!;
+
+if(!$ARGV[0]) {
+	die "Requires a target as argument";
+}
+
+foreach my $target (@{$data}) {
+	if($target->{'installed'}
+		and (index($target->{'filename'}[0], $ARGV[0]) != -1)
+	) {
+		printf "%s:%s\n", $target->{'filename'}[0], $target->{'install_filename'}[0];
+	}
+}
+EOF
+
+	chmod +x "${WORKDIR}/_gstreamer_get_target_filename.pl" || die
+
+	perl "${WORKDIR}/_gstreamer_get_target_filename.pl" $@ \
+		|| die "Failed to extract target filenames from meson-info"
+}
+
+# @FUNCTION: gstreamer_multilib_src_compile
+# @DESCRIPTION:
+# Compiles requested gstreamer plugin.
+gstreamer_multilib_src_compile() {
+	local plugin_dir plugin
+
+	for plugin_dir in ${GST_PLUGINS_BUILD_DIR} ; do
+		plugin=$(_gstreamer_get_target_filename $(gstreamer_get_plugin_dir ${plugin_dir}))
+		plugin_path="${plugin%%:*}"
+		eninja "${plugin_path/"${BUILD_DIR}/"}"
+	done
+}
+
+# @FUNCTION: gstreamer_multilib_src_test
+# @DESCRIPTION:
+# Tests the gstreamer plugin (non-split)
+gstreamer_multilib_src_test() {
+	GST_GL_WINDOW=x11 virtx eninja test;
+}
+
+# @FUNCTION: gstreamer_multilib_src_install
+# @DESCRIPTION:
+# Installs requested gstreamer plugin.
+gstreamer_multilib_src_install() {
+	local plugin_dir plugin
+
+	for plugin_dir in ${GST_PLUGINS_BUILD_DIR} ; do
+		for plugin in $(_gstreamer_get_target_filename $(gstreamer_get_plugin_dir ${plugin_dir})); do
+			local install_filename="${plugin##*:}"
+			insinto "${install_filename%/*}"
+			doins "${plugin%%:*}"
+		done
+	done
+}
+
+# @FUNCTION: gstreamer_multilib_src_install_all
+# @DESCRIPTION:
+# Installs documentation for requested gstreamer plugin
+gstreamer_multilib_src_install_all() {
+	local plugin_dir
+
+	for plugin_dir in ${GST_PLUGINS_BUILD_DIR} ; do
+		local dir=$(gstreamer_get_plugin_dir ${plugin_dir})
+		[[ -e ${dir}/README ]] && dodoc "${dir}"/README
+	done
+}
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [gentoo-dev] [PATCH v2] gstreamer-meson.eclass: New eclass required for gstreamer-1.18.0+
  2021-03-23 12:44 ` [gentoo-dev] [PATCH v2] " Haelwenn (lanodan) Monnier
@ 2021-03-23 13:05   ` Michał Górny
  0 siblings, 0 replies; 8+ messages in thread
From: Michał Górny @ 2021-03-23 13:05 UTC (permalink / raw
  To: gentoo-dev; +Cc: Haelwenn (lanodan) Monnier

On Tue, 2021-03-23 at 13:44 +0100, Haelwenn (lanodan) Monnier wrote:
> Gstreamer switched to meson in 1.16.0 and removed autotools support in 1.18.0,
> this eclass is an update of gstreamer.eclass.
> 
> One significant change between autotools and meson is that in the latter we
> don't have easily extractable semantics in the buildsystem to get a list
> of plugins with extraneous dependencies that we currently split in other
> packages.
> Hence the rather ugly but currently required GST_PLUGINS_DISABLED block.
> The gstreamer_system_link function also got lost in translation.
> 
> Differences from version 1:
> - Move to EAPI-7, including moving deps from DEPEND to BDEPEND when appropriate
> - Port python script to perl, this allows to avoid having to add PYTHON_COMPAT
>   into a python-unrelated eclass
> - Drop errorneous MULTILIB_USEDEP on virtual/pkgconfig
> - Fix running tests: defining multilib_src_test, media-libs/gstreamer[test] dep
> - Fix ebuild emesonargs being ignored
> - Remove legacy prune_libtool_files
> - virtualx wrapped for testing
> 
> Fixes: https://bugs.gentoo.org/690468
> 
> Signed-off-by: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
> ---
>  eclass/gstreamer-meson.eclass | 320 ++++++++++++++++++++++++++++++++++
>  1 file changed, 320 insertions(+)
>  create mode 100644 eclass/gstreamer-meson.eclass
> 
> diff --git a/eclass/gstreamer-meson.eclass b/eclass/gstreamer-meson.eclass
> new file mode 100644
> index 00000000000..14a825f76b5
> --- /dev/null
> +++ b/eclass/gstreamer-meson.eclass
> @@ -0,0 +1,320 @@
> +# Copyright 1999-2021 Gentoo Authors
> +# Distributed under the terms of the GNU General Public License v2
> +
> +# @ECLASS: gstreamer-meson.eclass
> +# @MAINTAINER:
> +# gstreamer@gentoo.org
> +# @AUTHOR:

I think the list actually goes the other way around, i.e. you should add
yourself on top.

> +# Michał Górny <mgorny@gentoo.org>
> +# Gilles Dartiguelongue <eva@gentoo.org>
> +# Saleem Abdulrasool <compnerd@gentoo.org>
> +# foser <foser@gentoo.org>
> +# zaheerm <zaheerm@gentoo.org>
> +# Steven Newbury
> +# Haelwenn (lanodan) Monnier <contact@hacktivis.me>
> +# @SUPPORTED_EAPIS: 7
> +# @BLURB: Helps building core & split gstreamer plugins.

No full stop here, it's not a proper sentence.

> +# @DESCRIPTION:
> +# Eclass to make external gst-plugins emergable on a per-plugin basis
> +# and to solve the problem with gst-plugins generating far too much
> +# unneeded dependencies.
> +#
> +# GStreamer consuming applications should depend on the specific plugins
> +# they need as defined in their source code. Usually you can find that
> +# out by grepping the source tree for 'factory_make'. If it uses playbin
> +# plugin, consider adding media-plugins/gst-plugins-meta dependency, but
> +# also list any packages that provide explicitly requested plugins.
> +
> +inherit multilib virtualx meson toolchain-funcs xdg-utils multilib-minimal

I'm pretty sure you can sort them a bit.

> +
> +case "${EAPI:-0}" in
> +	7)
> +		;;
> +	*)
> +		die "EAPI=\"${EAPI}\" is not supported"
> +		;;
> +esac
> +
> +# @ECLASS-VARIABLE: GST_PLUGINS_ENABLED
> +# @DESCRIPTION:
> +# Defines the plugins to be built.
> +# May be set by an ebuild and contain more than one indentifier, space
> +# seperated (only src_configure can handle mutiple plugins at this time).
> +: ${GST_PLUGINS_ENABLED:=${PN/gst-plugins-/}}
> +
> +# @ECLASS-VARIABLE: GST_PLUGINS_DISABLED
> +# @DESCRIPTION:
> +# Defines the plugins to not be built, GST_PLUGINS_ENABLED overrides it.
> +# May be set by an ebuild and contain more than one indentifier, space
> +# seperated (only src_configure can handle mutiple plugins at this time).
> +case "${GST_ORG_MODULE}" in
> +	# copied GST_PLUGINS_DISABLED from media-libs/${GST_ORG_MODULE} then added GST_PLUGINS_ENABLED
> +	gst-plugins-bad)
> +		# removed from list: shm ipcpipeline gl
> +		GST_PLUGINS_DISABLED="aom avtp androidmedia applemedia assrender bluez bs2b bz2 chromaprint closedcaption colormanagement curl curl-ssh2 d3dvideosink d3d11 dash dc1394 decklink directfb directsound dtls dts dvb faac faad fbdev fdkaac flite fluidsynth gme gsm iqa kate kms ladspa libde265 libmms lv2 mediafoundation microdns modplug mpeg2enc mplex msdk musepack neon nvcodec ofa openal openexr openh264 openjpeg openmpt openni2 opensles opus resindvd rsvg rtmp sbc sctp smoothstreaming sndfile soundtouch spandsp srt srtp svthevcenc teletext tinyalsa transcode ttml uvch264 va voaacenc voamrwbenc vulkan wasapi wasapi2 webp webrtc webrtcdsp wildmidi winks winscreencap x265 zbar zxing wpe magicleap v4l2codecs hls opencv"
> +		GST_PLUGINS_DISABLED="${GST_PLUGINS_DISABLED} accurip adpcmdec adpcmenc aiff asfmux audiobuffersplit audiofxbad audiolatency audiomixmatrix audiovisualizers autoconvert bayer camerabin2 coloreffects deb ugutils dvbsubenc dvbsuboverlay dvdspu faceoverlay festival fieldanalysis freeverb frei0r gaudieffects gdp geometrictransform id3tag inter interlace ivfpars e ivtc jp2kdecimator jpegformat librfb midi mpegdemux mpegpsmux mpegtsdemux mpegtsmux mxf netsim onvif pcapparse pnm proxy rawparse removesilence rist rtmp2 rtp sdp segmentclip siren smooth speed subenc switchbin timecode videofilters videoframe_audiolevel videoparsers videosignal vmnc y4m"
> +		;;
> +	gst-plugins-base)
> +		GST_PLUGINS_DISABLED="cdparanoia libvisual opus tremor"
> +		GST_PLUGINS_DISABLED="${GST_PLUGINS_DISABLED} adder app audioconvert audiomixer audiorate audioresample audiotestsrc compositor encoding gio gio-typefinder overlaycomposition pbtypes playback rawparse subparse tcp typefind videoconvert videorate videoscale videotestsrc volume"
> +		;;
> +	gst-plugins-good)
> +		GST_PLUGINS_DISABLED="aalib cairo directsound dv dv1394 flac gdk-pixbuf gtk3 jack jpeg lame libcaca mpg123 oss oss4 osxaudio osxvideo png pulse qt5 shout2 soup speex taglib twolame vpx waveform wavpack  rpicamsrc ximagesrc v4l2"
> +		GST_PLUGINS_DISABLED="${GST_PLUGINS_DISABLED} alpha apetag audiofx audioparsers auparse autodetect avi cutter debugutils deinterlace dtmf effectv equalizer flv flx goom goom2k1 icydemux id3demux imagefreeze interleave isomp4 law level matroska monoscope multifile multipart replaygain rtp rtpmanager rtsp shapewipe smpte spectrum udp videobox videocrop videofilter videomixer wavenc wavparse y4m"
> +		;;
> +	gst-plugins-ugly)
> +		GST_PLUGINS_DISABLED="a52dec amrnb amrwbdec cdio dvdread mpeg2dec sidplay x264"
> +		GST_PLUGINS_DISABLED="${GST_PLUGINS_DISABLED} asfdemux dvdlpcmdec dvdsub realmedia xingmux"
> +		;;
> +esac

Wrap these lists, please.

Are these supposed to be settable by ebuild?  If yes, you need not to
override them.  If no, then look into available eclassdoc tags
and choose one.

> +
> +# @ECLASS-VARIABLE: GST_PLUGINS_BUILD_DIR
> +# @DESCRIPTION:
> +# Actual build directories of the plugins.
> +# Most often the same as the configure switch name.
> +# FIXME: Change into a bash array
> +: ${GST_PLUGINS_BUILD_DIR:=${PN/gst-plugins-/}}
> +
> +# @ECLASS-VARIABLE: GST_TARBALL_SUFFIX
> +# @DESCRIPTION:
> +# Most projects hosted on gstreamer.freedesktop.org mirrors provide
> +# tarballs as tar.bz2 or tar.xz. This eclass defaults to xz. This is
> +# because the gstreamer mirrors are moving to only have xz tarballs for
> +# new releases.
> +: ${GST_TARBALL_SUFFIX:="xz"}
> +
> +# Even though xz-utils are in @system, they must still be added to BDEPEND; see
> +# https://archives.gentoo.org/gentoo-dev/msg_a0d4833eb314d1be5d5802a3b710e0a4.xml
> +if [[ ${GST_TARBALL_SUFFIX} == "xz" ]]; then
> +	BDEPEND="${BDEPEND} app-arch/xz-utils"
> +fi
> +
> +# @ECLASS-VARIABLE: GST_ORG_MODULE
> +# @DESCRIPTION:
> +# Name of the module as hosted on gstreamer.freedesktop.org mirrors.
> +# Leave unset if package name matches module name.
> +: ${GST_ORG_MODULE:=$PN}

Always use ${...} for vars.

> +
> +# @ECLASS-VARIABLE: GST_ORG_PVP
> +# @INTERNAL
> +# @DESCRIPTION:
> +# Major and minor numbers of the version number.
> +: ${GST_ORG_PVP:=$(ver_cut 1-2)}
> +
> +
> +DESCRIPTION="${BUILD_GST_PLUGINS} plugin for gstreamer"
> +HOMEPAGE="https://gstreamer.freedesktop.org/"
> +SRC_URI="https://gstreamer.freedesktop.org/src/${GST_ORG_MODULE}/${GST_ORG_MODULE}-${PV}.tar.${GST_TARBALL_SUFFIX}"
> +
> +LICENSE="GPL-2"
> +case ${GST_ORG_PVP} in
> +	1.*) SLOT="1.0"; GST_MIN_PV="1.2.4-r1" ;;
> +	*) die "Unkown gstreamer release."
> +esac
> +
> +S="${WORKDIR}/${GST_ORG_MODULE}-${PV}"

These days we put S immediately below SRC_URI as they're closely
associated.

> +
> +RDEPEND="
> +	>=dev-libs/glib-2.40.0:2[${MULTILIB_USEDEP}]
> +	>=media-libs/gstreamer-${GST_MIN_PV}:${SLOT}[${MULTILIB_USEDEP}]
> +"
> +BDEPEND="
> +	>=sys-apps/sed-4
> +	virtual/pkgconfig
> +	virtual/perl-JSON-PP
> +"
> +
> +# Export common multilib phases.
> +multilib_src_configure() { gstreamer_multilib_src_configure; }
> +
> +if [[ ${PN} != ${GST_ORG_MODULE} ]]; then
> +	# Do not run test phase for invididual plugin ebuilds.
> +	RESTRICT="test"
> +	RDEPEND="${RDEPEND}
> +		>=media-libs/${GST_ORG_MODULE}-${PV}:${SLOT}[${MULTILIB_USEDEP}]"
> +
> +	# Export multilib phases used for split builds.
> +	multilib_src_compile() { gstreamer_multilib_src_compile; }
> +	multilib_src_install() { gstreamer_multilib_src_install; }
> +	multilib_src_install_all() { gstreamer_multilib_src_install_all; }
> +else
> +	IUSE="nls test"
> +	RESTRICT="!test? ( test )"
> +	BDEPEND="${DEPEND}
> +		nls? ( >=sys-devel/gettext-0.17 )
> +		test? ( media-libs/gstreamer[test] )
> +	"
> +
> +	multilib_src_compile() { eninja; }
> +	multilib_src_test() { gstreamer_multilib_src_test; }
> +	multilib_src_install() { DESTDIR="${D}" eninja install; }

I find it a bit confusing that there are two conditional defaults. 
Maybe it'd make more sense to put the conditions inside
gstreamer_multilib*?

> +fi
> +
> +DEPEND="${DEPEND} ${RDEPEND}"
> +
> +# @FUNCTION: gstreamer_environment_reset
> +# @INTERNAL
> +# @DESCRIPTION:
> +# Clean up environment for clean builds.
> +# >=dev-lang/orc-0.4.23 rely on environment variables to find a place to
> +# allocate files to mmap.
> +gstreamer_environment_reset() {
> +	xdg_environment_reset
> +}

I don't really understand why you need to wrap xdg_environment_reset
in another function.

> +
> +# @FUNCTION: gstreamer_get_plugin_dir
> +# @USAGE: gstreamer_get_plugin_dir [<build_dir>]
> +# @INTERNAL
> +# @DESCRIPTION:
> +# Finds plugin build directory and output it.
> +# Defaults to ${GST_PLUGINS_BUILD_DIR} if argument is not provided
> +gstreamer_get_plugin_dir() {
> +	local build_dir=${1:-${GST_PLUGINS_BUILD_DIR}}
> +
> +	if [[ ! -d ${S}/ext/${build_dir} ]]; then
> +		if [[ ! -d ${S}/sys/${build_dir} ]]; then
> +			ewarn "No such plugin directory"
> +			die
> +		fi
> +		einfo "Got system plugin in ${build_dir}..." >&2
> +		echo sys/${build_dir}
> +	else
> +		einfo "Got external plugin in ${build_dir}..." >&2
> +		echo ext/${build_dir}
> +	fi
> +}
> +
> +# @FUNCTION: gstreamer_multilib_src_configure
> +# @DESCRIPTION:
> +# Handles logic common to configuring gstreamer plugins
> +gstreamer_multilib_src_configure() {
> +	local plugin gst_conf=( ) EMESON_SOURCE=${EMESON_SOURCE:-${S}}
> +
> +	gstreamer_environment_reset
> +
> +	# app-editor/vis regex for meson_options.txt: :x/option\('([^']*)'.*/ c/\1/
> +	for plugin in ${GST_PLUGINS_DISABLED} ; do
> +		gst_conf+=( -D${plugin}=disabled )
> +	done
> +
> +	for plugin in ${GST_PLUGINS_ENABLED} ; do
> +		gst_conf+=( -D${plugin}=enabled )
> +	done
> +
> +	if grep -q "option('orc'" "${EMESON_SOURCE}"/meson_options.txt ; then

Hmm, doesn't meson provide a cleaner way than grepping the sources?

> +		if in_iuse orc ; then
> +			gst_conf+=( -Dorc=$(usex orc enabled disabled) )
> +		else
> +			gst_conf+=( -Dorc=disabled )
> +			eqawarn "QA: IUSE=orc is missing while plugin supports it"
> +		fi
> +	fi
> +
> +	if grep -q "option(\'maintainer-mode\'" "${EMESON_SOURCE}"/meson_options.txt ; then
> +		gst_conf+=( -Dmaintainer-mode=disabled )
> +	fi
> +
> +	if grep -q "option(\'schemas-compile\'" "${EMESON_SOURCE}"/meson_options.txt ; then
> +		gst_conf+=( -Dschemas-compile=disabled )
> +	fi
> +
> +	if [[ ${PN} == ${GST_ORG_MODULE} ]]; then
> +		gst_conf+=(
> +			$(meson_feature nls)
> +			$(meson_feature test tests)
> +		)
> +	fi
> +
> +	einfo "Configuring to build ${GST_PLUGINS_ENABLED} plugin(s) ..."
> +	gst_conf+=(
> +		-Dexamples=disabled
> +		-Dpackage-name="Gentoo GStreamer ebuild"
> +		-Dpackage-origin="https://www.gentoo.org"
> +		-Dgst_debug=false
> +		"${@}"
> +	)
> +	meson_src_configure "${gst_conf[@]}"
> +}
> +
> +
> +# @FUNCTION: _gstreamer_get_target_filename
> +# @INTERNAL
> +# @DESCRIPTION:
> +# Looks for first argument being present as a substring in install targets
> +# Got ported from python to perl for greater language-stability
> +_gstreamer_get_target_filename() {
> +	cat >"${WORKDIR}/_gstreamer_get_target_filename.pl" <<"EOF"
> +#!/usr/bin/env perl
> +use strict;
> +use utf8;
> +use JSON::PP;
> +
> +open(my $targets_file, '<:encoding(UTF-8)', 'meson-info/intro-targets.json') || die $!;
> +my $data = decode_json <$targets_file>;
> +close($targets_file) || die $!;
> +
> +if(!$ARGV[0]) {
> +	die "Requires a target as argument";
> +}
> +
> +foreach my $target (@{$data}) {
> +	if($target->{'installed'}
> +		and (index($target->{'filename'}[0], $ARGV[0]) != -1)
> +	) {
> +		printf "%s:%s\n", $target->{'filename'}[0], $target->{'install_filename'}[0];
> +	}
> +}
> +EOF
> +
> +	chmod +x "${WORKDIR}/_gstreamer_get_target_filename.pl" || die
> +
> +	perl "${WORKDIR}/_gstreamer_get_target_filename.pl" $@ \
> +		|| die "Failed to extract target filenames from meson-info"
> +}
> +
> +# @FUNCTION: gstreamer_multilib_src_compile
> +# @DESCRIPTION:
> +# Compiles requested gstreamer plugin.
> +gstreamer_multilib_src_compile() {
> +	local plugin_dir plugin
> +
> +	for plugin_dir in ${GST_PLUGINS_BUILD_DIR} ; do
> +		plugin=$(_gstreamer_get_target_filename $(gstreamer_get_plugin_dir ${plugin_dir}))
> +		plugin_path="${plugin%%:*}"
> +		eninja "${plugin_path/"${BUILD_DIR}/"}"
> +	done
> +}
> +
> +# @FUNCTION: gstreamer_multilib_src_test
> +# @DESCRIPTION:
> +# Tests the gstreamer plugin (non-split)
> +gstreamer_multilib_src_test() {
> +	GST_GL_WINDOW=x11 virtx eninja test;

Stray semicolon.

> +}
> +
> +# @FUNCTION: gstreamer_multilib_src_install
> +# @DESCRIPTION:
> +# Installs requested gstreamer plugin.
> +gstreamer_multilib_src_install() {
> +	local plugin_dir plugin
> +
> +	for plugin_dir in ${GST_PLUGINS_BUILD_DIR} ; do
> +		for plugin in $(_gstreamer_get_target_filename $(gstreamer_get_plugin_dir ${plugin_dir})); do
> +			local install_filename="${plugin##*:}"
> +			insinto "${install_filename%/*}"
> +			doins "${plugin%%:*}"
> +		done
> +	done
> +}
> +
> +# @FUNCTION: gstreamer_multilib_src_install_all
> +# @DESCRIPTION:
> +# Installs documentation for requested gstreamer plugin
> +gstreamer_multilib_src_install_all() {
> +	local plugin_dir
> +
> +	for plugin_dir in ${GST_PLUGINS_BUILD_DIR} ; do
> +		local dir=$(gstreamer_get_plugin_dir ${plugin_dir})
> +		[[ -e ${dir}/README ]] && dodoc "${dir}"/README
> +	done
> +}

-- 
Best regards,
Michał Górny




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-03-23 13:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-17  1:49 [gentoo-dev] [PATCH] gstreamer-meson.eclass: New eclass required for gstreamer-1.18.0+ Haelwenn (lanodan) Monnier
2021-03-17  1:57 ` Sam James
2021-03-17  9:15   ` Mart Raudsepp
2021-03-17  9:29     ` Haelwenn (lanodan) Monnier
2021-03-17 14:24       ` Mart Raudsepp
2021-03-17 16:13 ` Alec Warner
2021-03-23 12:44 ` [gentoo-dev] [PATCH v2] " Haelwenn (lanodan) Monnier
2021-03-23 13:05   ` Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox