Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Oct 2022 18:09:28 GMT
From:      Alexey Dokuchaev <danfe@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: c5f751f8a9d0 - main - games/xray_re-tools: unbreak the build against new nVidia Texture Tools
Message-ID:  <202210151809.29FI9S9G099639@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by danfe:

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

commit c5f751f8a9d0d1a0a753f9b95562db4c97eea836
Author:     Alexey Dokuchaev <danfe@FreeBSD.org>
AuthorDate: 2022-10-15 18:08:20 +0000
Commit:     Alexey Dokuchaev <danfe@FreeBSD.org>
CommitDate: 2022-10-15 18:08:20 +0000

    games/xray_re-tools: unbreak the build against new nVidia Texture Tools
    
    In 2020 Ignacio had modified the API with NVTT upstream commit adce1a00
    which must have been cleanup, but was more than that.  Particularly, it
    shuffled things around DirectDrawSurface class, and thus had broken the
    port's build.  While here, remove all bundled 3rd-party code to prevent
    accidental use thereof.
---
 games/xray_re-tools/Makefile                       | 10 ++++-
 games/xray_re-tools/files/Makefile                 |  3 +-
 .../patch-sources_3rd-party_nvtt_nvcore_Memory.h   | 20 ---------
 ...ch-sources_3rd-party_nvtt_nvcore_poshlib_posh.h | 14 -------
 .../patch-sources_xray__re_xr__image__dds.cxx      | 48 ++++++++++++++++++++++
 5 files changed, 58 insertions(+), 37 deletions(-)

diff --git a/games/xray_re-tools/Makefile b/games/xray_re-tools/Makefile
index 91c0d035e431..6267cb8bf449 100644
--- a/games/xray_re-tools/Makefile
+++ b/games/xray_re-tools/Makefile
@@ -6,12 +6,11 @@ MAINTAINER=	danfe@FreeBSD.org
 COMMENT=	X-Ray engine game asset converter (unofficial)
 WWW=		https://github.com/abramcumner/xray_re-tools
 
+BUILD_DEPENDS=	${NONEXISTENT}:graphics/nvidia-texture-tools:patch
 LIB_DEPENDS=	liblzo2.so:archivers/lzo2 \
 		libvorbisfile.so:audio/libvorbis \
 		libnvtt.so:graphics/nvidia-texture-tools
 
-BROKEN=		does not link: ld: error: undefined symbol: nv::mem::malloc
-
 USE_GITHUB=	yes
 GH_ACCOUNT=	abramcumner
 GH_TAGNAME=	52721d2
@@ -19,11 +18,13 @@ GH_TAGNAME=	52721d2
 MAKEFILE=	${FILESDIR}/Makefile
 BUILD_WRKSRC=	${WRKSRC}/sources
 WITHOUT_FBSD10_FIX=	yes
+_NVTT_WRKSRC=	${MAKE} -C ${PORTSDIR}/graphics/nvidia-texture-tools -V WRKSRC
 
 PLIST_FILES=	bin/xr_converter
 
 post-extract:
 	@${MV} ${WRKSRC}/sources/3rd\ party ${WRKSRC}/sources/3rd-party
+	@cd ${WRKSRC}/sources/3rd-party && ${RM} -r libogg libvorbis nvtt
 	@${MV} ${WRKSRC}/sources/utils/converter/opcode/Ice/IceTrilist.h \
 		${WRKSRC}/sources/utils/converter/opcode/Ice/IceTriList.h
 	@${LN} -s StdAfx.h ${WRKSRC}/sources/utils/converter/opcode/Stdafx.h
@@ -53,6 +54,11 @@ post-patch:
 	@${REINPLACE_CMD} -e 's,MINGW32__),& || defined(__FreeBSD__),' \
 		${WRKSRC}/sources/xray_re/xr_types.h
 
+post-configure:
+	@${LN} -sf ${_NVTT_WRKSRC:sh}/src ${WRKSRC}/sources/3rd-party/nvtt
+	@${REINPLACE_CMD} -e '/#include "nvconfig\.h"/d' \
+		${WRKSRC}/sources/3rd-party/nvtt/nvcore/nvcore.h
+
 do-install:
 	${INSTALL_PROGRAM} ${BUILD_WRKSRC}/converter \
 		${STAGEDIR}${PREFIX}/bin/xr_converter
diff --git a/games/xray_re-tools/files/Makefile b/games/xray_re-tools/files/Makefile
index 3220d663a3ba..0ac7ccba00a4 100644
--- a/games/xray_re-tools/files/Makefile
+++ b/games/xray_re-tools/files/Makefile
@@ -1,5 +1,6 @@
 CXXFLAGS+=	-Wall -Wextra
-CPPFLAGS+=	-Ixray_re -Iutils/converter/opcode -I3rd-party/nvtt -I$(LOCALBASE)/include
+CPPFLAGS+=	-Ixray_re -Iutils/converter/opcode -I3rd-party/nvtt \
+		-I3rd-party/nvtt/../extern/poshlib -I$(LOCALBASE)/include
 LDFLAGS+=	-L$(LOCALBASE)/lib
 
 xray_re_OBJS=	xray_re/xr_ai_cross_table.o \
diff --git a/games/xray_re-tools/files/patch-sources_3rd-party_nvtt_nvcore_Memory.h b/games/xray_re-tools/files/patch-sources_3rd-party_nvtt_nvcore_Memory.h
deleted file mode 100644
index b6b6833f06ad..000000000000
--- a/games/xray_re-tools/files/patch-sources_3rd-party_nvtt_nvcore_Memory.h
+++ /dev/null
@@ -1,20 +0,0 @@
---- sources/3rd-party/nvtt/nvcore/Memory.h.orig	2018-09-02 12:42:44 UTC
-+++ sources/3rd-party/nvtt/nvcore/Memory.h
-@@ -28,7 +28,7 @@ namespace nv
- 
- // Override new/delete
- 
--inline void * operator new (size_t size) throw()
-+inline void * operator new (size_t size) _THROW_BAD_ALLOC
- {
- 	return nv::mem::malloc(size); 
- }
-@@ -38,7 +38,7 @@ inline void operator delete (void *p) throw()
- 	nv::mem::free(p); 
- }
- 
--inline void * operator new [] (size_t size) throw()
-+inline void * operator new [] (size_t size) _THROW_BAD_ALLOC
- {
- 	return nv::mem::malloc(size);
- }
diff --git a/games/xray_re-tools/files/patch-sources_3rd-party_nvtt_nvcore_poshlib_posh.h b/games/xray_re-tools/files/patch-sources_3rd-party_nvtt_nvcore_poshlib_posh.h
deleted file mode 100644
index 7448d82366c0..000000000000
--- a/games/xray_re-tools/files/patch-sources_3rd-party_nvtt_nvcore_poshlib_posh.h
+++ /dev/null
@@ -1,14 +0,0 @@
---- sources/3rd-party/nvtt/nvcore/poshlib/posh.h.orig	2018-09-02 12:42:44 UTC
-+++ sources/3rd-party/nvtt/nvcore/poshlib/posh.h
-@@ -293,6 +293,11 @@ Metrowerks:
- #  define POSH_OS_STRING "Linux"
- #endif
- 
-+#if defined __FreeBSD__
-+#  define POSH_OS_LINUX 1
-+#  define POSH_OS_STRING "FreeBSD"
-+#endif
-+
- #if defined __CYGWIN32__
- #  define POSH_OS_CYGWIN32 1
- #  define POSH_OS_STRING "Cygwin"
diff --git a/games/xray_re-tools/files/patch-sources_xray__re_xr__image__dds.cxx b/games/xray_re-tools/files/patch-sources_xray__re_xr__image__dds.cxx
new file mode 100644
index 000000000000..4323a3afc70c
--- /dev/null
+++ b/games/xray_re-tools/files/patch-sources_xray__re_xr__image__dds.cxx
@@ -0,0 +1,48 @@
+--- sources/xray_re/xr_image_dds.cxx.orig	2018-09-02 12:42:44 UTC
++++ sources/xray_re/xr_image_dds.cxx
+@@ -7,6 +7,7 @@
+ #include <nvmath/Color.h>
+ #include <nvtt/nvtt.h>
+ #pragma warning(pop)
++#undef sqrt
+ #include "xr_image.h"
+ #include "xr_file_system.h"
+ 
+@@ -14,13 +15,14 @@ bool xr_image::load_dds(const std::string& path)
+ 
+ bool xr_image::load_dds(const std::string& path)
+ {
+-	nv::DirectDrawSurface dds(path.c_str());
++	nv::DirectDrawSurface dds;
++	dds.load(path.c_str());
+ 	if (!dds.isValid() || !dds.isTexture2D())
+ 		return false;
+ 	nv::Image image;
+-	dds.mipmap(&image, 0, 0);
+-	m_width = image.width();
+-	m_height = image.height();
++	imageFromDDS(&image, dds, 0, 0);
++	m_width = image.width;
++	m_height = image.height;
+ 	m_data = new rgba32[m_width*m_height];
+ 	for (unsigned i = m_height*m_width; i > 0;) {
+ 		const nv::Color32& pix = image.pixel(--i);
+@@ -50,6 +52,7 @@ struct dds_writer: public nvtt::OutputHandler {
+ 			dds_writer(xr_writer& _w);
+ 
+ 	virtual void	beginImage(int size, int width, int height, int depth, int face, int miplevel);
++	virtual void	endImage();
+ 	virtual bool	writeData(const void* data, int size);
+ 	xr_writer&	w;
+ };
+@@ -60,6 +63,10 @@ void dds_writer::beginImage(int size, int width, int h
+ {
+ }
+ 
++void dds_writer::endImage()
++{
++}
++
+ bool dds_writer::writeData(const void* data, int size)
+ {
+ 	w.w_raw(data, size_t(size & INT_MAX));



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202210151809.29FI9S9G099639>