git: 3832a517de87 - main - games/jaggedalliance2: Update to 0.19.1

From: Neel Chauhan <nc_at_FreeBSD.org>
Date: Mon, 09 May 2022 16:52:16 UTC
The branch main has been updated by nc:

URL: https://cgit.FreeBSD.org/ports/commit/?id=3832a517de8708ed7e4407ab29f662bce8053bdb

commit 3832a517de8708ed7e4407ab29f662bce8053bdb
Author:     Pavel Timofeev <timp87@gmail.com>
AuthorDate: 2022-05-09 04:08:35 +0000
Commit:     Neel Chauhan <nc@FreeBSD.org>
CommitDate: 2022-05-09 16:51:45 +0000

    games/jaggedalliance2: Update to 0.19.1
    
    Changes: https://ja2-stracciatella.github.io/2022/04/27/release-0.19.1.html
    
    PR:     263708
---
 games/jaggedalliance2/Makefile                     | 33 +++++++++++++--------
 games/jaggedalliance2/distinfo                     |  8 ++---
 .../patch-dependencies_lib-lua_CMakeLists.txt      |  7 -----
 ...patch-dependencies_lib-miniaudio_CMakeLists.txt | 34 ++++++++++++++++++++++
 .../files/patch-rust_stracciatella_src_fs.rs       | 11 +++++++
 .../files/patch-src_sgp_SoundMan.cc                | 11 +++++++
 6 files changed, 80 insertions(+), 24 deletions(-)

diff --git a/games/jaggedalliance2/Makefile b/games/jaggedalliance2/Makefile
index 68f83f9b765a..84c1fcc1a8e3 100644
--- a/games/jaggedalliance2/Makefile
+++ b/games/jaggedalliance2/Makefile
@@ -2,8 +2,7 @@
 
 PORTNAME=	ja2
 DISTVERSIONPREFIX=	v
-DISTVERSION=	0.19.0
-PORTREVISION=	1
+DISTVERSION=	0.19.1
 CATEGORIES=	games
 
 MAINTAINER=	timp87@gmail.com
@@ -22,7 +21,8 @@ ONLY_FOR_ARCHS_REASON=	requires little endian environment
 
 BUILD_DEPENDS=	string_theory>=3.1:devel/string_theory \
 		rapidjson>=1.1.0:devel/rapidjson \
-		sol2>=3.2.2:devel/sol2
+		sol2>=3.2.2:devel/sol2 \
+		miniaudio>=0.10.36<0.11:audio/miniaudio
 LIB_DEPENDS=	libfltk.so:x11-toolkits/fltk
 
 USES=		cargo cmake compiler:c++17-lang pkgconfig sdl xorg gl lua:53
@@ -32,10 +32,9 @@ GH_PROJECT=	ja2-stracciatella
 USE_SDL=	sdl2
 USE_GL=		gl
 USE_XORG=	ice sm x11 xext
-GH_TUPLE=	mackron:miniaudio:634cdb028f340075ae8e8a1126620695688d2ac3:miniaudio
 
-CMAKE_ARGS=	-DEXTRA_DATA_DIR:PATH="${DATADIR}"
-CMAKE_OFF=	LOCAL_STRING_THEORY_LIB WITH_UNITTESTS LOCAL_RAPIDJSON_LIB LOCAL_LUA_LIB LOCAL_SOL_LIB
+CMAKE_ARGS=	-DEXTRA_DATA_DIR:PATH="${DATADIR}" -DMINIAUDIO_INCLUDE_DIR="${PREFIX}/include/miniaudio"
+CMAKE_OFF=	LOCAL_STRING_THEORY_LIB WITH_UNITTESTS LOCAL_RAPIDJSON_LIB LOCAL_LUA_LIB LOCAL_SOL_LIB LOCAL_MINIAUDIO_LIB
 
 CARGO_CRATES=	ahash-0.7.6 \
 		aho-corasick-0.7.18 \
@@ -137,11 +136,6 @@ CARGO_TEST=		no
 MAKE_ENV=	${CARGO_ENV:NCARGO_TARGET_DIR=*}
 LDFLAGS+=	-Wl,--as-needed
 
-pre-patch:
-	@${REINPLACE_CMD} -e 's|https://github.com/mackron/miniaudio/archive/634cdb028f340075ae8e8a1126620695688d2ac3.zip|${DISTDIR}/mackron-miniaudio-634cdb028f340075ae8e8a1126620695688d2ac3_GH0.tar.gz|' \
-		-e 's|b30045e95cec65bfe1d9fe3639f480a2|975a4d15815118a7ded8fbc7d3de68f6|' \
-		${WRKSRC}/dependencies/lib-miniaudio/getter/CMakeLists.txt.in
-
 post-patch:
 	@${REINPLACE_CMD} -e 's|/some/place/where/the/data/is|${DATADIR}|' \
 		${WRKSRC}/rust/stracciatella/src/stracciatella.rs
@@ -151,4 +145,19 @@ post-install:
 		${STAGEDIR}${PREFIX}/bin/ja2-launcher \
 		${STAGEDIR}${PREFIX}/bin/ja2-resource-pack
 
-.include <bsd.port.mk>
+.include <bsd.port.pre.mk>
+
+# Compilation with clang's broken in 14-CURRENT
+.if ${OSVERSION} >= 1400000
+# See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236344
+# Copy-pasted gcc-c++11-lib from Mk/Uses/compiler.mk
+USE_GCC=	yes
+CHOSEN_COMPILER_TYPE=	gcc
+CXXFLAGS+=	-nostdinc++ -isystem /usr/include/c++/v1
+LDFLAGS+=	-L${WRKDIR}
+_USES_configure+=	200:gcc-libc++-configure
+gcc-libc++-configure:
+	@${LN} -fs /usr/lib/libc++.so ${WRKDIR}/libstdc++.so
+.endif
+
+.include <bsd.port.post.mk>
diff --git a/games/jaggedalliance2/distinfo b/games/jaggedalliance2/distinfo
index d3075c922bed..269e134dac07 100644
--- a/games/jaggedalliance2/distinfo
+++ b/games/jaggedalliance2/distinfo
@@ -1,4 +1,4 @@
-TIMESTAMP = 1650500685
+TIMESTAMP = 1651349655
 SHA256 (rust/crates/ahash-0.7.6.crate) = fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47
 SIZE (rust/crates/ahash-0.7.6.crate) = 38030
 SHA256 (rust/crates/aho-corasick-0.7.18.crate) = 1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f
@@ -179,7 +179,5 @@ SHA256 (rust/crates/winapi-x86_64-pc-windows-gnu-0.4.0.crate) = 712e227841d057c1
 SIZE (rust/crates/winapi-x86_64-pc-windows-gnu-0.4.0.crate) = 2947998
 SHA256 (rust/crates/yaml-rust-0.4.5.crate) = 56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85
 SIZE (rust/crates/yaml-rust-0.4.5.crate) = 47783
-SHA256 (ja2-stracciatella-ja2-stracciatella-v0.19.0_GH0.tar.gz) = 8d204f2786b8e2cb8eca61005f89aae05e1ff2300079a61c15c1c61823dc037b
-SIZE (ja2-stracciatella-ja2-stracciatella-v0.19.0_GH0.tar.gz) = 26386346
-SHA256 (mackron-miniaudio-634cdb028f340075ae8e8a1126620695688d2ac3_GH0.tar.gz) = 4e21d471a09f644c6b6d0ee53f8df6d3019f1d2bc8b6dc3dc58a6ef3353b064e
-SIZE (mackron-miniaudio-634cdb028f340075ae8e8a1126620695688d2ac3_GH0.tar.gz) = 1227075
+SHA256 (ja2-stracciatella-ja2-stracciatella-v0.19.1_GH0.tar.gz) = e9806755f471275b653408f5b1ffc6f1629e83ac2fe04370b8756ed6eb87fee7
+SIZE (ja2-stracciatella-ja2-stracciatella-v0.19.1_GH0.tar.gz) = 26385836
diff --git a/games/jaggedalliance2/files/patch-dependencies_lib-lua_CMakeLists.txt b/games/jaggedalliance2/files/patch-dependencies_lib-lua_CMakeLists.txt
index a11cdcdf6bdb..0ffaecc51d33 100644
--- a/games/jaggedalliance2/files/patch-dependencies_lib-lua_CMakeLists.txt
+++ b/games/jaggedalliance2/files/patch-dependencies_lib-lua_CMakeLists.txt
@@ -22,10 +22,3 @@
  message(STATUS "<lua>")
  
  CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
-@@ -31,4 +48,4 @@ LIST(REMOVE_ITEM LUA_SRC
-     "${SRC_DIR}/src/luac.c")
- 
- ADD_LIBRARY(lua ${LUA_SRC})
--message(STATUS "</lua>")
-\ No newline at end of file
-+message(STATUS "</lua>")
diff --git a/games/jaggedalliance2/files/patch-dependencies_lib-miniaudio_CMakeLists.txt b/games/jaggedalliance2/files/patch-dependencies_lib-miniaudio_CMakeLists.txt
new file mode 100644
index 000000000000..9bf1647b5357
--- /dev/null
+++ b/games/jaggedalliance2/files/patch-dependencies_lib-miniaudio_CMakeLists.txt
@@ -0,0 +1,34 @@
+--- dependencies/lib-miniaudio/CMakeLists.txt.orig	2022-04-27 09:14:13 UTC
++++ dependencies/lib-miniaudio/CMakeLists.txt
+@@ -1,5 +1,31 @@
+ # \file dependencies/lib-miniaudio/CMakeLists.txt
+ 
++option(LOCAL_MINIAUDIO_LIB "Download and build miniaudio instead of searching the system" ON)
++if (NOT LOCAL_MINIAUDIO_LIB)
++    message(STATUS "Using system miniaudio")
++
++    if (NOT DEFINED MINIAUDIO_INCLUDE_DIR)
++        message(FATAL_ERROR "MINIAUDIO_INCLUDE_DIR var not set")
++    endif()
++
++    include(CheckIncludeFileCXX)
++    set (CMAKE_REQUIRED_INCLUDES "${MINIAUDIO_INCLUDE_DIR}")
++
++    CHECK_INCLUDE_FILE_CXX("miniaudio.h" MINIAUDIO_FOUND)
++    if (NOT MINIAUDIO_FOUND)
++        message(FATAL_ERROR "miniaudio.h not found")
++    endif()
++
++    CHECK_INCLUDE_FILE_CXX("extras/stb_vorbis.c" VORBIS_FOUND)
++    if (NOT VORBIS_FOUND)
++        message(FATAL_ERROR "miniaudio extras/stb_vorbis.c not found")
++    endif()
++
++    set(MINIAUDIO_INCLUDE_DIRS "${MINIAUDIO_INCLUDE_DIR}" PARENT_SCOPE)
++
++    return()
++endif()
++
+ message(STATUS "<miniaudio>")
+ 
+ # create getter
diff --git a/games/jaggedalliance2/files/patch-rust_stracciatella_src_fs.rs b/games/jaggedalliance2/files/patch-rust_stracciatella_src_fs.rs
new file mode 100644
index 000000000000..1fdc729750d8
--- /dev/null
+++ b/games/jaggedalliance2/files/patch-rust_stracciatella_src_fs.rs
@@ -0,0 +1,11 @@
+--- rust/stracciatella/src/fs.rs.orig	2022-05-02 13:31:34 UTC
++++ rust/stracciatella/src/fs.rs
+@@ -59,7 +59,7 @@ pub fn remove_file<P: AsRef<Path>>(path: P) -> Result<
+ pub fn rename<P: AsRef<Path>>(from: P, to: P) -> Result<(), io::Error> {
+     match std::fs::rename(&from, &to) {
+         Ok(()) => Ok(()),
+-        #[cfg(target_os = "linux")]
++        #[cfg(target_family = "unix")]
+         Err(e) if e.raw_os_error() == Some(libc::EXDEV) => {
+             std::fs::copy(&from, &to).and_then(|_| remove_file(&from))
+         }
diff --git a/games/jaggedalliance2/files/patch-src_sgp_SoundMan.cc b/games/jaggedalliance2/files/patch-src_sgp_SoundMan.cc
new file mode 100644
index 000000000000..a36ac1994f55
--- /dev/null
+++ b/games/jaggedalliance2/files/patch-src_sgp_SoundMan.cc
@@ -0,0 +1,11 @@
+--- src/sgp/SoundMan.cc.orig	2022-04-27 09:14:13 UTC
++++ src/sgp/SoundMan.cc
+@@ -696,7 +696,7 @@ size_t MiniaudioReadProc(ma_decoder* pDecoder, void* p
+ 	return SDL_RWread(rwOps, pBufferOut, sizeof(UINT8), bytesToRead);
+ }
+ 
+-ma_bool32 MiniaudioSeekProc(ma_decoder* pDecoder, int byteOffset, ma_seek_origin origin) {
++ma_bool32 MiniaudioSeekProc(ma_decoder* pDecoder, ma_int64 byteOffset, ma_seek_origin origin) {
+ 	auto rwOps = (SDL_RWops*)pDecoder->pUserData;
+ 	auto sdlOrigin = RW_SEEK_SET;
+ 	if (origin == ma_seek_origin::ma_seek_origin_current) {