unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: James Smith via Guix-patches via <guix-patches@gnu.org>
To: 73287@debbugs.gnu.org
Cc: "James Smith" <jsubuntuxp@disroot.org>,
	"Adam Faiz" <adam.faiz@disroot.org>,
	"Liliana Marie Prikler" <liliana.prikler@gmail.com>,
	宋文武 <iyzsong@envs.net>
Subject: [bug#73287] [PATCH v2 2/3] gnu: Add ericw-tools.
Date: Fri, 20 Sep 2024 17:38:35 -0700	[thread overview]
Message-ID: <a1ab67515ed40a088f8ae0fe33c1f077d6ff9692.1726879062.git.jsubuntuxp@disroot.org> (raw)
In-Reply-To: <eeb7a4981f3393045f781e33851101ea81b52d15.1726879062.git.jsubuntuxp@disroot.org>

* gnu/packages/game-development.scm: (ericw-tools): New variable.
* gnu/packages/patches/ericw-tools-add-check-for-sse2-in-light.cc.patch: New file.
* gnu/packages/patches/ericw-tools-gcc-11-pass-const-to-offsetof.patch: New file.
* gnu/local.mk: Register patch files.

Change-Id: I896b8f781054442e4db4a7220d526b8f2878873c
---
 gnu/local.mk                                  |  3 +
 gnu/packages/game-development.scm             | 67 ++++++++++++++
 ...tools-add-check-for-sse2-in-light.cc.patch | 31 +++++++
 ...-tools-gcc-11-pass-const-to-offsetof.patch | 87 +++++++++++++++++++
 4 files changed, 188 insertions(+)
 create mode 100644 gnu/packages/patches/ericw-tools-add-check-for-sse2-in-light.cc.patch
 create mode 100644 gnu/packages/patches/ericw-tools-gcc-11-pass-const-to-offsetof.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index a092122d22..616af50410 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -67,6 +67,7 @@
 # Copyright © 2024 David Elsing <david.elsing@posteo.net>
 # Copyright © 2024 Ashish SHUKLA <ashish.is@lostca.se>
 # Copyright © 2024 Fabio Natali <me@fabionatali.com>
+# Copyright © 2024 James Smith <jsubuntuxp@disroot.org>
 #
 # This file is part of GNU Guix.
 #
@@ -1201,6 +1202,8 @@ dist_patch_DATA =						\
   %D%/packages/patches/epiphany-fix-encoding-test.patch	\
   %D%/packages/patches/ergodox-firmware-fix-json-target.patch	\
   %D%/packages/patches/ergodox-firmware-fix-numpad.patch	\
+  %D%/packages/patches/ericw-tools-add-check-for-sse2-in-light.cc.patch	\
+  %D%/packages/patches/ericw-tools-gcc-11-pass-const-to-offsetof.patch	\
   %D%/packages/patches/erlang-man-path.patch			\
   %D%/packages/patches/esmini-use-pkgconfig.patch		\
   %D%/packages/patches/esmtp-add-lesmtp.patch		\
diff --git a/gnu/packages/game-development.scm b/gnu/packages/game-development.scm
index 0bae7cfe11..0b3171d1a8 100644
--- a/gnu/packages/game-development.scm
+++ b/gnu/packages/game-development.scm
@@ -2394,6 +2394,73 @@ (define-public entt
     (license (list license:expat        ; code
                    license:cc-by4.0)))) ; documentation
 
+(define-public ericw-tools
+  (package
+    (name "ericw-tools")
+    (version "0.18.1")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference (url "https://github.com/ericwa/ericw-tools")
+                           (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "11sap7qv0rlhw8q25azvhgjcwiql3zam09q0gim3i04cg6fkh0vp"))
+       (patches
+        (search-patches "ericw-tools-add-check-for-sse2-in-light.cc.patch"
+                        "ericw-tools-gcc-11-pass-const-to-offsetof.patch"))))
+    (build-system cmake-build-system)
+    (arguments
+     (list #:configure-flags #~(list "-DENABLE_LIGHTPREVIEW=OFF")
+           #:phases
+           #~(modify-phases %standard-phases
+               (add-after 'unpack 'disable-copying-embree-files
+                 (lambda _
+                   ;; Tries to copy files from embree, disable it.
+                   (substitute* "light/CMakeLists.txt"
+                     (("install\\\(FILES \\$\\{EMBREE")
+                      "#install(FILES ${EMBREE"))))
+               (add-after 'install 'rename-binaries
+                 (lambda _
+                   ;; Rename binaries to prevent collisions with other
+                   ;; packages.
+                   (rename-file (string-append #$output "/bin/bspinfo")
+                                (string-append #$output "/bin/qbspinfo"))
+                   (rename-file (string-append #$output "/bin/bsputil")
+                                (string-append #$output "/bin/qbsputil"))
+                   (rename-file (string-append #$output "/bin/light")
+                                (string-append #$output "/bin/qlight"))
+                   (rename-file (string-append #$output "/bin/vis")
+                                (string-append #$output "/bin/qvis"))))
+               (add-after 'install-license-files 'clean-up-bin-directory
+                 (lambda _
+                   ;; Install target copies text documents to #$output/bin, move
+                   ;; them to #$output/share/doc.
+                   (delete-file (string-append #$output "/bin/gpl_v3.txt"))
+                   (rename-file
+                    (string-append #$output "/bin/changelog.txt")
+                    (string-append #$output "/share/doc/"
+                                   #$(package-name this-package) "-"
+                                   #$(package-version this-package)
+                                   "/changelog.txt"))
+                   (rename-file
+                    (string-append #$output "/bin/README.md")
+                    (string-append #$output "/share/doc/"
+                                   #$(package-name this-package) "-"
+                                   #$(package-version this-package)
+                                   "/README.md")))))
+           #:tests? #f)) ; No tests
+    (inputs (list embree-2))
+    (home-page "https://ericwa.github.io/ericw-tools/")
+    (synopsis "Map compiling tools for Quake/Hexen 2")
+    (description "A collection of command line utilities used for building
+Quake maps as well as working with various Quake file formats.  The utilities
+include @command{qbsp} for building the geometry, @command{qvis} for
+calculating visibility, @command{qlight} for lighting, @command{bspinfo} for
+getting information, and @command{bsputil} for basic editing of data in a map
+file.")
+    (license license:gpl2+)))
+
 (define-public eureka
   (package
     (name "eureka")
diff --git a/gnu/packages/patches/ericw-tools-add-check-for-sse2-in-light.cc.patch b/gnu/packages/patches/ericw-tools-add-check-for-sse2-in-light.cc.patch
new file mode 100644
index 0000000000..4c95b8570d
--- /dev/null
+++ b/gnu/packages/patches/ericw-tools-add-check-for-sse2-in-light.cc.patch
@@ -0,0 +1,31 @@
+From 982ef5276bb231ded12c45a686b0875594175774 Mon Sep 17 00:00:00 2001
+From: Bryan Haley <bryanmhaley@gmail.com>
+Date: Mon, 28 Mar 2022 22:05:28 -0700
+Subject: [PATCH] Add check for SSE2 in light.cc (#328)
+
+---
+ light/light.cc | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/light/light.cc b/light/light.cc
+index 7e23d040f..c00844643 100644
+--- a/light/light.cc
++++ b/light/light.cc
+@@ -33,7 +33,7 @@
+ #include <common/polylib.hh>
+ #include <common/bsputils.hh>
+ 
+-#ifdef HAVE_EMBREE
++#if defined(HAVE_EMBREE) && defined (__SSE2__)
+ #include <xmmintrin.h>
+ //#include <pmmintrin.h>
+ #endif
+@@ -255,7 +255,7 @@ LightThread(void *arg)
+ {
+     const mbsp_t *bsp = (const mbsp_t *)arg;
+ 
+-#ifdef HAVE_EMBREE
++#if defined(HAVE_EMBREE) && defined (__SSE2__)
+     _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
+ //    _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
+ #endif
diff --git a/gnu/packages/patches/ericw-tools-gcc-11-pass-const-to-offsetof.patch b/gnu/packages/patches/ericw-tools-gcc-11-pass-const-to-offsetof.patch
new file mode 100644
index 0000000000..6da4179a9e
--- /dev/null
+++ b/gnu/packages/patches/ericw-tools-gcc-11-pass-const-to-offsetof.patch
@@ -0,0 +1,87 @@
+From c9570260fa895dde5a21272d76f9a3b05d59efdd Mon Sep 17 00:00:00 2001
+From: Eric Wasylishen <ewasylishen@gmail.com>
+Date: Sun, 30 May 2021 23:12:17 -0600
+Subject: [PATCH] gcc 11: pass constant to offsetof
+
+---
+ common/polylib.cc |  5 ++++-
+ qbsp/util.cc      |  5 ++++-
+ qbsp/winding.cc   |  4 +++-
+ vis/vis.cc        | 10 ++++++++--
+ 4 files changed, 19 insertions(+), 5 deletions(-)
+
+diff --git a/common/polylib.cc b/common/polylib.cc
+index 6397b3107..c8e1afbff 100644
+--- a/common/polylib.cc
++++ b/common/polylib.cc
+@@ -230,7 +230,10 @@ polylib::CopyWinding(const winding_t * w)
+     int size;
+     winding_t *c;
+ 
+-    size = offsetof(winding_t, p[w->numpoints]);
++    //size = offsetof(winding_t, p[w->numpoints]);
++    size = offsetof(winding_t, p[0]);
++    size += w->numpoints * sizeof(w->p[0]);
++
+     c = static_cast<winding_t *>(malloc(size));
+     memcpy(c, w, size);
+     return c;
+diff --git a/qbsp/util.cc b/qbsp/util.cc
+index e8baf7205..16c9077f1 100644
+--- a/qbsp/util.cc
++++ b/qbsp/util.cc
+@@ -53,7 +53,10 @@ AllocMem(int Type, int cElements, bool fZero)
+         if (cElements > MAX_POINTS_ON_WINDING)
+             Error("Too many points (%d) on winding (%s)", cElements, __func__);
+ 
+-        cSize = offsetof(winding_t, points[cElements]) + sizeof(int);
++        //cSize = offsetof(winding_t, points[cElements]) + sizeof(int);
++        cSize = offsetof(winding_t, points[0]);
++        cSize += cElements * sizeof(static_cast<winding_t*>(nullptr)->points[0]);
++        cSize += sizeof(int);
+ 
+         // Set cElements to 1 so bookkeeping works OK
+         cElements = 1;
+diff --git a/qbsp/winding.cc b/qbsp/winding.cc
+index 1af1d096c..6e286c387 100644
+--- a/qbsp/winding.cc
++++ b/qbsp/winding.cc
+@@ -106,7 +106,9 @@ CopyWinding(const winding_t *w)
+     winding_t *c;
+ 
+     c = (winding_t *)AllocMem(WINDING, w->numpoints, false);
+-    size = offsetof(winding_t, points[w->numpoints]);
++    //size = offsetof(winding_t, points[w->numpoints]);
++    size = offsetof(winding_t, points[0]);
++    size += w->numpoints * sizeof(w->points[0]);
+     memcpy(c, w, size);
+ 
+     return c;
+diff --git a/vis/vis.cc b/vis/vis.cc
+index 9fb0ea9ea..ec43a8a5f 100644
+--- a/vis/vis.cc
++++ b/vis/vis.cc
+@@ -127,7 +127,10 @@ NewWinding(int points)
+     if (points > MAX_WINDING)
+         Error("%s: %i points", __func__, points);
+ 
+-    size = offsetof(winding_t, points[points]);
++    //size = offsetof(winding_t, points[points]);
++    size = offsetof(winding_t, points[0]);
++    size += points * sizeof(w->points[0]);
++
+     w = static_cast<winding_t *>(malloc(size));
+     memset(w, 0, size);
+ 
+@@ -178,7 +181,10 @@ CopyWinding(const winding_t * w)
+     int size;
+     winding_t *c;
+ 
+-    size = offsetof(winding_t, points[w->numpoints]);
++    //size = offsetof(winding_t, points[w->numpoints]);
++    size = offsetof(winding_t, points[0]);
++    size += w->numpoints * sizeof(w->points[0]);
++
+     c = static_cast<winding_t *>(malloc(size));
+     memcpy(c, w, size);
+     return c;
-- 
2.46.0





  reply	other threads:[~2024-09-21  0:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-16  2:10 [bug#73287] [PATCH 0/3] Add ericw-tools and TrenchBroom James Smith via Guix-patches via
2024-09-16  2:16 ` [bug#73287] [PATCH 1/3] gnu: Add embree-2 James Smith via Guix-patches via
2024-09-20  7:58   ` Liliana Marie Prikler
2024-09-21  0:35     ` James Smith via Guix-patches via
2024-09-16  2:16 ` [bug#73287] [PATCH 2/3] gnu: Add ericw-tools James Smith via Guix-patches via
2024-09-20  8:04   ` Liliana Marie Prikler
2024-09-16  2:16 ` [bug#73287] [PATCH 3/3] gnu: Add trenchbroom James Smith via Guix-patches via
2024-09-20  8:02   ` Liliana Marie Prikler
2024-09-21  0:38 ` [bug#73287] [PATCH v2 1/3] gnu: Add embree-2 James Smith via Guix-patches via
2024-09-21  0:38   ` James Smith via Guix-patches via [this message]
2024-09-21  0:38   ` [bug#73287] [PATCH v2 3/3] gnu: Add trenchbroom James Smith via Guix-patches via
     [not found] ` <handler.73287.B.172645275019055.ack@debbugs.gnu.org>
2024-10-27 14:30   ` [bug#73287] [PATCH 0/3] Add ericw-tools and TrenchBroom James Smith via Guix-patches via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a1ab67515ed40a088f8ae0fe33c1f077d6ff9692.1726879062.git.jsubuntuxp@disroot.org \
    --to=guix-patches@gnu.org \
    --cc=73287@debbugs.gnu.org \
    --cc=adam.faiz@disroot.org \
    --cc=iyzsong@envs.net \
    --cc=jsubuntuxp@disroot.org \
    --cc=liliana.prikler@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).