Ludovic Courtès (2015-10-10 00:56 +0300) wrote:

> "Thompson, David" <dthomps...@worcester.edu> skribis:
>
>> On Fri, Oct 9, 2015 at 8:40 AM, Ludovic Courtès <l...@gnu.org> wrote:
>>> Alex Kost <alez...@gmail.com> skribis:
>>>
>>>> I don't know if there is a better workaround for the SDL headers, but
>>>> this problem is rather common: there is a workaround in 'abbaye' and a
>>>> special patch for 'pingus'.
>>>>
>>>> The problem is: the source code has lines like this:
>>>>
>>>>   #include <SDL_mixer.h>
>>>>
>>>> but the headers of all SDL packages are placed in “include/SDL/”
>>>> subdirectories.  And an upstream often doesn't use "pkg-config" for
>>>> every SDL package to define CFLAGS and assumes that all SDL headers are
>>>> placed in one directory.  So we have to invent workarounds for such
>>>> packages.
>>>>
>>>> I just mention this problem here, perhaps someone will come up with a
>>>> general solution.
>>>
>>> Can’t ‘sdl-union’ be used here?  I think it was created specifically to
>>> solve this problem.  (Currently it’s private to (gnu packages sdl) but
>>> you can export it.)
>>
>> Do you have any concerns about this package being picked up by UIs now
>> that it will be public?  Might confuse a user or two, dunno.
>
> No opinion.  If you think we’d rather keep it hidden, we can wrap it in
> a thunk for instance so that the UIs don’t pick it up.  WDYT?

I like it.  But since there are several sdl libraries, and not all of
them may be required, what about making it a procedure that takes sdl
packages instead? (the patch is attached)

>From f1bd9edbbae498fb3b4726428daf523e3fd83060 Mon Sep 17 00:00:00 2001
From: Alex Kost <alez...@gmail.com>
Date: Sat, 10 Oct 2015 11:27:27 +0300
Subject: [PATCH] gnu: sdl-union: Wrap into a procedure and export it.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Suggested by Ludovic Courtès <l...@gnu.org>.

* gnu/packages/sdl.scm (sdl-union): Make it a procedure returning
  'sdl-union' package.
  (guile-sdl): Use it.
---
 gnu/packages/sdl.scm | 68 ++++++++++++++++++++++++++++++----------------------
 1 file changed, 39 insertions(+), 29 deletions(-)

diff --git a/gnu/packages/sdl.scm b/gnu/packages/sdl.scm
index 50fe010..021feff 100644
--- a/gnu/packages/sdl.scm
+++ b/gnu/packages/sdl.scm
@@ -42,7 +42,8 @@
             sdl-image
             sdl-mixer
             sdl-net
-            sdl-ttf))
+            sdl-ttf
+            sdl-union))
 
 (define sdl
   (package
@@ -268,33 +269,42 @@ SDL.")
     (home-page "http://www.libsdl.org/projects/SDL_ttf/";)
     (license zlib)))
 
-(define sdl-union
-  (package
-    (name "sdl-union")
-    (version (package-version sdl))
-    (source #f)
-    (build-system trivial-build-system)
-    (arguments
-     '(#:modules ((guix build union))
-       #:builder (begin
-                   (use-modules (ice-9 match)
-                                (guix build union))
-                   (match %build-inputs
-                     (((names . directories) ...)
-                      (union-build (assoc-ref %outputs "out")
-                                   directories))))))
-    (inputs `(("sdl" ,sdl)
-              ("sdl-gfx" ,sdl-gfx)
-              ("sdl-image" ,sdl-image)
-              ("sdl-mixer" ,sdl-mixer)
-              ("sdl-ttf" ,sdl-ttf)))
-    (synopsis "Union of all SDL libraries")
-    (description
-     "A union of SDL and its extension libraries.  A union is required because
-sdl-config assumes that all of the headers and libraries are in the same
-directory.")
-    (home-page (package-home-page sdl))
-    (license (package-license sdl))))
+(define (sdl-union . sdl-packages)
+  "Return 'sdl-union' package that is the union of SDL-PACKAGES.
+If SDL-PACKAGES are not specified, all SDL libraries are used."
+  (let* ((sdl-packages (if (null? sdl-packages)
+                           (list sdl
+                                 sdl-gfx
+                                 sdl-image
+                                 sdl-mixer
+                                 sdl-net
+                                 sdl-ttf)
+                           sdl-packages))
+         (inputs (map (lambda (pkg)
+                        (list (package-name pkg) pkg))
+                      sdl-packages)))
+    (package
+      (name "sdl-union")
+      (version (package-version sdl))
+      (source #f)
+      (build-system trivial-build-system)
+      (arguments
+       '(#:modules ((guix build union))
+         #:builder (begin
+                     (use-modules (ice-9 match)
+                                  (guix build union))
+                     (match %build-inputs
+                       (((names . directories) ...)
+                        (union-build (assoc-ref %outputs "out")
+                                     directories))))))
+      (inputs inputs)
+      (synopsis "Union of SDL libraries")
+      (description
+       "A union of SDL and its extension libraries.  The union is
+required because sdl-config assumes that all of the headers and
+libraries are in the same directory.")
+      (home-page (package-home-page sdl))
+      (license (package-license sdl)))))
 
 (define-public guile-sdl
   (package
@@ -316,7 +326,7 @@ directory.")
        ("libjpeg" ,libjpeg)))
     (inputs
      `(("guile" ,guile-2.0)
-       ("sdl-union" ,sdl-union)))
+       ("sdl-union" ,(sdl-union))))
     (arguments
      '(#:configure-flags
        (list (string-append "--with-sdl-prefix="
-- 
2.5.0

Reply via email to