unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: 73754@debbugs.gnu.org
Cc: "Maxim Cournoyer" <maxim.cournoyer@gmail.com>,
	"Maxim Cournoyer" <maxim.cournoyer@gmail.com>,
	"Adam Faiz" <adam.faiz@disroot.org>,
	"Liliana Marie Prikler" <liliana.prikler@gmail.com>,
	宋文武 <iyzsong@envs.net>
Subject: [bug#73754] [PATCH 5/5] gnu: jg-bsnes: Unbundle SameBoy.
Date: Sat, 12 Oct 2024 13:28:14 +0900	[thread overview]
Message-ID: <cb93e8ce73ea21c6764d15e85744b0732bc11d87.1728684335.git.maxim.cournoyer@gmail.com> (raw)
In-Reply-To: <cover.1728684335.git.maxim.cournoyer@gmail.com>

* gnu/packages/emulators.scm (jg-bsnes) [source]: Delete deps/gb in snippet.
<patches>: Apply unbundling patch.
[make-flags]: Add USE_VENDORED_SAMEBOY=0 flag.
[inputs]: Add sameboy.
* gnu/packages/patches/jg-bsnes-unbundle-sameboy.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it.

Change-Id: I0ce850b366663d88d66becb9121b13c48d4091a3
---
 gnu/local.mk                                  |   1 +
 gnu/packages/emulators.scm                    |   9 +-
 .../patches/jg-bsnes-unbundle-sameboy.patch   | 101 ++++++++++++++++++
 3 files changed, 108 insertions(+), 3 deletions(-)
 create mode 100644 gnu/packages/patches/jg-bsnes-unbundle-sameboy.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 544cf36f04..1eb3c66f85 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1592,6 +1592,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/jfsutils-add-sysmacros.patch		\
   %D%/packages/patches/jfsutils-gcc-compat.patch		\
   %D%/packages/patches/jfsutils-include-systypes.patch		\
+  %D%/packages/patches/jg-bsnes-unbundle-sameboy.patch		\
   %D%/packages/patches/john-the-ripper-jumbo-with-gcc-11.patch	\
   %D%/packages/patches/json-c-0.13-CVE-2020-12762.patch		\
   %D%/packages/patches/json-c-0.12-CVE-2020-12762.patch		\
diff --git a/gnu/packages/emulators.scm b/gnu/packages/emulators.scm
index 3df1b94506..3d4b833c11 100644
--- a/gnu/packages/emulators.scm
+++ b/gnu/packages/emulators.scm
@@ -3291,10 +3291,12 @@ (define-public jg-bsnes
               ;; - snes_spc (also modified by this project)
               (snippet '(begin
                           (use-modules (guix build utils))
+                          (delete-file-recursively "deps/gb")
                           (delete-file-recursively "deps/libsamplerate")))
               (sha256
                (base32
-                "0z1ka4si8vcb0j6ih087cni18vpgfd3qnaw24awycxz23xc0jkdv"))))
+                "0z1ka4si8vcb0j6ih087cni18vpgfd3qnaw24awycxz23xc0jkdv"))
+              (patches (search-patches "jg-bsnes-unbundle-sameboy.patch"))))
     (build-system gnu-build-system)
     (arguments
      (list #:tests? #f                  ;no test suite
@@ -3302,11 +3304,12 @@ (define-public jg-bsnes
            #~(list (string-append "AR=" #$(ar-for-target))
                    (string-append "CC=" #$(cc-for-target))
                    (string-append "CXX=" #$(cxx-for-target))
-                   (string-append "PREFIX=" #$output))
+                   (string-append "PREFIX=" #$output)
+                   (string-append "USE_EXTERNAL_SAMEBOY=1"))
            #:phases #~(modify-phases %standard-phases
                         (delete 'configure)))) ;no configure script
     (native-inputs (list jg-api pkg-config))
-    (inputs (list libsamplerate))
+    (inputs (list libsamplerate sameboy))
     (home-page "https://gitlab.com/jgemu/bsnes")
     (synopsis "Jolly Good Fork of bsnes")
     (description "@code{bsnes-jg} is a cycle accurate emulator for the Super
diff --git a/gnu/packages/patches/jg-bsnes-unbundle-sameboy.patch b/gnu/packages/patches/jg-bsnes-unbundle-sameboy.patch
new file mode 100644
index 0000000000..1047dd4819
--- /dev/null
+++ b/gnu/packages/patches/jg-bsnes-unbundle-sameboy.patch
@@ -0,0 +1,101 @@
+Upstream-status: https://gitlab.com/jgemu/bsnes/-/merge_requests/429
+
+diff --git a/Makefile b/Makefile
+index 7371ff4..a4a8457 100644
+--- a/Makefile
++++ b/Makefile
+@@ -37,6 +37,9 @@ MKDIRS := deps/byuuML \
+ 	src/expansion \
+ 	src/processor
+ 
++# Set to 1 to use a system-provided SameBoy shared library.
++USE_EXTERNAL_SAMEBOY := 0
++
+ # Global symbols
+ # TODO: Darwin export files expect mangled symbols for C++
+ SYMBOLS :=
+@@ -61,6 +64,9 @@ CPPFLAGS_GB := -DGB_INTERNAL -DGB_DISABLE_CHEATS -DGB_DISABLE_DEBUGGER \
+ 	-D_GNU_SOURCE -DGB_VERSION=\"0.16.6\"
+ 
+ INCLUDES += $(CFLAGS_SAMPLERATE) -I$(DEPDIR)
++ifeq ($(USE_EXTERNAL_SAMEBOY), 0)
++INCLUDES += -I$(DEPDIR)/gb
++endif
+ LIBS += $(LIBS_SAMPLERATE)
+ 
+ EXT := cpp
+@@ -81,7 +87,13 @@ WARNINGS_CO := $(WARNINGS_MIN) -Wmissing-prototypes
+ WARNINGS_ICD := $(WARNINGS_CXX)
+ WARNINGS_GB := -Wall -Wno-missing-braces -Wno-multichar -Wno-unused-result
+ 
+-CSRCS := deps/gb/apu.c \
++CSRCS := \
++	deps/libco/libco.c \
++	deps/snes_spc/spc_dsp.c
++
++ifeq ($(USE_EXTERNAL_SAMEBOY), 0)
++CSRCS += \
++	deps/gb/apu.c \
+ 	deps/gb/camera.c \
+ 	deps/gb/display.c \
+ 	deps/gb/gb.c \
+@@ -96,9 +108,16 @@ CSRCS := deps/gb/apu.c \
+ 	deps/gb/sgb.c \
+ 	deps/gb/sm83_cpu.c \
+ 	deps/gb/timing.c \
+-	deps/gb/workboy.c \
+-	deps/libco/libco.c \
+-	deps/snes_spc/spc_dsp.c
++	deps/gb/workboy.c
++else
++CFLAGS_SAMEBOY = $(shell $(PKG_CONFIG) --cflags sameboy || echo fail)
++LIBS_SAMEBOY = $(shell $(PKG_CONFIG) --libs sameboy || echo fail)
++ifeq ($(CFLAGS_SAMEBOY)$(LIBS_SAMEBOY),failfail)
++$(error "pkg-config failure; CFLAGS_SAMEBOY and LIBS_SAMEBOY missing")
++endif
++INCLUDES += $(CFLAGS_SAMEBOY)
++LIBS += $(LIBS_SAMEBOY)
++endif
+ 
+ CXXSRCS := deps/byuuML/byuuML.cpp \
+ 	src/audio.cpp \
+@@ -243,8 +262,11 @@ install-data: all
+ 
+ install-docs::
+ 	cp $(DEPDIR)/byuuML/LICENSE $(DESTDIR)$(DOCDIR)/LICENSE-byuuML
+-	cp $(DEPDIR)/gb/LICENSE $(DESTDIR)$(DOCDIR)/LICENSE-gb
+ 	cp $(DEPDIR)/libco/LICENSE $(DESTDIR)$(DOCDIR)/LICENSE-libco
+ 	cp $(DEPDIR)/snes_spc/LICENSE $(DESTDIR)$(DOCDIR)/LICENSE-spc
++ifeq ($(USE_EXTERNAL_SAMEBOY), 0)
++install-docs::
++	cp $(DEPDIR)/gb/LICENSE $(DESTDIR)$(DOCDIR)/LICENSE-gb
++endif
+ 
+ include $(SOURCEDIR)/mk/rules.mk
+diff --git a/README b/README
+index 3db6823..910c8d5 100644
+--- a/README
++++ b/README
+@@ -30,7 +30,8 @@ Options:
+   ENABLE_HTML - Set to a non-zero value to generate the html documentation.
+   ENABLE_STATIC - Set to a non-zero value to build a static archive.
+   ENABLE_STATIC_JG - Set to a non-zero value to build a static JG archive.
+-  USE_VENDORED_SAMPLERATE - Set non-zero to use vendored libsamplerate
++  USE_VENDORED_SAMPLERATE - Set non-zero to use vendored libsamplerate.
++  USE_EXTERNAL_SAMEBOY - Set non-zero to use system-provided sameboy.
+ 
+ Linux:
+   make
+diff --git a/src/coprocessor/icd.cpp b/src/coprocessor/icd.cpp
+index 2b0fb96..066b63e 100644
+--- a/src/coprocessor/icd.cpp
++++ b/src/coprocessor/icd.cpp
+@@ -28,7 +28,7 @@
+ #include "icd.hpp"
+ 
+ extern "C" {
+-  #include <gb/gb.h>
++  #include <gb.h>
+ }
+ 
+ //warning: the size of this object will be too large due to C++ size rules differing from C rules.
-- 
2.46.0





      parent reply	other threads:[~2024-10-12  4:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-11 22:07 [bug#73754] [PATCH games-team 0/5] Unbundle SameBoy from jg-bsnes Maxim Cournoyer
2024-10-12  4:28 ` [bug#73754] [PATCH 1/5] gnu: sameboy: Update to 0.16.7 Maxim Cournoyer
2024-10-12  4:28 ` [bug#73754] [PATCH 2/5] gnu: sameboy: Use gexps Maxim Cournoyer
2024-10-12  4:28 ` [bug#73754] [PATCH 3/5] gnu: Add cppp Maxim Cournoyer
2024-10-12  4:28 ` [bug#73754] [PATCH 4/5] gnu: sameboy: Install shared library Maxim Cournoyer
2024-10-12  4:28 ` Maxim Cournoyer [this message]

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=cb93e8ce73ea21c6764d15e85744b0732bc11d87.1728684335.git.maxim.cournoyer@gmail.com \
    --to=maxim.cournoyer@gmail.com \
    --cc=73754@debbugs.gnu.org \
    --cc=adam.faiz@disroot.org \
    --cc=iyzsong@envs.net \
    --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).