GNU bug report logs - #69638
[PATCH] gnu: sdl: Replace with sdl12-compat.

Previous Next

Package: guix-patches;

Reported by: iyzsong <at> envs.net

Date: Fri, 8 Mar 2024 14:41:01 UTC

Severity: normal

Tags: patch

Done: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 69638 in the body.
You can then email your comments to 69638 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#69638; Package guix-patches. (Fri, 08 Mar 2024 14:41:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to iyzsong <at> envs.net:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Fri, 08 Mar 2024 14:41:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: iyzsong <at> envs.net
To: guix-patches <at> gnu.org
Cc: 宋文武 <iyzsong <at> member.fsf.org>
Subject: [PATCH] gnu: sdl: Replace with sdl12-compat.
Date: Fri,  8 Mar 2024 22:40:00 +0800
From: 宋文武 <iyzsong <at> member.fsf.org>

* gnu/packages/sdl.scm (sdl12-compat): New package.
(sdl): Remove package, defined as sdl12-compat.
(sdl2): Don't inherit from sdl.
(propagated-inputs-with-sdl2): Add case for sdl12-compat.
(sdl-union): Hardcode version to "1.2.15" to avoid rebuilds.

Change-Id: I843d349b3d69164cc640c7db204464a51819a0df
---
 gnu/packages/sdl.scm | 165 ++++++++++++++++++++++++-------------------
 1 file changed, 94 insertions(+), 71 deletions(-)

diff --git a/gnu/packages/sdl.scm b/gnu/packages/sdl.scm
index 3a4aafcaa7..8646e505c4 100644
--- a/gnu/packages/sdl.scm
+++ b/gnu/packages/sdl.scm
@@ -43,6 +43,7 @@ (define-module (gnu packages sdl)
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module (guix utils)
+  #:use-module (guix build-system cmake)
   #:use-module (guix build-system copy)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system trivial)
@@ -67,35 +68,48 @@ (define-module (gnu packages sdl)
   #:use-module (gnu packages xorg)
   #:export (sdl-union))
 
-(define-public sdl
+(define-public sdl2
   (package
-    (name "sdl")
-    (version "1.2.15")
+    (name "sdl2")
+    (version "2.28.5")
     (source (origin
-             (method url-fetch)
-             (uri
-              (string-append "https://libsdl.org/release/SDL-"
-                             version ".tar.gz"))
-             (sha256
-              (base32
-               "005d993xcac8236fpvd1iawkz4wqjybkpn8dbwaliqz5jfkidlyn"))
-             (patches (search-patches "sdl-libx11-1.6.patch"))))
+              (method url-fetch)
+              (uri
+               (string-append "https://libsdl.org/release/SDL2-"
+                              version ".tar.gz"))
+              (sha256
+               (base32
+                "1r36cspzv6h8abiqbbkrgm17g975p9wiziir2xabj3721dyv6b1k"))))
     (build-system gnu-build-system)
+    ;; TODO: Remove 'append' and 'cons*', was used to avoid rebuilds.
     (arguments
-     '(;; Explicitly link against shared libraries instead of dlopening them.
-       ;; For X11, ALSA, and PulseAudio.
-       ;; OpenGL library is still dlopened at runtime.
-       #:configure-flags '("--disable-alsa-shared"
-                           "--disable-pulseaudio-shared"
-                           "--disable-x11-shared"
-                           ;; Explicitly link with mesa.
-                           ;; This add mesa to libsdl's RUNPATH, to make dlopen
-                           ;; finding the libGL from mesa at runtime.
-                           "LDFLAGS=-lGL")
-
-       #:make-flags '("V=1")            ;build verbosely
-
-       #:tests? #f)) ; no check target
+     (list
+      #:tests? #f                  ;no check target
+      ;; Explicitly link against shared libraries instead of dlopening them.
+      ;; For X11, ALSA, and PulseAudio.
+      ;; OpenGL library is still dlopened at runtime.
+      #:configure-flags
+      #~(append
+         '("--disable-wayland-shared"
+           "--enable-video-kmsdrm"
+           "--disable-kmsdrm-shared")
+         '("--disable-alsa-shared"
+           "--disable-pulseaudio-shared"
+           "--disable-x11-shared"
+           ;; Explicitly link with mesa.
+           ;; This add mesa to libsdl's RUNPATH, to make dlopen
+           ;; finding the libGL from mesa at runtime.
+           "LDFLAGS=-lGL"))
+      #:make-flags
+      #~(cons*
+         ;; SDL dlopens libudev and libvulkan, so make sure they are in
+         ;; rpath. This overrides the LDFLAG set in sdl’s configure-flags,
+         ;; which isn’t necessary as sdl2 includes Mesa by default.
+         (string-append "LDFLAGS=-Wl,-rpath,"
+                        #$(this-package-input "eudev") "/lib"
+                        ",-rpath,"
+                        #$(this-package-input "vulkan-loader") "/lib")
+         '("V=1"))))                  ;build verbosely
     (propagated-inputs
      ;; SDL headers include X11 headers.
      (list libx11
@@ -105,60 +119,67 @@ (define-public sdl
            ;; change in pkg-config.
            mesa))
     (native-inputs (list pkg-config))
-    (inputs (list libxrandr glu alsa-lib pulseaudio))
+    (inputs
+     ;; SDL2 needs to be built with ibus support otherwise some systems
+     ;; experience a bug where input events are doubled.
+     ;;
+     ;; For more information, see: https://dev.solus-project.com/T1721
+     (list
+      libxrandr
+      glu
+      alsa-lib
+      pulseaudio
+      dbus
+      eudev                             ;for discovering input devices
+      glib
+      ibus-minimal
+      libxkbcommon
+      libxcursor                        ;enables X11 cursor support
+      vulkan-loader
+      wayland
+      wayland-protocols))
     (outputs '("out" "debug"))
     (synopsis "Cross platform game development library")
-    (description "Simple DirectMedia Layer is a cross-platform development
-library designed to provide low level access to audio, keyboard, mouse,
-joystick, and graphics hardware.")
+    (description
+     "Simple DirectMedia Layer is a cross-platform development library designed to
+provide low level access to audio, keyboard, mouse, joystick, and graphics
+hardware.")
     (home-page "https://libsdl.org/")
-    (license license:lgpl2.1)))
+    (license license:bsd-3)))
 
-(define-public sdl2
+(define-public sdl12-compat
   (package
-    (inherit sdl)
-    (name "sdl2")
-    (version "2.28.5")
+    (name "sdl12-compat")
+    (version "1.2.68")
     (source (origin
-              (method url-fetch)
-              (uri
-               (string-append "https://libsdl.org/release/SDL2-"
-                              version ".tar.gz"))
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/libsdl-org/sdl12-compat")
+                    (commit (string-append "release-" version))))
+              (file-name (git-file-name name version))
               (sha256
                (base32
-                "1r36cspzv6h8abiqbbkrgm17g975p9wiziir2xabj3721dyv6b1k"))))
+                "0qsjlzi1wqszi6k4pc3k9xdvzid5cx6ql8wbjw6qdapzpvf6arvz"))))
+    (build-system cmake-build-system)
     (arguments
-     (substitute-keyword-arguments (package-arguments sdl)
-       ((#:configure-flags flags)
-        #~(append '("--disable-wayland-shared" "--enable-video-kmsdrm"
-                    "--disable-kmsdrm-shared")
-                  #$flags))
-       ((#:make-flags flags ''())
-        #~(cons*
-           ;; SDL dlopens libudev and libvulkan, so make sure they are in
-           ;; rpath. This overrides the LDFLAG set in sdl’s configure-flags,
-           ;; which isn’t necessary as sdl2 includes Mesa by default.
-           (string-append "LDFLAGS=-Wl,-rpath,"
-                          #$(this-package-input "eudev") "/lib"
-                          ",-rpath,"
-                          #$(this-package-input "vulkan-loader") "/lib")
-           #$flags))))
-    (inputs
-     ;; SDL2 needs to be built with ibus support otherwise some systems
-     ;; experience a bug where input events are doubled.
-     ;;
-     ;; For more information, see: https://dev.solus-project.com/T1721
-     (modify-inputs (package-inputs sdl)
-       (append dbus
-               eudev                    ;for discovering input devices
-               glib
-               ibus-minimal
-               libxkbcommon
-               libxcursor               ;enables X11 cursor support
-               vulkan-loader
-               wayland
-               wayland-protocols)))
-    (license license:bsd-3)))
+     (list #:tests? #f                  ;no check target
+           #:configure-flags
+           ;; This add SDL2 to sdl12-compat's RUNPATH, to make dlopen finding the
+           ;; libSDL2 at runtime.
+           #~'("-DCMAKE_SHARED_LINKER_FLAGS=-lSDL2")))
+    (inputs (list sdl2))
+    (propagated-inputs (list glu))      ;required by SDL_opengl.h
+    (synopsis "Cross platform game development library")
+    (description "Simple DirectMedia Layer is a cross-platform development library
+designed to provide low level access to audio, keyboard, mouse, joystick, and
+graphics hardware.  This package is a compatibility layer; it provides a binary and
+source compatible API for programs written against SDL 1.2, but it uses SDL 2.0
+behind the scenes.")
+    (home-page "https://libsdl.org/")
+    ;; dr_mp3 code are under public domain.
+    (license (list license:zlib license:public-domain))))
+
+(define-public sdl sdl12-compat)
 
 (define-public sdl2-2.0
   (package
@@ -423,7 +444,7 @@ (define* (sdl-union #:optional (packages (list sdl sdl-gfx sdl-net sdl-ttf
 If PACKAGES are not specified, all SDL packages are used."
   (package
     (name "sdl-union")
-    (version (package-version sdl))
+    (version "1.2.15")                  ;TODO: use correct SDL version
     (source #f)
     (build-system trivial-build-system)
     (arguments
@@ -452,6 +473,8 @@ (define (propagated-inputs-with-sdl2 package)
   (map (match-lambda
          (("sdl" _)
           `("sdl2" ,sdl2))
+         (("sdl12-compat" _)
+          `("sdl2" ,sdl2))
          (other other))
        (package-propagated-inputs package)))
 

base-commit: de3f86443837b7bd6e3bad11dbaeed2550d4207c
-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#69638; Package guix-patches. (Fri, 08 Mar 2024 15:08:02 GMT) Full text and rfc822 format available.

Message #8 received at 69638 <at> debbugs.gnu.org (full text, mbox):

From: iyzsong <at> envs.net
To: 69638 <at> debbugs.gnu.org
Cc: 宋文武 <iyzsong <at> member.fsf.org>
Subject: [PATCH v2] gnu: sdl: Replace with sdl12-compat.
Date: Fri,  8 Mar 2024 23:06:48 +0800
From: 宋文武 <iyzsong <at> member.fsf.org>

* gnu/packages/sdl.scm (sdl12-compat): New package.
(sdl): Remove package, defined as sdl12-compat.
(sdl2): Don't inherit from sdl.
(propagated-inputs-with-sdl2): Add case for sdl12-compat.
(sdl-union): Hardcode version to "1.2.15" to avoid rebuilds.
* gnu/packages/patches/sdl-libx11-1.6.patch: Remove file.
* gnu/local.mk (dist_patch_DATA): Unregister it.

Change-Id: I843d349b3d69164cc640c7db204464a51819a0df
---
 gnu/local.mk                              |   1 -
 gnu/packages/patches/sdl-libx11-1.6.patch |  13 --
 gnu/packages/sdl.scm                      | 173 +++++++++++++---------
 3 files changed, 102 insertions(+), 85 deletions(-)
 delete mode 100644 gnu/packages/patches/sdl-libx11-1.6.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 16241ee441..0f76d0c771 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -2027,7 +2027,6 @@ dist_patch_DATA =						\
   %D%/packages/patches/scons-test-environment.patch		\
   %D%/packages/patches/screen-hurd-path-max.patch		\
   %D%/packages/patches/scsh-nonstring-search-path.patch	\
-  %D%/packages/patches/sdl-libx11-1.6.patch			\
   %D%/packages/patches/seed-webkit.patch			\
   %D%/packages/patches/sendgmail-accept-ignored-gsuite-flag.patch	\
   %D%/packages/patches/sendgmail-remove-domain-restriction.patch	\
diff --git a/gnu/packages/patches/sdl-libx11-1.6.patch b/gnu/packages/patches/sdl-libx11-1.6.patch
deleted file mode 100644
index 73ba9ac071..0000000000
--- a/gnu/packages/patches/sdl-libx11-1.6.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-Update _XData32 declaration in SDL_x11sym.h to match that of libx11 1.6.
-
---- SDL-1.2.15/src/video/x11/SDL_x11sym.h.~1~	2012-01-19 01:30:06.000000000 -0500
-+++ SDL-1.2.15/src/video/x11/SDL_x11sym.h	2014-12-26 00:22:36.445067694 -0500
-@@ -165,7 +165,7 @@
-  */
- #ifdef LONG64
- SDL_X11_MODULE(IO_32BIT)
--SDL_X11_SYM(int,_XData32,(Display *dpy,register long *data,unsigned len),(dpy,data,len),return)
-+SDL_X11_SYM(int,_XData32,(Display *dpy,register _Xconst long *data,unsigned len),(dpy,data,len),return)
- SDL_X11_SYM(void,_XRead32,(Display *dpy,register long *data,long len),(dpy,data,len),)
- #endif
- 
diff --git a/gnu/packages/sdl.scm b/gnu/packages/sdl.scm
index 3a4aafcaa7..3d81baf368 100644
--- a/gnu/packages/sdl.scm
+++ b/gnu/packages/sdl.scm
@@ -43,6 +43,7 @@ (define-module (gnu packages sdl)
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module (guix utils)
+  #:use-module (guix build-system cmake)
   #:use-module (guix build-system copy)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system trivial)
@@ -67,35 +68,48 @@ (define-module (gnu packages sdl)
   #:use-module (gnu packages xorg)
   #:export (sdl-union))
 
-(define-public sdl
+(define-public sdl2
   (package
-    (name "sdl")
-    (version "1.2.15")
+    (name "sdl2")
+    (version "2.28.5")
     (source (origin
-             (method url-fetch)
-             (uri
-              (string-append "https://libsdl.org/release/SDL-"
-                             version ".tar.gz"))
-             (sha256
-              (base32
-               "005d993xcac8236fpvd1iawkz4wqjybkpn8dbwaliqz5jfkidlyn"))
-             (patches (search-patches "sdl-libx11-1.6.patch"))))
+              (method url-fetch)
+              (uri
+               (string-append "https://libsdl.org/release/SDL2-"
+                              version ".tar.gz"))
+              (sha256
+               (base32
+                "1r36cspzv6h8abiqbbkrgm17g975p9wiziir2xabj3721dyv6b1k"))))
     (build-system gnu-build-system)
+    ;; TODO: Remove 'append' and 'cons*', was used to avoid rebuilds.
     (arguments
-     '(;; Explicitly link against shared libraries instead of dlopening them.
-       ;; For X11, ALSA, and PulseAudio.
-       ;; OpenGL library is still dlopened at runtime.
-       #:configure-flags '("--disable-alsa-shared"
-                           "--disable-pulseaudio-shared"
-                           "--disable-x11-shared"
-                           ;; Explicitly link with mesa.
-                           ;; This add mesa to libsdl's RUNPATH, to make dlopen
-                           ;; finding the libGL from mesa at runtime.
-                           "LDFLAGS=-lGL")
-
-       #:make-flags '("V=1")            ;build verbosely
-
-       #:tests? #f)) ; no check target
+     (list
+      #:tests? #f                  ;no check target
+      ;; Explicitly link against shared libraries instead of dlopening them.
+      ;; For X11, ALSA, and PulseAudio.
+      ;; OpenGL library is still dlopened at runtime.
+      #:configure-flags
+      #~(append
+         '("--disable-wayland-shared"
+           "--enable-video-kmsdrm"
+           "--disable-kmsdrm-shared")
+         '("--disable-alsa-shared"
+           "--disable-pulseaudio-shared"
+           "--disable-x11-shared"
+           ;; Explicitly link with mesa.
+           ;; This add mesa to libsdl's RUNPATH, to make dlopen
+           ;; finding the libGL from mesa at runtime.
+           "LDFLAGS=-lGL"))
+      #:make-flags
+      #~(cons*
+         ;; SDL dlopens libudev and libvulkan, so make sure they are in
+         ;; rpath. This overrides the LDFLAG set in sdl’s configure-flags,
+         ;; which isn’t necessary as sdl2 includes Mesa by default.
+         (string-append "LDFLAGS=-Wl,-rpath,"
+                        #$(this-package-input "eudev") "/lib"
+                        ",-rpath,"
+                        #$(this-package-input "vulkan-loader") "/lib")
+         '("V=1"))))                  ;build verbosely
     (propagated-inputs
      ;; SDL headers include X11 headers.
      (list libx11
@@ -105,60 +119,75 @@ (define-public sdl
            ;; change in pkg-config.
            mesa))
     (native-inputs (list pkg-config))
-    (inputs (list libxrandr glu alsa-lib pulseaudio))
+    (inputs
+     ;; SDL2 needs to be built with ibus support otherwise some systems
+     ;; experience a bug where input events are doubled.
+     ;;
+     ;; For more information, see: https://dev.solus-project.com/T1721
+     (list
+      libxrandr
+      glu
+      alsa-lib
+      pulseaudio
+      dbus
+      eudev                             ;for discovering input devices
+      glib
+      ibus-minimal
+      libxkbcommon
+      libxcursor                        ;enables X11 cursor support
+      vulkan-loader
+      wayland
+      wayland-protocols))
     (outputs '("out" "debug"))
     (synopsis "Cross platform game development library")
-    (description "Simple DirectMedia Layer is a cross-platform development
-library designed to provide low level access to audio, keyboard, mouse,
-joystick, and graphics hardware.")
+    (description
+     "Simple DirectMedia Layer is a cross-platform development library designed to
+provide low level access to audio, keyboard, mouse, joystick, and graphics
+hardware.")
     (home-page "https://libsdl.org/")
-    (license license:lgpl2.1)))
+    (license license:bsd-3)))
 
-(define-public sdl2
+(define-public sdl12-compat
   (package
-    (inherit sdl)
-    (name "sdl2")
-    (version "2.28.5")
+    (name "sdl12-compat")
+    (version "1.2.68")
     (source (origin
-              (method url-fetch)
-              (uri
-               (string-append "https://libsdl.org/release/SDL2-"
-                              version ".tar.gz"))
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/libsdl-org/sdl12-compat")
+                    (commit (string-append "release-" version))))
+              (file-name (git-file-name name version))
               (sha256
                (base32
-                "1r36cspzv6h8abiqbbkrgm17g975p9wiziir2xabj3721dyv6b1k"))))
+                "0qsjlzi1wqszi6k4pc3k9xdvzid5cx6ql8wbjw6qdapzpvf6arvz"))))
+    (build-system cmake-build-system)
     (arguments
-     (substitute-keyword-arguments (package-arguments sdl)
-       ((#:configure-flags flags)
-        #~(append '("--disable-wayland-shared" "--enable-video-kmsdrm"
-                    "--disable-kmsdrm-shared")
-                  #$flags))
-       ((#:make-flags flags ''())
-        #~(cons*
-           ;; SDL dlopens libudev and libvulkan, so make sure they are in
-           ;; rpath. This overrides the LDFLAG set in sdl’s configure-flags,
-           ;; which isn’t necessary as sdl2 includes Mesa by default.
-           (string-append "LDFLAGS=-Wl,-rpath,"
-                          #$(this-package-input "eudev") "/lib"
-                          ",-rpath,"
-                          #$(this-package-input "vulkan-loader") "/lib")
-           #$flags))))
-    (inputs
-     ;; SDL2 needs to be built with ibus support otherwise some systems
-     ;; experience a bug where input events are doubled.
-     ;;
-     ;; For more information, see: https://dev.solus-project.com/T1721
-     (modify-inputs (package-inputs sdl)
-       (append dbus
-               eudev                    ;for discovering input devices
-               glib
-               ibus-minimal
-               libxkbcommon
-               libxcursor               ;enables X11 cursor support
-               vulkan-loader
-               wayland
-               wayland-protocols)))
-    (license license:bsd-3)))
+     (list #:tests? #f                  ;no check target
+           #:configure-flags
+           ;; This add SDL2 to sdl12-compat's RUNPATH, to make dlopen finding the
+           ;; libSDL2 at runtime.
+           #~'("-DCMAKE_SHARED_LINKER_FLAGS=-lSDL2")
+           #:phases
+           #~(modify-phases %standard-phases
+               (add-after 'install 'install-sdl.pc
+                 (lambda* (#:key outputs #:allow-other-keys)
+                   (let ((pcdir (string-append (assoc-ref outputs "out")
+                                               "/lib/pkgconfig")))
+                     (symlink (string-append pcdir "/sdl12_compat.pc")
+                              (string-append pcdir "/sdl.pc"))))))))
+    (inputs (list sdl2))
+    (propagated-inputs (list glu))      ;required by SDL_opengl.h
+    (synopsis "Cross platform game development library")
+    (description "Simple DirectMedia Layer is a cross-platform development library
+designed to provide low level access to audio, keyboard, mouse, joystick, and
+graphics hardware.  This package is a compatibility layer; it provides a binary and
+source compatible API for programs written against SDL 1.2, but it uses SDL 2.0
+behind the scenes.")
+    (home-page "https://libsdl.org/")
+    ;; dr_mp3 code are under public domain.
+    (license (list license:zlib license:public-domain))))
+
+(define-public sdl sdl12-compat)
 
 (define-public sdl2-2.0
   (package
@@ -423,7 +452,7 @@ (define* (sdl-union #:optional (packages (list sdl sdl-gfx sdl-net sdl-ttf
 If PACKAGES are not specified, all SDL packages are used."
   (package
     (name "sdl-union")
-    (version (package-version sdl))
+    (version "1.2.15")                  ;TODO: use correct SDL version
     (source #f)
     (build-system trivial-build-system)
     (arguments
@@ -452,6 +481,8 @@ (define (propagated-inputs-with-sdl2 package)
   (map (match-lambda
          (("sdl" _)
           `("sdl2" ,sdl2))
+         (("sdl12-compat" _)
+          `("sdl2" ,sdl2))
          (other other))
        (package-propagated-inputs package)))
 

base-commit: de3f86443837b7bd6e3bad11dbaeed2550d4207c
-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#69638; Package guix-patches. (Sun, 10 Mar 2024 09:35:01 GMT) Full text and rfc822 format available.

Message #11 received at 69638 <at> debbugs.gnu.org (full text, mbox):

From: iyzsong <at> envs.net
To: 69638 <at> debbugs.gnu.org
Cc: 宋文武 <iyzsong <at> member.fsf.org>
Subject: [PATCH v3] gnu: sdl: Replace with sdl12-compat.
Date: Sun, 10 Mar 2024 17:33:51 +0800
From: 宋文武 <iyzsong <at> member.fsf.org>

* gnu/packages/sdl.scm (sdl12-compat): New package.
(sdl): Remove package, defined as sdl12-compat.
(sdl2): Don't inherit from sdl.
(propagated-inputs-with-sdl2): Add case for sdl12-compat.
(sdl-union): Hardcode version to "1.2.15" to avoid rebuilds.
* gnu/packages/patches/sdl-libx11-1.6.patch: Remove file.
* gnu/local.mk (dist_patch_DATA): Unregister it.

Change-Id: I843d349b3d69164cc640c7db204464a51819a0df
---
Changes since v2:
  sdl12-compat: Add a 'patch-sdl-config' phase to fix build for frozen-bubble.


---
 gnu/local.mk                              |   1 -
 gnu/packages/patches/sdl-libx11-1.6.patch |  13 --
 gnu/packages/sdl.scm                      | 180 +++++++++++++---------
 3 files changed, 109 insertions(+), 85 deletions(-)
 delete mode 100644 gnu/packages/patches/sdl-libx11-1.6.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 174c4c30e2..93bed266ac 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -2030,7 +2030,6 @@ dist_patch_DATA =						\
   %D%/packages/patches/scons-test-environment.patch		\
   %D%/packages/patches/screen-hurd-path-max.patch		\
   %D%/packages/patches/scsh-nonstring-search-path.patch	\
-  %D%/packages/patches/sdl-libx11-1.6.patch			\
   %D%/packages/patches/seed-webkit.patch			\
   %D%/packages/patches/sendgmail-accept-ignored-gsuite-flag.patch	\
   %D%/packages/patches/sendgmail-remove-domain-restriction.patch	\
diff --git a/gnu/packages/patches/sdl-libx11-1.6.patch b/gnu/packages/patches/sdl-libx11-1.6.patch
deleted file mode 100644
index 73ba9ac071..0000000000
--- a/gnu/packages/patches/sdl-libx11-1.6.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-Update _XData32 declaration in SDL_x11sym.h to match that of libx11 1.6.
-
---- SDL-1.2.15/src/video/x11/SDL_x11sym.h.~1~	2012-01-19 01:30:06.000000000 -0500
-+++ SDL-1.2.15/src/video/x11/SDL_x11sym.h	2014-12-26 00:22:36.445067694 -0500
-@@ -165,7 +165,7 @@
-  */
- #ifdef LONG64
- SDL_X11_MODULE(IO_32BIT)
--SDL_X11_SYM(int,_XData32,(Display *dpy,register long *data,unsigned len),(dpy,data,len),return)
-+SDL_X11_SYM(int,_XData32,(Display *dpy,register _Xconst long *data,unsigned len),(dpy,data,len),return)
- SDL_X11_SYM(void,_XRead32,(Display *dpy,register long *data,long len),(dpy,data,len),)
- #endif
- 
diff --git a/gnu/packages/sdl.scm b/gnu/packages/sdl.scm
index 3a4aafcaa7..17cae5708f 100644
--- a/gnu/packages/sdl.scm
+++ b/gnu/packages/sdl.scm
@@ -43,6 +43,7 @@ (define-module (gnu packages sdl)
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module (guix utils)
+  #:use-module (guix build-system cmake)
   #:use-module (guix build-system copy)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system trivial)
@@ -67,35 +68,48 @@ (define-module (gnu packages sdl)
   #:use-module (gnu packages xorg)
   #:export (sdl-union))
 
-(define-public sdl
+(define-public sdl2
   (package
-    (name "sdl")
-    (version "1.2.15")
+    (name "sdl2")
+    (version "2.28.5")
     (source (origin
-             (method url-fetch)
-             (uri
-              (string-append "https://libsdl.org/release/SDL-"
-                             version ".tar.gz"))
-             (sha256
-              (base32
-               "005d993xcac8236fpvd1iawkz4wqjybkpn8dbwaliqz5jfkidlyn"))
-             (patches (search-patches "sdl-libx11-1.6.patch"))))
+              (method url-fetch)
+              (uri
+               (string-append "https://libsdl.org/release/SDL2-"
+                              version ".tar.gz"))
+              (sha256
+               (base32
+                "1r36cspzv6h8abiqbbkrgm17g975p9wiziir2xabj3721dyv6b1k"))))
     (build-system gnu-build-system)
+    ;; TODO: Remove 'append' and 'cons*', was used to avoid rebuilds.
     (arguments
-     '(;; Explicitly link against shared libraries instead of dlopening them.
-       ;; For X11, ALSA, and PulseAudio.
-       ;; OpenGL library is still dlopened at runtime.
-       #:configure-flags '("--disable-alsa-shared"
-                           "--disable-pulseaudio-shared"
-                           "--disable-x11-shared"
-                           ;; Explicitly link with mesa.
-                           ;; This add mesa to libsdl's RUNPATH, to make dlopen
-                           ;; finding the libGL from mesa at runtime.
-                           "LDFLAGS=-lGL")
-
-       #:make-flags '("V=1")            ;build verbosely
-
-       #:tests? #f)) ; no check target
+     (list
+      #:tests? #f                  ;no check target
+      ;; Explicitly link against shared libraries instead of dlopening them.
+      ;; For X11, ALSA, and PulseAudio.
+      ;; OpenGL library is still dlopened at runtime.
+      #:configure-flags
+      #~(append
+         '("--disable-wayland-shared"
+           "--enable-video-kmsdrm"
+           "--disable-kmsdrm-shared")
+         '("--disable-alsa-shared"
+           "--disable-pulseaudio-shared"
+           "--disable-x11-shared"
+           ;; Explicitly link with mesa.
+           ;; This add mesa to libsdl's RUNPATH, to make dlopen
+           ;; finding the libGL from mesa at runtime.
+           "LDFLAGS=-lGL"))
+      #:make-flags
+      #~(cons*
+         ;; SDL dlopens libudev and libvulkan, so make sure they are in
+         ;; rpath. This overrides the LDFLAG set in sdl’s configure-flags,
+         ;; which isn’t necessary as sdl2 includes Mesa by default.
+         (string-append "LDFLAGS=-Wl,-rpath,"
+                        #$(this-package-input "eudev") "/lib"
+                        ",-rpath,"
+                        #$(this-package-input "vulkan-loader") "/lib")
+         '("V=1"))))                  ;build verbosely
     (propagated-inputs
      ;; SDL headers include X11 headers.
      (list libx11
@@ -105,60 +119,82 @@ (define-public sdl
            ;; change in pkg-config.
            mesa))
     (native-inputs (list pkg-config))
-    (inputs (list libxrandr glu alsa-lib pulseaudio))
+    (inputs
+     ;; SDL2 needs to be built with ibus support otherwise some systems
+     ;; experience a bug where input events are doubled.
+     ;;
+     ;; For more information, see: https://dev.solus-project.com/T1721
+     (list
+      libxrandr
+      glu
+      alsa-lib
+      pulseaudio
+      dbus
+      eudev                             ;for discovering input devices
+      glib
+      ibus-minimal
+      libxkbcommon
+      libxcursor                        ;enables X11 cursor support
+      vulkan-loader
+      wayland
+      wayland-protocols))
     (outputs '("out" "debug"))
     (synopsis "Cross platform game development library")
-    (description "Simple DirectMedia Layer is a cross-platform development
-library designed to provide low level access to audio, keyboard, mouse,
-joystick, and graphics hardware.")
+    (description
+     "Simple DirectMedia Layer is a cross-platform development library designed to
+provide low level access to audio, keyboard, mouse, joystick, and graphics
+hardware.")
     (home-page "https://libsdl.org/")
-    (license license:lgpl2.1)))
+    (license license:bsd-3)))
 
-(define-public sdl2
+(define-public sdl12-compat
   (package
-    (inherit sdl)
-    (name "sdl2")
-    (version "2.28.5")
+    (name "sdl12-compat")
+    (version "1.2.68")
     (source (origin
-              (method url-fetch)
-              (uri
-               (string-append "https://libsdl.org/release/SDL2-"
-                              version ".tar.gz"))
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/libsdl-org/sdl12-compat")
+                    (commit (string-append "release-" version))))
+              (file-name (git-file-name name version))
               (sha256
                (base32
-                "1r36cspzv6h8abiqbbkrgm17g975p9wiziir2xabj3721dyv6b1k"))))
+                "0qsjlzi1wqszi6k4pc3k9xdvzid5cx6ql8wbjw6qdapzpvf6arvz"))))
+    (build-system cmake-build-system)
     (arguments
-     (substitute-keyword-arguments (package-arguments sdl)
-       ((#:configure-flags flags)
-        #~(append '("--disable-wayland-shared" "--enable-video-kmsdrm"
-                    "--disable-kmsdrm-shared")
-                  #$flags))
-       ((#:make-flags flags ''())
-        #~(cons*
-           ;; SDL dlopens libudev and libvulkan, so make sure they are in
-           ;; rpath. This overrides the LDFLAG set in sdl’s configure-flags,
-           ;; which isn’t necessary as sdl2 includes Mesa by default.
-           (string-append "LDFLAGS=-Wl,-rpath,"
-                          #$(this-package-input "eudev") "/lib"
-                          ",-rpath,"
-                          #$(this-package-input "vulkan-loader") "/lib")
-           #$flags))))
-    (inputs
-     ;; SDL2 needs to be built with ibus support otherwise some systems
-     ;; experience a bug where input events are doubled.
-     ;;
-     ;; For more information, see: https://dev.solus-project.com/T1721
-     (modify-inputs (package-inputs sdl)
-       (append dbus
-               eudev                    ;for discovering input devices
-               glib
-               ibus-minimal
-               libxkbcommon
-               libxcursor               ;enables X11 cursor support
-               vulkan-loader
-               wayland
-               wayland-protocols)))
-    (license license:bsd-3)))
+     (list #:tests? #f                  ;no check target
+           #:configure-flags
+           ;; This add SDL2 to sdl12-compat's RUNPATH, to make dlopen finding the
+           ;; libSDL2 at runtime.
+           #~'("-DCMAKE_SHARED_LINKER_FLAGS=-lSDL2")
+           #:phases
+           #~(modify-phases %standard-phases
+               (add-after 'unpack 'patch-sdl-config
+                 (lambda _
+                   ;; Keep the old behaviour to honour "--prefix" option for
+                   ;; "--cflags" and "--libs", required by 'perl-alien-sdl'.
+                   (substitute* "sdl-config.in"
+                     (("echo -I[$][{]includedir[}]") "echo -I${prefix}/include")
+                     (("echo -L[$][{]libdir[}]") "echo -L${prefix}/lib"))))
+               (add-after 'install 'install-sdl.pc
+                 (lambda* (#:key outputs #:allow-other-keys)
+                   (let ((pcdir (string-append (assoc-ref outputs "out")
+                                               "/lib/pkgconfig")))
+                     (symlink (string-append pcdir "/sdl12_compat.pc")
+                              (string-append pcdir "/sdl.pc"))))))))
+    (inputs (list sdl2))
+    (propagated-inputs (list glu))      ;required by SDL_opengl.h
+    (synopsis "Cross platform game development library")
+    (description "Simple DirectMedia Layer is a cross-platform development library
+designed to provide low level access to audio, keyboard, mouse, joystick, and
+graphics hardware.  This package is a compatibility layer; it provides a binary and
+source compatible API for programs written against SDL 1.2, but it uses SDL 2.0
+behind the scenes.")
+    (home-page "https://libsdl.org/")
+    ;; dr_mp3 code are under public domain.
+    (license (list license:zlib license:public-domain))))
+
+(define-public sdl sdl12-compat)
 
 (define-public sdl2-2.0
   (package
@@ -423,7 +459,7 @@ (define* (sdl-union #:optional (packages (list sdl sdl-gfx sdl-net sdl-ttf
 If PACKAGES are not specified, all SDL packages are used."
   (package
     (name "sdl-union")
-    (version (package-version sdl))
+    (version "1.2.15")                  ;TODO: use correct SDL version
     (source #f)
     (build-system trivial-build-system)
     (arguments
@@ -452,6 +488,8 @@ (define (propagated-inputs-with-sdl2 package)
   (map (match-lambda
          (("sdl" _)
           `("sdl2" ,sdl2))
+         (("sdl12-compat" _)
+          `("sdl2" ,sdl2))
          (other other))
        (package-propagated-inputs package)))
 

base-commit: 7758e63f7a89f53fbb7c7a265ae472af0a8dfab0
-- 
2.41.0





Reply sent to Maxim Cournoyer <maxim.cournoyer <at> gmail.com>:
You have taken responsibility. (Fri, 12 Apr 2024 19:01:03 GMT) Full text and rfc822 format available.

Notification sent to iyzsong <at> envs.net:
bug acknowledged by developer. (Fri, 12 Apr 2024 19:01:04 GMT) Full text and rfc822 format available.

Message #16 received at 69638-done <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: iyzsong <at> envs.net
Cc: 宋文武 <iyzsong <at> member.fsf.org>,
 69638-done <at> debbugs.gnu.org
Subject: Re: [bug#69638] [PATCH v3] gnu: sdl: Replace with sdl12-compat.
Date: Fri, 12 Apr 2024 15:00:28 -0400
Hi,

iyzsong <at> envs.net writes:

> From: ®æ‡­ <iyzsong <at> member.fsf.org>
>
> * gnu/packages/sdl.scm (sdl12-compat): New package.
> (sdl): Remove package, defined as sdl12-compat.
> (sdl2): Don't inherit from sdl.
> (propagated-inputs-with-sdl2): Add case for sdl12-compat.
> (sdl-union): Hardcode version to "1.2.15" to avoid rebuilds.

It was triggering a mass rebuild anyway, so I've opted to use the actual
'sdl' version and merged this to core-updates.

Thank you, closing.

-- 
Thanks,
Maxim




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 11 May 2024 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 5 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.