1 |
Gstreamer switched to meson in 1.16.0 and removed autotools support in 1.18.0, |
2 |
this eclass is an update of gstreamer.eclass. |
3 |
|
4 |
One significant change between autotools and meson is that in the latter we |
5 |
don't have easily extractable semantics in the buildsystem to get a list |
6 |
of plugins with extraneous dependencies that we currently split in other |
7 |
packages. |
8 |
Hence the rather ugly but currently required GST_PLUGINS_DISABLED block. |
9 |
|
10 |
Fixes: https://bugs.gentoo.org/690468 |
11 |
|
12 |
Signed-off-by: Haelwenn (lanodan) Monnier <contact@×××××××××.me> |
13 |
--- |
14 |
eclass/gstreamer-meson.eclass | 293 ++++++++++++++++++++++++++++++++++ |
15 |
1 file changed, 293 insertions(+) |
16 |
create mode 100644 eclass/gstreamer-meson.eclass |
17 |
|
18 |
diff --git a/eclass/gstreamer-meson.eclass b/eclass/gstreamer-meson.eclass |
19 |
new file mode 100644 |
20 |
index 00000000000..263deeb08aa |
21 |
--- /dev/null |
22 |
+++ b/eclass/gstreamer-meson.eclass |
23 |
@@ -0,0 +1,293 @@ |
24 |
+# Copyright 1999-2021 Gentoo Authors |
25 |
+# Distributed under the terms of the GNU General Public License v2 |
26 |
+ |
27 |
+# @ECLASS: gstreamer-meson.eclass |
28 |
+# @MAINTAINER: |
29 |
+# gstreamer@g.o |
30 |
+# @AUTHOR: |
31 |
+# Michał Górny <mgorny@g.o> |
32 |
+# Gilles Dartiguelongue <eva@g.o> |
33 |
+# Saleem Abdulrasool <compnerd@g.o> |
34 |
+# foser <foser@g.o> |
35 |
+# zaheerm <zaheerm@g.o> |
36 |
+# Steven Newbury |
37 |
+# Haelwenn (lanodan) Monnier <contact@×××××××××.me> |
38 |
+# @SUPPORTED_EAPIS: 5 6 |
39 |
+# @BLURB: Helps building core & split gstreamer plugins. |
40 |
+# @DESCRIPTION: |
41 |
+# Eclass to make external gst-plugins emergable on a per-plugin basis |
42 |
+# and to solve the problem with gst-plugins generating far too much |
43 |
+# unneeded dependencies. |
44 |
+# |
45 |
+# GStreamer consuming applications should depend on the specific plugins |
46 |
+# they need as defined in their source code. Usually you can find that |
47 |
+# out by grepping the source tree for 'factory_make'. If it uses playbin |
48 |
+# plugin, consider adding media-plugins/gst-plugins-meta dependency, but |
49 |
+# also list any packages that provide explicitly requested plugins. |
50 |
+ |
51 |
+inherit eutils multilib meson multilib-minimal toolchain-funcs versionator xdg-utils |
52 |
+ |
53 |
+case "${EAPI:-0}" in |
54 |
+ 5|6) |
55 |
+ ;; |
56 |
+ 0|1|2|3|4) |
57 |
+ die "EAPI=\"${EAPI:-0}\" is not supported anymore" |
58 |
+ ;; |
59 |
+ *) |
60 |
+ die "EAPI=\"${EAPI}\" is not supported yet" |
61 |
+ ;; |
62 |
+esac |
63 |
+ |
64 |
+# @ECLASS-VARIABLE: GST_PLUGINS_ENABLED |
65 |
+# @DESCRIPTION: |
66 |
+# Defines the plugins to be built. |
67 |
+# May be set by an ebuild and contain more than one indentifier, space |
68 |
+# seperated (only src_configure can handle mutiple plugins at this time). |
69 |
+: ${GST_PLUGINS_ENABLED:=${PN/gst-plugins-/}} |
70 |
+ |
71 |
+# @ECLASS-VARIABLE: GST_PLUGINS_DISABLED |
72 |
+# @DESCRIPTION: |
73 |
+# Defines the plugins to not be built, GST_PLUGINS_ENABLED overrides it. |
74 |
+# May be set by an ebuild and contain more than one indentifier, space |
75 |
+# seperated (only src_configure can handle mutiple plugins at this time). |
76 |
+case "${GST_ORG_MODULE}" in |
77 |
+ # copied GST_PLUGINS_DISABLED from media-libs/${GST_ORG_MODULE} then added GST_PLUGINS_ENABLED |
78 |
+ gst-plugins-bad) |
79 |
+ # removed from list: shm ipcpipeline gl |
80 |
+ 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" |
81 |
+ 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" |
82 |
+ ;; |
83 |
+ gst-plugins-base) |
84 |
+ GST_PLUGINS_DISABLED="cdparanoia libvisual opus tremor" |
85 |
+ 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" |
86 |
+ ;; |
87 |
+ gst-plugins-good) |
88 |
+ 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" |
89 |
+ 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" |
90 |
+ ;; |
91 |
+ gst-plugins-ugly) |
92 |
+ GST_PLUGINS_DISABLED="a52dec amrnb amrwbdec cdio dvdread mpeg2dec sidplay x264" |
93 |
+ GST_PLUGINS_DISABLED="${GST_PLUGINS_DISABLED} asfdemux dvdlpcmdec dvdsub realmedia xingmux" |
94 |
+ ;; |
95 |
+esac |
96 |
+ |
97 |
+# @ECLASS-VARIABLE: GST_PLUGINS_BUILD_DIR |
98 |
+# @DESCRIPTION: |
99 |
+# Actual build directory of the plugin. |
100 |
+# Most often the same as the configure switch name. |
101 |
+: ${GST_PLUGINS_BUILD_DIR:=${PN/gst-plugins-/}} |
102 |
+ |
103 |
+# @ECLASS-VARIABLE: GST_TARBALL_SUFFIX |
104 |
+# @DESCRIPTION: |
105 |
+# Most projects hosted on gstreamer.freedesktop.org mirrors provide |
106 |
+# tarballs as tar.bz2 or tar.xz. This eclass defaults to xz. This is |
107 |
+# because the gstreamer mirrors are moving to only have xz tarballs for |
108 |
+# new releases. |
109 |
+: ${GST_TARBALL_SUFFIX:="xz"} |
110 |
+ |
111 |
+# Even though xz-utils are in @system, they must still be added to DEPEND; see |
112 |
+# https://archives.gentoo.org/gentoo-dev/msg_a0d4833eb314d1be5d5802a3b710e0a4.xml |
113 |
+if [[ ${GST_TARBALL_SUFFIX} == "xz" ]]; then |
114 |
+ DEPEND="${DEPEND} app-arch/xz-utils" |
115 |
+fi |
116 |
+ |
117 |
+# @ECLASS-VARIABLE: GST_ORG_MODULE |
118 |
+# @DESCRIPTION: |
119 |
+# Name of the module as hosted on gstreamer.freedesktop.org mirrors. |
120 |
+# Leave unset if package name matches module name. |
121 |
+: ${GST_ORG_MODULE:=$PN} |
122 |
+ |
123 |
+# @ECLASS-VARIABLE: GST_ORG_PVP |
124 |
+# @INTERNAL |
125 |
+# @DESCRIPTION: |
126 |
+# Major and minor numbers of the version number. |
127 |
+: ${GST_ORG_PVP:=$(get_version_component_range 1-2)} |
128 |
+ |
129 |
+ |
130 |
+DESCRIPTION="${BUILD_GST_PLUGINS} plugin for gstreamer" |
131 |
+HOMEPAGE="https://gstreamer.freedesktop.org/" |
132 |
+SRC_URI="https://gstreamer.freedesktop.org/src/${GST_ORG_MODULE}/${GST_ORG_MODULE}-${PV}.tar.${GST_TARBALL_SUFFIX}" |
133 |
+ |
134 |
+LICENSE="GPL-2" |
135 |
+case ${GST_ORG_PVP} in |
136 |
+ 1.*) SLOT="1.0"; GST_MIN_PV="1.2.4-r1" ;; |
137 |
+ *) die "Unkown gstreamer release." |
138 |
+esac |
139 |
+ |
140 |
+S="${WORKDIR}/${GST_ORG_MODULE}-${PV}" |
141 |
+ |
142 |
+RDEPEND=" |
143 |
+ >=dev-libs/glib-2.38.2-r1:2[${MULTILIB_USEDEP}] |
144 |
+ >=media-libs/gstreamer-${GST_MIN_PV}:${SLOT}[${MULTILIB_USEDEP}] |
145 |
+" |
146 |
+DEPEND=" |
147 |
+ >=sys-apps/sed-4 |
148 |
+ >=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}] |
149 |
+" |
150 |
+ |
151 |
+# Export common multilib phases. |
152 |
+multilib_src_configure() { gstreamer_multilib_src_configure; } |
153 |
+ |
154 |
+if [[ ${PN} != ${GST_ORG_MODULE} ]]; then |
155 |
+ # Do not run test phase for invididual plugin ebuilds. |
156 |
+ RESTRICT="test" |
157 |
+ RDEPEND="${RDEPEND} |
158 |
+ >=media-libs/${GST_ORG_MODULE}-${PV}:${SLOT}[${MULTILIB_USEDEP}]" |
159 |
+ |
160 |
+ # Export multilib phases used for split builds. |
161 |
+ multilib_src_compile() { gstreamer_multilib_src_compile; } |
162 |
+ multilib_src_install() { gstreamer_multilib_src_install; } |
163 |
+ multilib_src_install_all() { gstreamer_multilib_src_install_all; } |
164 |
+else |
165 |
+ IUSE="nls" |
166 |
+ DEPEND="${DEPEND} nls? ( >=sys-devel/gettext-0.17 )" |
167 |
+ |
168 |
+ multilib_src_compile() { eninja; } |
169 |
+ multilib_src_install() { DESTDIR="${D}" eninja install; } |
170 |
+fi |
171 |
+ |
172 |
+DEPEND="${DEPEND} ${RDEPEND}" |
173 |
+ |
174 |
+# @FUNCTION: gstreamer_environment_reset |
175 |
+# @INTERNAL |
176 |
+# @DESCRIPTION: |
177 |
+# Clean up environment for clean builds. |
178 |
+# >=dev-lang/orc-0.4.23 rely on environment variables to find a place to |
179 |
+# allocate files to mmap. |
180 |
+gstreamer_environment_reset() { |
181 |
+ xdg_environment_reset |
182 |
+} |
183 |
+ |
184 |
+# @FUNCTION: gstreamer_get_plugin_dir |
185 |
+# @USAGE: gstreamer_get_plugin_dir [<build_dir>] |
186 |
+# @INTERNAL |
187 |
+# @DESCRIPTION: |
188 |
+# Finds plugin build directory and output it. |
189 |
+# Defaults to ${GST_PLUGINS_BUILD_DIR} if argument is not provided |
190 |
+gstreamer_get_plugin_dir() { |
191 |
+ local build_dir=${1:-${GST_PLUGINS_BUILD_DIR}} |
192 |
+ |
193 |
+ if [[ ! -d ${S}/ext/${build_dir} ]]; then |
194 |
+ if [[ ! -d ${S}/sys/${build_dir} ]]; then |
195 |
+ ewarn "No such plugin directory" |
196 |
+ die |
197 |
+ fi |
198 |
+ einfo "Building system plugin in ${build_dir}..." >&2 |
199 |
+ echo sys/${build_dir} |
200 |
+ else |
201 |
+ einfo "Building external plugin in ${build_dir}..." >&2 |
202 |
+ echo ext/${build_dir} |
203 |
+ fi |
204 |
+} |
205 |
+ |
206 |
+# @FUNCTION: gstreamer_multilib_src_configure |
207 |
+# @DESCRIPTION: |
208 |
+# Handles logic common to configuring gstreamer plugins |
209 |
+gstreamer_multilib_src_configure() { |
210 |
+ local plugin emesonargs=() EMESON_SOURCE=${EMESON_SOURCE:-${S}} |
211 |
+ |
212 |
+ gstreamer_environment_reset |
213 |
+ |
214 |
+ # app-editor/vis regex for meson_options.txt: :x/option\('([^']*)'.*/ c/\1/ |
215 |
+ for plugin in ${GST_PLUGINS_DISABLED} ; do |
216 |
+ emesonargs+=( -D${plugin}=disabled ) |
217 |
+ done |
218 |
+ |
219 |
+ for plugin in ${GST_PLUGINS_ENABLED} ; do |
220 |
+ emesonargs+=( -D${plugin}=enabled ) |
221 |
+ done |
222 |
+ |
223 |
+ if grep -q "option(\'orc\'" "${EMESON_SOURCE}"/meson_options.txt ; then |
224 |
+ if in_iuse orc ; then |
225 |
+ emesonargs+=( -Dorc=$(usex orc enabled disabled) ) |
226 |
+ else |
227 |
+ emesonargs+=( -Dorc=disabled ) |
228 |
+ fi |
229 |
+ fi |
230 |
+ |
231 |
+ if grep -q "option(\'maintainer-mode\'" "${EMESON_SOURCE}"/meson_options.txt ; then |
232 |
+ gst_conf+=( -Dmaintainer-mode=disabled ) |
233 |
+ fi |
234 |
+ |
235 |
+ if grep -q "option(\'schemas-compile\'" "${EMESON_SOURCE}"/meson_options.txt ; then |
236 |
+ gst_conf+=( -Dschemas-compile=disabled ) |
237 |
+ fi |
238 |
+ |
239 |
+ if [[ ${PN} == ${GST_ORG_MODULE} ]]; then |
240 |
+ emesonargs+=( $(meson_feature nls) ) |
241 |
+ fi |
242 |
+ |
243 |
+ einfo "Configuring to build ${GST_PLUGINS_ENABLED} plugin(s) ..." |
244 |
+ emesonargs+=( |
245 |
+ -Dexamples=disabled |
246 |
+ -Dpackage-name="Gentoo GStreamer ebuild" |
247 |
+ -Dpackage-origin="https://www.gentoo.org" |
248 |
+ "${@}" |
249 |
+ ) |
250 |
+ meson_src_configure |
251 |
+} |
252 |
+ |
253 |
+read -d '' __MESON_EXTRACT_TARGET_FILENAME <<"EOF" |
254 |
+import json |
255 |
+import sys |
256 |
+ |
257 |
+with open("meson-info/intro-targets.json", "r") as targets_file: |
258 |
+ data = json.load(targets_file) |
259 |
+ |
260 |
+for i in range(len(data)): |
261 |
+ target = data[i] |
262 |
+ if target['installed']: |
263 |
+ if sys.argv[1] in target['filename'][0]: |
264 |
+ print(target['filename'][0] + ':' + target['install_filename'][0]) |
265 |
+EOF |
266 |
+ |
267 |
+# @FUNCTION: _gstreamer_get_target_filename |
268 |
+# @INTERNAL |
269 |
+# @DESCRIPTION: |
270 |
+# Extracts build and target filenames from meson-data for given submatch |
271 |
+_gstreamer_get_target_filename() { |
272 |
+ python -c "${__MESON_EXTRACT_TARGET_FILENAME}" "$@" |
273 |
+} |
274 |
+ |
275 |
+# @FUNCTION: gstreamer_multilib_src_compile |
276 |
+# @DESCRIPTION: |
277 |
+# Compiles requested gstreamer plugin. |
278 |
+gstreamer_multilib_src_compile() { |
279 |
+ local plugin_dir plugin |
280 |
+ |
281 |
+ for plugin_dir in ${GST_PLUGINS_BUILD_DIR} ; do |
282 |
+ plugin=$(_gstreamer_get_target_filename $(gstreamer_get_plugin_dir ${plugin_dir})) |
283 |
+ plugin_path="${plugin%%:*}" |
284 |
+ eninja "${plugin_path/"${BUILD_DIR}/"}" |
285 |
+ done |
286 |
+} |
287 |
+ |
288 |
+# @FUNCTION: gstreamer_multilib_src_install |
289 |
+# @DESCRIPTION: |
290 |
+# Installs requested gstreamer plugin. |
291 |
+gstreamer_multilib_src_install() { |
292 |
+ local plugin_dir plugin |
293 |
+ |
294 |
+ for plugin_dir in ${GST_PLUGINS_BUILD_DIR} ; do |
295 |
+ for plugin in $(_gstreamer_get_target_filename $(gstreamer_get_plugin_dir ${plugin_dir})); do |
296 |
+ local install_filename="${plugin##*:}" |
297 |
+ insinto "${install_filename%/*}" |
298 |
+ doins "${plugin%%:*}" |
299 |
+ done |
300 |
+ done |
301 |
+} |
302 |
+ |
303 |
+# @FUNCTION: gstreamer_multilib_src_install_all |
304 |
+# @DESCRIPTION: |
305 |
+# Installs documentation for requested gstreamer plugin, and removes .la |
306 |
+# files. |
307 |
+gstreamer_multilib_src_install_all() { |
308 |
+ local plugin_dir |
309 |
+ |
310 |
+ for plugin_dir in ${GST_PLUGINS_BUILD_DIR} ; do |
311 |
+ local dir=$(gstreamer_get_plugin_dir ${plugin_dir}) |
312 |
+ [[ -e ${dir}/README ]] && dodoc "${dir}"/README |
313 |
+ done |
314 |
+ |
315 |
+ prune_libtool_files --modules |
316 |
+} |
317 |
-- |
318 |
2.26.2 |