aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2024-09-27 22:20:27 +0900
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2024-10-07 01:20:21 +0900
commit9875fbfeba8ce0ad7916c03365eded648bbb0275 (patch)
treecb37f841eafa5499649d1663b66c35a502cb7bd5 /gnu/packages
parent6be4c3feb16faa234a5073a342e340b377671dfa (diff)
downloadguix-9875fbfeba8ce0ad7916c03365eded648bbb0275.tar
guix-9875fbfeba8ce0ad7916c03365eded648bbb0275.tar.gz
gnu: retroarch: Reduce bundled libraries to a minimum.
* gnu/packages/emulators.scm (retroarch) [source]: Add snippet removing most bundled sources. Apply patch to allow using system SPIRV-Cross. [phases] <configure>: Add --disable-builtinspirv_cross. Disable non-core features making use of bundled libraries (7zip, cheevos crtswitchres, discord, dr_mp3, ixbm, stb_font, stb_image, stb_vorbis and xdelta). [inputs]: Add spirv-cross. [license]: Add licenses of bundled sources. * gnu/packages/patches/retroarch-unbundle-spirv-cross.patch: New file. Change-Id: I824391424bf0fa2ec3888f02535b94dea3021378
Diffstat (limited to 'gnu/packages')
-rw-r--r--gnu/packages/emulators.scm52
-rw-r--r--gnu/packages/patches/retroarch-unbundle-spirv-cross.patch92
2 files changed, 141 insertions, 3 deletions
diff --git a/gnu/packages/emulators.scm b/gnu/packages/emulators.scm
index d984b7d529..35a7e845d3 100644
--- a/gnu/packages/emulators.scm
+++ b/gnu/packages/emulators.scm
@@ -1587,9 +1587,38 @@ physical device and the RetroPad virtual controller.")
(uri (git-reference
(url "https://github.com/libretro/RetroArch")
(commit (string-append "v" version))))
+ (snippet
+ #~(begin
+ (use-modules (guix build utils)
+ (ice-9 ftw)
+ (srfi srfi-26))
+ ;; XXX: 'delete-all-but' is copied from the turbovnc package.
+ (define (delete-all-but directory . preserve)
+ (define (directory? x)
+ (and=> (stat x #f)
+ (compose (cut eq? 'directory <>) stat:type)))
+ (with-directory-excursion directory
+ (let* ((pred
+ (negate (cut member <> (append '("." "..") preserve))))
+ (items (scandir "." pred)))
+ (for-each (lambda (item)
+ (if (directory? item)
+ (delete-file-recursively item)
+ (delete-file item)))
+ items))))
+ ;; Remove as much bundled sources as possible, shaving off about
+ ;; 65 MiB.
+ (delete-all-but "deps"
+ "feralgamemode" ;used in platform_unix.c
+ "mbedtls" ;further refined below
+ "yxml") ;used in rxml.c
+ ;; This is an old root certificate used in net_socket_ssl_mbed.c,
+ ;; not actually from mbedtls.
+ (delete-all-but "deps/mbedtls" "cacert.h")))
(file-name (git-file-name name version))
(sha256
- (base32 "15nh4y4vpf4n1ryhiy4fwvzn5xz5idzfzn9fsi5v9hzp25vbjmrm"))))
+ (base32 "15nh4y4vpf4n1ryhiy4fwvzn5xz5idzfzn9fsi5v9hzp25vbjmrm"))
+ (patches (search-patches "retroarch-unbundle-spirv-cross.patch"))))
(build-system gnu-build-system)
(arguments
(list
@@ -1626,7 +1655,20 @@ physical device and the RetroPad virtual controller.")
"--disable-builtinbearssl"
"--disable-builtinzlib"
"--disable-builtinflac"
- "--disable-builtinglslang"))))))
+ "--disable-builtinglslang"
+ "--disable-builtinspirv_cross"
+ ;; These are disabled to avoid requiring the bundled
+ ;; dependencies.
+ "--disable-7zip"
+ "--disable-cheevos"
+ "--disable-crtswitchres"
+ "--disable-discord"
+ "--disable-dr_mp3"
+ "--disable-ibxm"
+ "--disable-stb_font"
+ "--disable-stb_image"
+ "--disable-stb_vorbis"
+ "--disable-xdelta"))))))
(inputs
(list alsa-lib
eudev
@@ -1648,6 +1690,7 @@ physical device and the RetroPad virtual controller.")
python
qtbase-5
sdl2
+ spirv-cross
spirv-headers
spirv-tools
v4l-utils
@@ -1669,7 +1712,10 @@ the easy creation of emulators, games and multimedia applications that can plug
straight into any libretro-compatible frontend. RetroArch is the official
reference frontend for the libretro API, currently used by most as a modular
multi-system game/emulator system.")
- (license license:gpl3+)))
+ (license (list license:gpl3+ ;for RetroArch itself
+ license:asl2.0 ;SPIRV-Cross
+ license:expat ;yxml
+ license:bsd-3)))) ;feragamemode
(define-public wasm4
(package
diff --git a/gnu/packages/patches/retroarch-unbundle-spirv-cross.patch b/gnu/packages/patches/retroarch-unbundle-spirv-cross.patch
new file mode 100644
index 0000000000..dd39fab538
--- /dev/null
+++ b/gnu/packages/patches/retroarch-unbundle-spirv-cross.patch
@@ -0,0 +1,92 @@
+Upstream-status: https://github.com/libretro/RetroArch/issues/17079
+
+diff --git a/Makefile.common b/Makefile.common
+index 8ba76cf6c7..e9e8b8a643 100644
+--- a/Makefile.common
++++ b/Makefile.common
+@@ -1869,6 +1869,7 @@ endif
+
+ ifeq ($(HAVE_SPIRV_CROSS), 1)
+ DEFINES += -DHAVE_SPIRV_CROSS
++ifeq ($(HAVE_BUILTINSPIRV_CROSS), 1)
+ INCLUDE_DIRS += -I$(DEPS_DIR)/SPIRV-Cross
+ OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_cross.o
+ OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_cfg.o
+@@ -1877,6 +1878,13 @@ ifeq ($(HAVE_SPIRV_CROSS), 1)
+ OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_msl.o
+ OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_parser.o
+ OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_cross_parsed_ir.o
++else
++ CXXFLAGS += $(SPIRV_CROSS_CFLAGS)
++ LIBS += -lspirv-cross-core \
++ -lspirv-cross-glsl \
++ -lspirv-cross-reflect \
++ -lspirv-cross-msl
++endif
+ endif
+
+ ifeq ($(WANT_WGL), 1)
+diff --git a/qb/config.libs.sh b/qb/config.libs.sh
+index 2daa6b5e45..649a62690d 100644
+--- a/qb/config.libs.sh
++++ b/qb/config.libs.sh
+@@ -32,7 +32,10 @@ CLIB=-lc
+ PTHREADLIB=-lpthread
+ SOCKETLIB=-lc
+ SOCKETHEADER=
+-INCLUDES='usr/include usr/local/include'
++TR='tr'
++INCLUDES="$(echo $C_INCLUDE_PATH | $TR ':' ' ') \
++$(echo $CPLUS_INCLUDE_PATH | $TR ':' ' ') \
++usr/include usr/local/include"
+ SORT='sort'
+ EXTRA_GL_LIBS=''
+ VC_PREFIX=''
+@@ -625,6 +628,7 @@ check_enabled CXX GLSLANG glslang 'The C++ compiler is' false
+ check_enabled CXX SPIRV_CROSS SPIRV-Cross 'The C++ compiler is' false
+
+ check_enabled GLSLANG BUILTINGLSLANG 'builtin glslang' 'glslang is' true
++check_enabled SPIRV_CROSS BUILTINSPIRV_CROSS 'builtin spirv-cross' 'spirv-cross is' true
+
+ if [ "$HAVE_GLSLANG" != no ]; then
+ check_header cxx GLSLANG \
+@@ -657,6 +661,27 @@ if [ "$HAVE_GLSLANG" != no ]; then
+ fi
+ fi
+
++if [ "$HAVE_SPIRV_CROSS" != no ]; then
++ check_lib cxx SPIRV_CROSS -lspirv-cross-core '' '' 'spirv_cross.hpp' 'spirv_cross'
++ check_lib cxx SPIRV_CROSS_GLSL -lspirv-cross-glsl
++ check_lib cxx SPIRV_CROSS_MSL -lspirv-cross-msl
++ check_lib cxx SPIRV_CROSS_REFLECT -lspirv-cross-reflect
++ if [ "$HAVE_SPIRV_CROSS" = no ] ||
++ [ "$HAVE_SPIRV_CROSS_GLSL" = no ] ||
++ [ "$HAVE_SPIRV_CROSS_MSL" = no ] ||
++ [ "$HAVE_SPIRV_CROSS_REFLECT" = no ]; then
++ if [ "$HAVE_BUILTINSPIRV_CROSS" != yes ]; then
++ die : "Notice: System spirv-cross libraries not found, \
++disabling spirv-cross support"
++ HAVE_SPIRV_CROSS=no
++ else
++ HAVE_SPIRV_CROSS=yes
++ fi
++ else
++ HAVE_SPIRV_CROSS=yes
++ fi
++fi
++
+ if [ "$HAVE_CRTSWITCHRES" != no ]; then
+ if [ "$HAVE_CXX11" = 'no' ]; then
+ HAVE_CRTSWITCHRES=no
+diff --git a/qb/config.params.sh b/qb/config.params.sh
+index 1f1ea15637..a1653cb3cf 100644
+--- a/qb/config.params.sh
++++ b/qb/config.params.sh
+@@ -191,6 +191,7 @@ C89_GLSLANG=no
+ HAVE_BUILTINGLSLANG=auto # Bake in glslang support
+ C89_BUILTINGLSLANG=no
+ HAVE_SPIRV_CROSS=auto # SPIRV-Cross support (requires C++11)
++HAVE_BUILTINSPIRV_CROSS=auto # Use bundled SPIRV-Cross source
+ C89_SPIRV_CROSS=no
+ HAVE_METAL=no # Metal support (macOS-only)
+ C89_METAL=no