Gentoo Archives: gentoo-commits

From: Lars Wendler <polynomial-c@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: games-emulation/mgba/, games-emulation/mgba/files/
Date: Tue, 01 Mar 2022 08:02:11
Message-Id: 1646121719.219f791f4599cf5ca3668cbbd9f5c95b20dac98c.polynomial-c@gentoo
1 commit: 219f791f4599cf5ca3668cbbd9f5c95b20dac98c
2 Author: Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
3 AuthorDate: Tue Mar 1 08:01:28 2022 +0000
4 Commit: Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
5 CommitDate: Tue Mar 1 08:01:59 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=219f791f
7
8 games-emulation/mgba: Revbump to fix compilation against ffmpeg-5
9
10 Closes: https://bugs.gentoo.org/834374
11 Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>
12
13 .../mgba/files/mgba-0.9.3-ffmpeg5.patch | 117 ++++++++++++++++++
14 games-emulation/mgba/mgba-0.9.3-r1.ebuild | 132 +++++++++++++++++++++
15 2 files changed, 249 insertions(+)
16
17 diff --git a/games-emulation/mgba/files/mgba-0.9.3-ffmpeg5.patch b/games-emulation/mgba/files/mgba-0.9.3-ffmpeg5.patch
18 new file mode 100644
19 index 000000000000..cf4f6f56a2d4
20 --- /dev/null
21 +++ b/games-emulation/mgba/files/mgba-0.9.3-ffmpeg5.patch
22 @@ -0,0 +1,117 @@
23 +From cdc753516798882a805db1d2042dbce8313382bf Mon Sep 17 00:00:00 2001
24 +From: Ryan Tandy <ryan@××××××.ca>
25 +Date: Thu, 3 Feb 2022 19:02:52 -0800
26 +Subject: [PATCH] FFmpeg: Support FFmpeg 5.0
27 +
28 +---
29 + src/feature/ffmpeg/ffmpeg-decoder.c | 3 ++-
30 + src/feature/ffmpeg/ffmpeg-encoder.c | 25 ++++++++++++++-----------
31 + 2 files changed, 16 insertions(+), 12 deletions(-)
32 +
33 +diff --git a/src/feature/ffmpeg/ffmpeg-decoder.c b/src/feature/ffmpeg/ffmpeg-decoder.c
34 +index c3bb6d1c5c..daa47fbf2c 100644
35 +--- a/src/feature/ffmpeg/ffmpeg-decoder.c
36 ++++ b/src/feature/ffmpeg/ffmpeg-decoder.c
37 +@@ -5,6 +5,7 @@
38 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
39 + #include "ffmpeg-decoder.h"
40 +
41 ++#include <libavcodec/avcodec.h>
42 + #include <libswscale/swscale.h>
43 +
44 + void FFmpegDecoderInit(struct FFmpegDecoder* decoder) {
45 +@@ -38,7 +39,7 @@ bool FFmpegDecoderOpen(struct FFmpegDecoder* decoder, const char* infile) {
46 + #else
47 + enum AVMediaType type = decoder->context->streams[i]->codec->codec_type;
48 + #endif
49 +- struct AVCodec* codec;
50 ++ const struct AVCodec* codec;
51 + struct AVCodecContext* context = NULL;
52 + if (type == AVMEDIA_TYPE_VIDEO && decoder->videoStream < 0) {
53 + decoder->video = avcodec_alloc_context3(NULL);
54 +diff --git a/src/feature/ffmpeg/ffmpeg-encoder.c b/src/feature/ffmpeg/ffmpeg-encoder.c
55 +index ad76ca57b2..be6bd3af5e 100644
56 +--- a/src/feature/ffmpeg/ffmpeg-encoder.c
57 ++++ b/src/feature/ffmpeg/ffmpeg-encoder.c
58 +@@ -12,6 +12,9 @@
59 +
60 + #include <libavcodec/version.h>
61 + #include <libavcodec/avcodec.h>
62 ++#if LIBAVCODEC_VERSION_MAJOR >= 58
63 ++#include <libavcodec/bsf.h>
64 ++#endif
65 +
66 + #include <libavfilter/buffersink.h>
67 + #include <libavfilter/buffersrc.h>
68 +@@ -121,7 +124,7 @@ bool FFmpegEncoderSetAudio(struct FFmpegEncoder* encoder, const char* acodec, un
69 + return true;
70 + }
71 +
72 +- AVCodec* codec = avcodec_find_encoder_by_name(acodec);
73 ++ const AVCodec* codec = avcodec_find_encoder_by_name(acodec);
74 + if (!codec) {
75 + return false;
76 + }
77 +@@ -193,7 +196,7 @@ bool FFmpegEncoderSetVideo(struct FFmpegEncoder* encoder, const char* vcodec, in
78 + return true;
79 + }
80 +
81 +- AVCodec* codec = avcodec_find_encoder_by_name(vcodec);
82 ++ const AVCodec* codec = avcodec_find_encoder_by_name(vcodec);
83 + if (!codec) {
84 + return false;
85 + }
86 +@@ -213,7 +216,7 @@ bool FFmpegEncoderSetVideo(struct FFmpegEncoder* encoder, const char* vcodec, in
87 + if (encoder->pixFormat == AV_PIX_FMT_NONE) {
88 + return false;
89 + }
90 +- if (vbr < 0 && !av_opt_find(&codec->priv_class, "crf", NULL, 0, 0)) {
91 ++ if (vbr < 0 && !av_opt_find((void*) &codec->priv_class, "crf", NULL, 0, 0)) {
92 + return false;
93 + }
94 + encoder->videoCodec = vcodec;
95 +@@ -223,7 +226,7 @@ bool FFmpegEncoderSetVideo(struct FFmpegEncoder* encoder, const char* vcodec, in
96 + }
97 +
98 + bool FFmpegEncoderSetContainer(struct FFmpegEncoder* encoder, const char* container) {
99 +- AVOutputFormat* oformat = av_guess_format(container, 0, 0);
100 ++ const AVOutputFormat* oformat = av_guess_format(container, 0, 0);
101 + if (!oformat) {
102 + return false;
103 + }
104 +@@ -241,9 +244,9 @@ void FFmpegEncoderSetLooping(struct FFmpegEncoder* encoder, bool loop) {
105 + }
106 +
107 + bool FFmpegEncoderVerifyContainer(struct FFmpegEncoder* encoder) {
108 +- AVOutputFormat* oformat = av_guess_format(encoder->containerFormat, 0, 0);
109 +- AVCodec* acodec = avcodec_find_encoder_by_name(encoder->audioCodec);
110 +- AVCodec* vcodec = avcodec_find_encoder_by_name(encoder->videoCodec);
111 ++ const AVOutputFormat* oformat = av_guess_format(encoder->containerFormat, 0, 0);
112 ++ const AVCodec* acodec = avcodec_find_encoder_by_name(encoder->audioCodec);
113 ++ const AVCodec* vcodec = avcodec_find_encoder_by_name(encoder->videoCodec);
114 + if ((encoder->audioCodec && !acodec) || (encoder->videoCodec && !vcodec) || !oformat || (!acodec && !vcodec)) {
115 + return false;
116 + }
117 +@@ -257,8 +260,8 @@ bool FFmpegEncoderVerifyContainer(struct FFmpegEncoder* encoder) {
118 + }
119 +
120 + bool FFmpegEncoderOpen(struct FFmpegEncoder* encoder, const char* outfile) {
121 +- AVCodec* acodec = avcodec_find_encoder_by_name(encoder->audioCodec);
122 +- AVCodec* vcodec = avcodec_find_encoder_by_name(encoder->videoCodec);
123 ++ const AVCodec* acodec = avcodec_find_encoder_by_name(encoder->audioCodec);
124 ++ const AVCodec* vcodec = avcodec_find_encoder_by_name(encoder->videoCodec);
125 + if ((encoder->audioCodec && !acodec) || (encoder->videoCodec && !vcodec) || !FFmpegEncoderVerifyContainer(encoder)) {
126 + return false;
127 + }
128 +@@ -272,9 +275,9 @@ bool FFmpegEncoderOpen(struct FFmpegEncoder* encoder, const char* outfile) {
129 + encoder->currentVideoFrame = 0;
130 + encoder->skipResidue = 0;
131 +
132 +- AVOutputFormat* oformat = av_guess_format(encoder->containerFormat, 0, 0);
133 ++ const AVOutputFormat* oformat = av_guess_format(encoder->containerFormat, 0, 0);
134 + #ifndef USE_LIBAV
135 +- avformat_alloc_output_context2(&encoder->context, oformat, 0, outfile);
136 ++ avformat_alloc_output_context2(&encoder->context, (AVOutputFormat*) oformat, 0, outfile);
137 + #else
138 + encoder->context = avformat_alloc_context();
139 + strncpy(encoder->context->filename, outfile, sizeof(encoder->context->filename) - 1);
140
141 diff --git a/games-emulation/mgba/mgba-0.9.3-r1.ebuild b/games-emulation/mgba/mgba-0.9.3-r1.ebuild
142 new file mode 100644
143 index 000000000000..f2e1ddb6dd3b
144 --- /dev/null
145 +++ b/games-emulation/mgba/mgba-0.9.3-r1.ebuild
146 @@ -0,0 +1,132 @@
147 +# Copyright 1999-2022 Gentoo Authors
148 +# Distributed under the terms of the GNU General Public License v2
149 +
150 +EAPI=8
151 +
152 +inherit cmake desktop xdg
153 +
154 +DESCRIPTION="Game Boy Advance emulator written in C"
155 +HOMEPAGE="https://mgba.io"
156 +if [[ "${PV}" == 9999 ]] ; then
157 + inherit git-r3
158 + EGIT_REPO_URI="https://github.com/mgba-emu/mgba.git"
159 +else
160 + MY_PV="${PV/_beta/-b}"
161 + SRC_URI="https://github.com/${PN}-emu/${PN}/archive/${MY_PV}.tar.gz -> ${P}.tar.gz"
162 + [[ "${PV}" == *_beta* ]] || \
163 + KEYWORDS="~amd64 ~arm64 ~x86"
164 + S="${WORKDIR}/${PN}-${MY_PV}"
165 +fi
166 +LICENSE="MPL-2.0"
167 +SLOT="0"
168 +IUSE="debug discord elf ffmpeg gles2 gles3 opengl qt5 +sdl sqlite"
169 +REQUIRED_USE="|| ( qt5 sdl )
170 + qt5? ( opengl )"
171 +
172 +RDEPEND="
173 + media-libs/libpng:0=
174 + sys-libs/zlib[minizip]
175 + debug? ( dev-libs/libedit )
176 + elf? ( dev-libs/elfutils )
177 + ffmpeg? ( media-video/ffmpeg:= )
178 + opengl? ( media-libs/libglvnd )
179 + qt5? (
180 + dev-qt/qtcore:5
181 + dev-qt/qtgui:5
182 + dev-qt/qtmultimedia:5
183 + dev-qt/qtwidgets:5
184 + opengl? ( dev-qt/qtopengl:5 )
185 + )
186 + sdl? ( media-libs/libsdl2[X,sound,joystick,video,opengl?] )
187 + sqlite? ( dev-db/sqlite:3 )
188 +"
189 +DEPEND="${RDEPEND}
190 + gles2? ( media-libs/libglvnd )
191 + gles3? ( media-libs/libglvnd )
192 +"
193 +
194 +PATCHES=(
195 + "${FILESDIR}/${P}-ffmpeg5.patch" #834374
196 +)
197 +
198 +src_prepare() {
199 + xdg_environment_reset
200 + cmake_src_prepare
201 +
202 + # Get rid of any bundled stuff we don't want
203 + local pkg
204 + for pkg in libpng lzma sqlite3 zlib ; do
205 + rm -r src/third-party/${pkg} || die
206 + done
207 +}
208 +
209 +src_configure() {
210 + local mycmakeargs=(
211 + -DCMAKE_SKIP_RPATH=ON
212 + -DBUILD_GL="$(usex opengl)"
213 + -DBUILD_GLES2="$(usex gles2)"
214 + -DBUILD_GLES3="$(usex gles3)"
215 + -DBUILD_PYTHON=OFF
216 + -DBUILD_QT="$(usex qt5)"
217 + -DBUILD_SDL="$(usex sdl)"
218 + -DBUILD_SHARED=ON
219 + # test suite fails to build (>=0.6.0)
220 + -DBUILD_SUITE=OFF
221 + -DBUILD_TEST=OFF
222 + -DM_CORE_GB=ON
223 + -DM_CORE_GBA=ON
224 + -DUSE_DEBUGGERS="$(usex debug)"
225 + -DUSE_DISCORD_RPC="$(usex discord)"
226 + -DUSE_EDITLINE="$(usex debug)"
227 + -DUSE_ELF="$(usex elf)"
228 + -DUSE_EPOXY=OFF
229 + -DUSE_FFMPEG="$(usex ffmpeg)"
230 + -DUSE_GDB_STUB="$(usex debug)"
231 + -DUSE_LIBZIP=OFF
232 + -DUSE_LZMA=OFF
233 + -DUSE_MINIZIP=ON
234 + -DUSE_PNG=ON
235 + -DUSE_SQLITE3="$(usex sqlite)"
236 + -DUSE_ZLIB=ON
237 + )
238 + cmake_src_configure
239 +}
240 +
241 +src_compile() {
242 + cmake_src_compile
243 +}
244 +
245 +src_install() {
246 + if use qt5 ; then
247 + dobin ${BUILD_DIR}/qt/${PN}-qt
248 + doman doc/${PN}-qt.6
249 + domenu res/${PN}-qt.desktop
250 + for size in 16 24 32 48 64 96 128 256 ; do
251 + newicon -s ${size} res/${PN}-${size}.png ${PN}.png
252 + done
253 + fi
254 + if use sdl ; then
255 + doman doc/${PN}.6
256 + newbin ${BUILD_DIR}/sdl/${PN} ${PN}-sdl
257 + fi
258 +
259 + dolib.so ${BUILD_DIR}/lib${PN}.so*
260 +}
261 +
262 +pkg_preinst() {
263 + if use qt5 ; then
264 + xdg_pkg_preinst
265 + fi
266 +}
267 +
268 +pkg_postinst() {
269 + if use qt5 ; then
270 + xdg_pkg_postinst
271 + fi
272 +}
273 +
274 +pkg_postrm() {
275 + if use qt5 ; then
276 + xdg_pkg_postrm
277 + fi
278 +}