summaryrefslogtreecommitdiff
path: root/gnu
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
parent6be4c3feb16faa234a5073a342e340b377671dfa (diff)
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')
-rw-r--r--gnu/local.mk1
-rw-r--r--gnu/packages/emulators.scm52
-rw-r--r--gnu/packages/patches/retroarch-unbundle-spirv-cross.patch92
3 files changed, 142 insertions, 3 deletions
diff --git a/gnu/local.mk b/gnu/local.mk
index b7a432cc1c2..8e9cccd1886 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -2083,6 +2083,7 @@ dist_patch_DATA = \
2083 %D%/packages/patches/raptor2-heap-overflow.patch \ 2083 %D%/packages/patches/raptor2-heap-overflow.patch \
2084 %D%/packages/patches/ratpoints-sturm_and_rp_private.patch \ 2084 %D%/packages/patches/ratpoints-sturm_and_rp_private.patch \
2085 %D%/packages/patches/ratpoison-shell.patch \ 2085 %D%/packages/patches/ratpoison-shell.patch \
2086 %D%/packages/patches/retroarch-unbundle-spirv-cross.patch \
2086 %D%/packages/patches/rct-add-missing-headers.patch \ 2087 %D%/packages/patches/rct-add-missing-headers.patch \
2087 %D%/packages/patches/readline-link-ncurses.patch \ 2088 %D%/packages/patches/readline-link-ncurses.patch \
2088 %D%/packages/patches/readline-6.2-CVE-2014-2524.patch \ 2089 %D%/packages/patches/readline-6.2-CVE-2014-2524.patch \
diff --git a/gnu/packages/emulators.scm b/gnu/packages/emulators.scm
index d984b7d5293..35a7e845d34 100644
--- a/gnu/packages/emulators.scm
+++ b/gnu/packages/emulators.scm
@@ -1587,9 +1587,38 @@ physical device and the RetroPad virtual controller.")
1587 (uri (git-reference 1587 (uri (git-reference
1588 (url "https://github.com/libretro/RetroArch") 1588 (url "https://github.com/libretro/RetroArch")
1589 (commit (string-append "v" version)))) 1589 (commit (string-append "v" version))))
1590 (snippet
1591 #~(begin
1592 (use-modules (guix build utils)
1593 (ice-9 ftw)
1594 (srfi srfi-26))
1595 ;; XXX: 'delete-all-but' is copied from the turbovnc package.
1596 (define (delete-all-but directory . preserve)
1597 (define (directory? x)
1598 (and=> (stat x #f)
1599 (compose (cut eq? 'directory <>) stat:type)))
1600 (with-directory-excursion directory
1601 (let* ((pred
1602 (negate (cut member <> (append '("." "..") preserve))))
1603 (items (scandir "." pred)))
1604 (for-each (lambda (item)
1605 (if (directory? item)
1606 (delete-file-recursively item)
1607 (delete-file item)))
1608 items))))
1609 ;; Remove as much bundled sources as possible, shaving off about
1610 ;; 65 MiB.
1611 (delete-all-but "deps"
1612 "feralgamemode" ;used in platform_unix.c
1613 "mbedtls" ;further refined below
1614 "yxml") ;used in rxml.c
1615 ;; This is an old root certificate used in net_socket_ssl_mbed.c,
1616 ;; not actually from mbedtls.
1617 (delete-all-but "deps/mbedtls" "cacert.h")))
1590 (file-name (git-file-name name version)) 1618 (file-name (git-file-name name version))
1591 (sha256 1619 (sha256
1592 (base32 "15nh4y4vpf4n1ryhiy4fwvzn5xz5idzfzn9fsi5v9hzp25vbjmrm")))) 1620 (base32 "15nh4y4vpf4n1ryhiy4fwvzn5xz5idzfzn9fsi5v9hzp25vbjmrm"))
1621 (patches (search-patches "retroarch-unbundle-spirv-cross.patch"))))
1593 (build-system gnu-build-system) 1622 (build-system gnu-build-system)
1594 (arguments 1623 (arguments
1595 (list 1624 (list
@@ -1626,7 +1655,20 @@ physical device and the RetroPad virtual controller.")
1626 "--disable-builtinbearssl" 1655 "--disable-builtinbearssl"
1627 "--disable-builtinzlib" 1656 "--disable-builtinzlib"
1628 "--disable-builtinflac" 1657 "--disable-builtinflac"
1629 "--disable-builtinglslang")))))) 1658 "--disable-builtinglslang"
1659 "--disable-builtinspirv_cross"
1660 ;; These are disabled to avoid requiring the bundled
1661 ;; dependencies.
1662 "--disable-7zip"
1663 "--disable-cheevos"
1664 "--disable-crtswitchres"
1665 "--disable-discord"
1666 "--disable-dr_mp3"
1667 "--disable-ibxm"
1668 "--disable-stb_font"
1669 "--disable-stb_image"
1670 "--disable-stb_vorbis"
1671 "--disable-xdelta"))))))
1630 (inputs 1672 (inputs
1631 (list alsa-lib 1673 (list alsa-lib
1632 eudev 1674 eudev
@@ -1648,6 +1690,7 @@ physical device and the RetroPad virtual controller.")
1648 python 1690 python
1649 qtbase-5 1691 qtbase-5
1650 sdl2 1692 sdl2
1693 spirv-cross
1651 spirv-headers 1694 spirv-headers
1652 spirv-tools 1695 spirv-tools
1653 v4l-utils 1696 v4l-utils
@@ -1669,7 +1712,10 @@ the easy creation of emulators, games and multimedia applications that can plug
1669straight into any libretro-compatible frontend. RetroArch is the official 1712straight into any libretro-compatible frontend. RetroArch is the official
1670reference frontend for the libretro API, currently used by most as a modular 1713reference frontend for the libretro API, currently used by most as a modular
1671multi-system game/emulator system.") 1714multi-system game/emulator system.")
1672 (license license:gpl3+))) 1715 (license (list license:gpl3+ ;for RetroArch itself
1716 license:asl2.0 ;SPIRV-Cross
1717 license:expat ;yxml
1718 license:bsd-3)))) ;feragamemode
1673 1719
1674(define-public wasm4 1720(define-public wasm4
1675 (package 1721 (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 00000000000..dd39fab5380
--- /dev/null
+++ b/gnu/packages/patches/retroarch-unbundle-spirv-cross.patch
@@ -0,0 +1,92 @@
1Upstream-status: https://github.com/libretro/RetroArch/issues/17079
2
3diff --git a/Makefile.common b/Makefile.common
4index 8ba76cf6c7..e9e8b8a643 100644
5--- a/Makefile.common
6+++ b/Makefile.common
7@@ -1869,6 +1869,7 @@ endif
8
9 ifeq ($(HAVE_SPIRV_CROSS), 1)
10 DEFINES += -DHAVE_SPIRV_CROSS
11+ifeq ($(HAVE_BUILTINSPIRV_CROSS), 1)
12 INCLUDE_DIRS += -I$(DEPS_DIR)/SPIRV-Cross
13 OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_cross.o
14 OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_cfg.o
15@@ -1877,6 +1878,13 @@ ifeq ($(HAVE_SPIRV_CROSS), 1)
16 OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_msl.o
17 OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_parser.o
18 OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_cross_parsed_ir.o
19+else
20+ CXXFLAGS += $(SPIRV_CROSS_CFLAGS)
21+ LIBS += -lspirv-cross-core \
22+ -lspirv-cross-glsl \
23+ -lspirv-cross-reflect \
24+ -lspirv-cross-msl
25+endif
26 endif
27
28 ifeq ($(WANT_WGL), 1)
29diff --git a/qb/config.libs.sh b/qb/config.libs.sh
30index 2daa6b5e45..649a62690d 100644
31--- a/qb/config.libs.sh
32+++ b/qb/config.libs.sh
33@@ -32,7 +32,10 @@ CLIB=-lc
34 PTHREADLIB=-lpthread
35 SOCKETLIB=-lc
36 SOCKETHEADER=
37-INCLUDES='usr/include usr/local/include'
38+TR='tr'
39+INCLUDES="$(echo $C_INCLUDE_PATH | $TR ':' ' ') \
40+$(echo $CPLUS_INCLUDE_PATH | $TR ':' ' ') \
41+usr/include usr/local/include"
42 SORT='sort'
43 EXTRA_GL_LIBS=''
44 VC_PREFIX=''
45@@ -625,6 +628,7 @@ check_enabled CXX GLSLANG glslang 'The C++ compiler is' false
46 check_enabled CXX SPIRV_CROSS SPIRV-Cross 'The C++ compiler is' false
47
48 check_enabled GLSLANG BUILTINGLSLANG 'builtin glslang' 'glslang is' true
49+check_enabled SPIRV_CROSS BUILTINSPIRV_CROSS 'builtin spirv-cross' 'spirv-cross is' true
50
51 if [ "$HAVE_GLSLANG" != no ]; then
52 check_header cxx GLSLANG \
53@@ -657,6 +661,27 @@ if [ "$HAVE_GLSLANG" != no ]; then
54 fi
55 fi
56
57+if [ "$HAVE_SPIRV_CROSS" != no ]; then
58+ check_lib cxx SPIRV_CROSS -lspirv-cross-core '' '' 'spirv_cross.hpp' 'spirv_cross'
59+ check_lib cxx SPIRV_CROSS_GLSL -lspirv-cross-glsl
60+ check_lib cxx SPIRV_CROSS_MSL -lspirv-cross-msl
61+ check_lib cxx SPIRV_CROSS_REFLECT -lspirv-cross-reflect
62+ if [ "$HAVE_SPIRV_CROSS" = no ] ||
63+ [ "$HAVE_SPIRV_CROSS_GLSL" = no ] ||
64+ [ "$HAVE_SPIRV_CROSS_MSL" = no ] ||
65+ [ "$HAVE_SPIRV_CROSS_REFLECT" = no ]; then
66+ if [ "$HAVE_BUILTINSPIRV_CROSS" != yes ]; then
67+ die : "Notice: System spirv-cross libraries not found, \
68+disabling spirv-cross support"
69+ HAVE_SPIRV_CROSS=no
70+ else
71+ HAVE_SPIRV_CROSS=yes
72+ fi
73+ else
74+ HAVE_SPIRV_CROSS=yes
75+ fi
76+fi
77+
78 if [ "$HAVE_CRTSWITCHRES" != no ]; then
79 if [ "$HAVE_CXX11" = 'no' ]; then
80 HAVE_CRTSWITCHRES=no
81diff --git a/qb/config.params.sh b/qb/config.params.sh
82index 1f1ea15637..a1653cb3cf 100644
83--- a/qb/config.params.sh
84+++ b/qb/config.params.sh
85@@ -191,6 +191,7 @@ C89_GLSLANG=no
86 HAVE_BUILTINGLSLANG=auto # Bake in glslang support
87 C89_BUILTINGLSLANG=no
88 HAVE_SPIRV_CROSS=auto # SPIRV-Cross support (requires C++11)
89+HAVE_BUILTINSPIRV_CROSS=auto # Use bundled SPIRV-Cross source
90 C89_SPIRV_CROSS=no
91 HAVE_METAL=no # Metal support (macOS-only)
92 C89_METAL=no