Subject: Re: [PATCH v1 1/5] gnu: Add fgeal.

From: Liliana Marie Prikler <[email-masked]>
Date: Tue, 18 Apr 2023 18:50:15 +0200

Am Donnerstag, dem 16.03.2023 um 14:26 +0800 schrieb Adam Faiz:
>  From 735f08bc3d271959685e03d761f5ac9039e5cfd3 Mon Sep 17 00:00:00
> 2001
> Message-Id:
> <735f08bc3d271959685e03d761f5ac9039e5cfd3.1678947948.git.adam.faiz@di
> sroot.org>
> From: AwesomeAdam54321 <[email-masked]>
> Date: Tue, 14 Mar 2023 13:38:36 +0800
> Subject: [PATCH v1 1/5] gnu: Add fgeal.
> 
> * gnu/packages/game-development.scm (fgeal): New variable.
> ---
>   gnu/packages/game-development.scm | 106
> ++++++++++++++++++++++++++++++
>   1 file changed, 106 insertions(+)
> 
> diff --git a/gnu/packages/game-development.scm b/gnu/packages/game-
> development.scm
> index a384572a9d..cbededa8e4 100644
> --- a/gnu/packages/game-development.scm
> +++ b/gnu/packages/game-development.scm
> @@ -2359,6 +2359,112 @@ (define-public flatzebra
>   double-buffering.")
>       (license license:gpl2+)))
>   
> +(define-public fgeal
> +  (let ((commit "0ae72fbf31eb2e133fe83520391e7a82c0b59e67")
> +        (revision "0"))
> +  (package
> +    (name "fgeal")
> +    (version (git-version "0.8.4" revision commit))
> +    (source
> +     (origin
> +       (method git-fetch)
> +       (uri (git-reference
> +             (url "https://gitlab.com/hydren/fgeal")
> +             (commit commit)))
> +       (file-name (git-file-name name version))
> +       (sha256
> +        (base32
> "0lck86n8nkhb088bd0jg4imi9j5l1lwfr2pddqqr880rjrnnm8fw"))
> +       (modules '((guix build utils)))
> +       (snippet
> +        #~(begin
> +            (with-directory-excursion "project/build/linux-gcc-sdl2-
> release"
> +              (rename-file "configure.sh" "configure")
> +              (substitute* "configure"
> +                (("-exec sed -i")
> +                 (string-append
> +                 "-exec sed -i"
> +                 " \"s,SDL2_CFLAGS,`pkg-config --cflags sdl2`,g\" {}
> \\;"
> +                 " -exec sed -i"))
Capture the existing match with a variable, then use that variable.
> +                (("which") "type -p"))
> +              (substitute* "makefile"
> +                (("RM := rm -rf")
> +                 (string-append "RM := rm -rf\n"
> +                                "PREFIX ?= /usr/local"))
Same here.
> +                (("clean:")
> +                 (string-append
> +                  "install:\n\t"
> +                  "install -d $(DESTDIR)$(PREFIX)/include\n\t"
> +                  "cp -r ../fgeal $(DESTDIR)$(PREFIX)/include\n\t"
> +                  "install -d $(DESTDIR)$(PREFIX)/lib\n\t"
> +                  "install -m 644 libfgeal.so
> $(DESTDIR)$(PREFIX)/lib\n\n"
> +                  "clean:")))
Simply replace the install phase instead.
> +              (substitute* "extra/subdir.mk"
> +                (("../extra/input_manager.cpp \\\\")
> +                 (string-append "../extra/input_manager.cpp \\\n"
> +                                "../extra/primitives.cpp \\"))
> +                (("./extra/input_manager.o \\\\")
> +                 (string-append "./extra/input_manager.o \\\n"
> +                                "./extra/primitives.o \\"))
> +                (("./extra/input_manager.d \\\\")
> +                 (string-append "./extra/input_manager.d \\\n"
> +                                "./extra/primitives.d \\"))))
> +            (copy-recursively "project/build/linux-gcc-sdl2-release"
> +                              "linux-gcc-sdl2-release")
> +            (substitute* (find-files "." "\\.mk")
> +              (("-I\"BUILD_PATH\"") "-I\"BUILD_PATH\" SDL2_CFLAGS"))
> +            (for-each
> +             (lambda (file)
> +               (install-file file "fgeal"))
> +             '("agnostic_cached_drawable_text.hxx"
> +               "agnostic_filesystem.hxx"
> +               "agnostic_sound_stream.hxx"
> +               "colors.hpp"
> +               "core.hpp"
> +               "display.hpp"
> +               "event.hpp"
> +               "exceptions.hpp"
> +               "fgeal.hpp"
> +               "filesystem.hpp"
> +               "font.hpp"
> +               "friend_classes.hxx"
> +               "generic_graphics.hxx"
> +               "geometry.hpp"
> +               "graphics.hpp"
> +               "image.hpp"
> +               "input.hpp"
> +               "sound.hpp"
> +               "version.h"))
Why is it necessary to move these files?  Also, could this perhaps be
expressed via find-files?
> +            (for-each
> +             (lambda (file)
> +               (install-file file "fgeal/extra"))
> +             (find-files "extra" "\\.hpp$"))))))
> +    (build-system gnu-build-system)
> +    (native-inputs
> +     (list pkg-config))
> +    (inputs
> +     (list sdl2
> +           sdl2-gfx
> +           sdl2-image
> +           sdl2-mixer
> +           sdl2-ttf))
> +    (arguments
> +     (list #:tests? #f ; no tests
> +           #:phases
> +           #~(modify-phases %standard-phases
> +               (add-before 'configure 'chdir
> +                 (lambda _
> +                   (chdir "linux-gcc-sdl2-release"))))
> +           #:make-flags
> +           #~(list (string-append "DESTDIR=" #$output)
> +                   "PREFIX=")))
> +    (home-page "https://gitlab.com/hydren/fgeal")
> +    (synopsis "Simple C++ game library wrapper")
> +    (description "fgeal is a simple C++ wrapper library meant to
> provide
> +common functionalities between some game libraries through a single
> API.
> +  It serves as a cross-platform abstraction layer to other low-level
> game
> +libraries, such as SDL.")
> +    (license license:lgpl2.1+))))
> +
>   (define-public libccd
>     (package
>       (name "libccd")
> 
> base-commit: 5befcff66edb4d72ab8e713c81836fb8519ce3e6
Cheers