git: 57569e0b98a8 - main - emulators/{,libretro-}ppsspp{,-qt5}: Fix build with miniupnpc-2.2.8

From: Vladimir Druzenko <vvd_at_FreeBSD.org>
Date: Wed, 17 Jul 2024 13:38:45 UTC
The branch main has been updated by vvd:

URL: https://cgit.FreeBSD.org/ports/commit/?id=57569e0b98a87e08032fe64c106958b8e439ebd7

commit 57569e0b98a87e08032fe64c106958b8e439ebd7
Author:     Vladimir Druzenko <vvd@FreeBSD.org>
AuthorDate: 2024-07-17 13:31:55 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2024-07-17 13:31:55 +0000

    emulators/{,libretro-}ppsspp{,-qt5}: Fix build with miniupnpc-2.2.8
    
    Upstream bug report: https://github.com/hrydgard/ppsspp/issues/19333
    
    While here fix plist error in libretro-ppsspp and pet portclippy.
    
    PR:     280298
---
 emulators/libretro-ppsspp/Makefile                 |  6 +-
 emulators/ppsspp-qt5/Makefile                      |  6 +-
 emulators/ppsspp/Makefile                          | 78 +++++++++++-----------
 .../ppsspp/files/patch-Core_Util_PortManager.cpp   | 25 +++++++
 4 files changed, 69 insertions(+), 46 deletions(-)

diff --git a/emulators/libretro-ppsspp/Makefile b/emulators/libretro-ppsspp/Makefile
index 59effea19ca9..add5ff86a07a 100644
--- a/emulators/libretro-ppsspp/Makefile
+++ b/emulators/libretro-ppsspp/Makefile
@@ -1,9 +1,9 @@
-PORTREVISION=	0
+PORTREVISION=	1
 PKGNAMEPREFIX=	libretro-
 
 MASTERDIR=	${.CURDIR}/../ppsspp
 
-OPTIONS_SLAVE=	LIBRETRO
-OPTIONS_EXCLUDE=${OPTIONS_DEFINE}
+OPTIONS_EXCLUDE=	${OPTIONS_DEFINE}
+OPTIONS_SLAVE=		LIBRETRO
 
 .include "${MASTERDIR}/Makefile"
diff --git a/emulators/ppsspp-qt5/Makefile b/emulators/ppsspp-qt5/Makefile
index 2b5cf472f7e3..71f2a24b5d82 100644
--- a/emulators/ppsspp-qt5/Makefile
+++ b/emulators/ppsspp-qt5/Makefile
@@ -1,10 +1,10 @@
-PORTREVISION=	0
+PORTREVISION=	1
 PKGNAMESUFFIX=	-qt5
 
 MASTERDIR=	${.CURDIR}/../ppsspp
 
-OPTIONS_SLAVE=	QT5
 # XXX No VULKAN per https://github.com/hrydgard/ppsspp/blob/v1.10/Qt/QtMain.cpp#L711-L712
-OPTIONS_EXCLUDE=${OPTIONS_DEFINE}
+OPTIONS_EXCLUDE=	${OPTIONS_DEFINE}
+OPTIONS_SLAVE=		QT5
 
 .include "${MASTERDIR}/Makefile"
diff --git a/emulators/ppsspp/Makefile b/emulators/ppsspp/Makefile
index 1dfb83ec39ad..826d848ebefc 100644
--- a/emulators/ppsspp/Makefile
+++ b/emulators/ppsspp/Makefile
@@ -26,6 +26,7 @@ LIB_DEPENDS=	libzip.so:archivers/libzip \
 		libminiupnpc.so:net/miniupnpc
 RUN_DEPENDS=	xdg-open:devel/xdg-utils
 
+USES=		cmake compiler:c++11-lib gl localbase:ldflags pkgconfig
 USE_GITHUB=	yes
 GH_ACCOUNT=	hrydgard
 GH_TUPLE?=	hrydgard:glslang:8.13.3743-948-gb34f619e:glslang/ext/glslang \
@@ -37,68 +38,65 @@ GH_TUPLE?=	hrydgard:glslang:8.13.3743-948-gb34f619e:glslang/ext/glslang \
 		Kingcom:filesystem:v1.3.2-12-g3f1c185:filesystem/ext/armips/ext/filesystem \
 		RetroAchievements:rcheevos:v11.0.0-26-ge7989c3:rcheevos/ext/rcheevos \
 		Tencent:rapidjson:v1.1.0-415-g73063f50:rapidjson/ext/rapidjson
-
-CONFLICTS_INSTALL=	${PORTNAME}-*
-
-USES=		cmake compiler:c++11-lib gl localbase:ldflags pkgconfig shared-mime-info
 EXCLUDE=	libzip zlib
-EXTRACT_AFTER_ARGS=${EXCLUDE:S,^,--exclude ,}
 USE_GL=		glew opengl
 CMAKE_ON=	${FFMPEG LIBZIP MINIUPNPC SNAPPY ZSTD:L:S/^/USE_SYSTEM_/} USE_VULKAN_DISPLAY_KHR
 CMAKE_OFF=	USE_DISCORD
 LDFLAGS+=	-Wl,--as-needed # ICE/SM/X11/Xext, Qt5Network
+CONFLICTS_INSTALL=	${PORTNAME}-*
+DESKTOP_ENTRIES=	"PPSSPP" \
+			"" \
+			"${PORTNAME}" \
+			"${PORTNAME} %f" \
+			"Game;Emulator;" \
+			""
+EXTRACT_AFTER_ARGS=	${EXCLUDE:S,^,--exclude ,}
 SUB_FILES=	pkg-message
 PORTDATA=	assets
 
-DESKTOP_ENTRIES="PPSSPP" \
-		"" \
-		"${PORTNAME}" \
-		"${PORTNAME} %f" \
-		"Game;Emulator;" \
-		""
-
-OPTIONS_DEFINE=	VULKAN
-OPTIONS_DEFAULT=VULKAN
-OPTIONS_SINGLE=	GUI
+OPTIONS_DEFINE=		VULKAN
+OPTIONS_DEFAULT=	VULKAN
+OPTIONS_SINGLE=		GUI
 OPTIONS_SINGLE_GUI=	LIBRETRO QT5 SDL
-OPTIONS_SLAVE?=	SDL
 OPTIONS_EXCLUDE:=	${OPTIONS_EXCLUDE} ${OPTIONS_SINGLE_GUI}
+OPTIONS_SLAVE?=		SDL
 
-LIBRETRO_DESC=	libretro core for games/retroarch
+LIBRETRO_DESC=		libretro core for games/retroarch
+VULKAN_DESC=		Vulkan renderer
+LIBRETRO_LIB_DEPENDS=	libpng.so:graphics/png
 LIBRETRO_CMAKE_BOOL=	LIBRETRO
 LIBRETRO_PLIST_FILES=	lib/libretro/${PORTNAME}_libretro.so
-LIBRETRO_VARS=	CONFLICTS_INSTALL= DESKTOP_ENTRIES= PLIST= PORTDATA= PKGMESSAGE= SUB_FILES=
-QT5_USES=	elfctl qt:5 sdl
-QT5_USE=	QT=qmake:build,buildtools:build,linguisttools:build,gui,multimedia,opengl,widgets
-QT5_USE+=	SDL=sdl2 # audio, joystick
-QT5_CMAKE_BOOL=	USING_QT_UI
-QT5_VARS=	EXENAME=PPSSPPQt ELF_FEATURES=+wxneeded:PPSSPPQt
+LIBRETRO_VARS=		CONFLICTS_INSTALL= DESKTOP_ENTRIES= PLIST= PORTDATA= PKGMESSAGE= SUB_FILES=
+QT5_LIB_DEPENDS=	libpng.so:graphics/png
+QT5_USES=		desktop-file-utils elfctl qt:5 shared-mime-info sdl
+QT5_USE=		QT=qmake:build,buildtools:build,linguisttools:build,core,gui,multimedia,opengl,widgets
+QT5_USE+=		SDL=sdl2 # audio, joystick
+QT5_CMAKE_BOOL=		USING_QT_UI
+QT5_VARS=		EXENAME=PPSSPPQt ELF_FEATURES=+wxneeded:PPSSPPQt
 SDL_CATEGORIES=		wayland
-SDL_BUILD_DEPENDS=	png>=1.6:graphics/png
 SDL_LIB_DEPENDS=	libpng.so:graphics/png
-SDL_USES=	elfctl sdl
-SDL_USE=	SDL=sdl2
-SDL_VARS=	EXENAME=PPSSPPSDL ELF_FEATURES=+wxneeded:PPSSPPSDL
-VULKAN_DESC=		Vulkan renderer
+SDL_USES=		elfctl shared-mime-info sdl
+SDL_USE=		SDL=sdl2
+SDL_VARS=		EXENAME=PPSSPPSDL ELF_FEATURES=+wxneeded:PPSSPPSDL
 VULKAN_RUN_DEPENDS=	${LOCALBASE}/lib/libvulkan.so:graphics/vulkan-loader
 
 post-patch:
-	@${REINPLACE_CMD} -e 's/Linux/${OPSYS}/' \
-		${WRKSRC}/assets/gamecontrollerdb.txt
-	@${REINPLACE_CMD} -e 's,/usr/share,${PREFIX}/share,' \
-		${WRKSRC}/UI/NativeApp.cpp
-	@${REINPLACE_CMD} -e 's/"unknown"/"${DISTVERSIONFULL}"/' \
-		${WRKSRC}/git-version.cmake
-
-do-install-QT5-on do-install-SDL-on:
-	${MV} ${STAGEDIR}${PREFIX}/bin/${EXENAME} \
-		${STAGEDIR}${PREFIX}/bin/${PORTNAME}
-	${INSTALL_MAN} ${_DISTDIR}/${PORTNAME}.1 \
-		${STAGEDIR}${PREFIX}/share/man/man1
+	@${REINPLACE_CMD} -e 's/Linux/${OPSYS}/' ${WRKSRC}/assets/gamecontrollerdb.txt
+	@${REINPLACE_CMD} -e 's,/usr/share,${PREFIX}/share,' ${WRKSRC}/UI/NativeApp.cpp
+	@${REINPLACE_CMD} -e 's/"unknown"/"${DISTVERSIONFULL}"/' ${WRKSRC}/git-version.cmake
 
 do-install-LIBRETRO-on:
 	${MKDIR} ${STAGEDIR}${PREFIX}/${LIBRETRO_PLIST_FILES:H}
 	${INSTALL_LIB} ${BUILD_WRKSRC}/lib/${LIBRETRO_PLIST_FILES:T} \
 		${STAGEDIR}${PREFIX}/${LIBRETRO_PLIST_FILES:H}
+.if ${OPTIONS_SLAVE} == LIBRETRO
+.  for d in applications icons man mime ${PORTNAME}
+	${RM} -r ${STAGEDIR}${PREFIX}/share/${d}
+.  endfor
+.endif
+
+do-install-QT5-on do-install-SDL-on:
+	${MV} ${STAGEDIR}${PREFIX}/bin/${EXENAME} ${STAGEDIR}${PREFIX}/bin/${PORTNAME}
+	${INSTALL_MAN} ${_DISTDIR}/${PORTNAME}.1 ${STAGEDIR}${PREFIX}/share/man/man1
 
 .include <bsd.port.mk>
diff --git a/emulators/ppsspp/files/patch-Core_Util_PortManager.cpp b/emulators/ppsspp/files/patch-Core_Util_PortManager.cpp
new file mode 100644
index 000000000000..e2b3ae859c67
--- /dev/null
+++ b/emulators/ppsspp/files/patch-Core_Util_PortManager.cpp
@@ -0,0 +1,25 @@
+--- Core/Util/PortManager.cpp.orig	2024-02-04 13:08:02 UTC
++++ Core/Util/PortManager.cpp
+@@ -161,7 +161,21 @@ bool PortManager::Initialize(const unsigned int timeou
+ 
+ 		// Get LAN IP address that connects to the router
+ 		char lanaddr[64] = "unset";
+-		int status = UPNP_GetValidIGD(devlist, urls, datas, lanaddr, sizeof(lanaddr)); //possible "status" values, 0 = NO IGD found, 1 = A valid connected IGD has been found, 2 = A valid IGD has been found but it reported as not connected, 3 = an UPnP device has been found but was not recognized as an IGD
++/*
++possible "status" values:
++-1 = Internal error
++ 0 = NO IGD found
++ 1 = A valid connected IGD has been found
++ 2 = A valid connected IGD has been found but its IP address is reserved (non routable)
++ 3 = A valid IGD has been found but it reported as not connected
++ 4 = an UPnP device has been found but was not recognized as an IGD
++*/
++		int status =
++#if (MINIUPNPC_API_VERSION >= 18)
++			UPNP_GetValidIGD(devlist, urls, datas, lanaddr, sizeof(lanaddr), nullptr, 0);
++#else
++			UPNP_GetValidIGD(devlist, urls, datas, lanaddr, sizeof(lanaddr));
++#endif
+ 		m_lanip = std::string(lanaddr);
+ 		INFO_LOG(SCENET, "PortManager - Detected LAN IP: %s", m_lanip.c_str());
+