diff mbox series

[bug#64519] gnu: godot: Update to 4.1. Rename godot@3 to godot-lts.

Message ID 875y6vlmaw.fsf@protonmail.com
State New
Headers show
Series [bug#64519] gnu: godot: Update to 4.1. Rename godot@3 to godot-lts. | expand

Commit Message

John Kehayias July 7, 2023, 4:27 p.m. UTC
Hi Guixers,

Here's a patch to add Godot 4! I've tested it builds and can load some sophisticated examples, working with the new Vulkan support. There is no longer a headless build so that has been removed as an output. The previous version, godot@3 is an LTS release now (and in need of an update I see) so I kept that as godot-lts.

I wasn't sure how best to break this up in commits, let me know if these should be separate and how (1. rename godot to godot-lts and 2. add godot@4?). I did my best to put in all the changes in the package definition from 3 to 4 in the changelog, but please do check. Due to the amount and scope of changes I didn't think godot-lts could easily inherit from godot.

Thanks!
John

Comments

Ludovic Courtès July 11, 2023, 1:51 p.m. UTC | #1
Hi John,

John Kehayias <john.kehayias@protonmail.com> skribis:

> From 287373c727c5292e5778f60aacf3685a4feddeca Mon Sep 17 00:00:00 2001
> Message-Id: <287373c727c5292e5778f60aacf3685a4feddeca.1688747031.git.john.kehayias@protonmail.com>
> From: John Kehayias <john.kehayias@protonmail.com>
> Date: Fri, 7 Jul 2023 12:05:39 -0400
> Subject: [PATCH] gnu: godot: Update to 4.1.  Rename godot@3 to godot-lts.
>
> * gnu/packages/game-development.scm (godot): Update to 4.1.
> [source]: Update snippet: remove embree and enet; add amd-fsr, astcenc,
> basis_universal, brotli, linuxbsd_headers, etcpak, meshoptimizer, msdfgen,
> noise, openxr, rvo2, spirv-reflect, thorvg, volk, vulkan.
> [arguments]: Remove #:scons.  Update #:scons-flags to unbundle more
> libraries.
> [phases]: Remove 'build-headless phase (headless is no longer has a separate
> build).  Add 'fix-dl-open-paths and 'unbundle-xkbcommon phases.  In 'install
> phase, remove headless output.  Update 'wrap phase to remove eudev.
> [outputs]: Remove headless.
> [inputs]: Add dbus, embree, enet, fontconfig, glslang, libpng, harfbuzz,
> icu4c, libxkbcommon, openxr, speech-dispatcher, vulkan-loader, zlib.  Remove
> bullet.  Rename freetype to freetype-brotli.
> (godot-lts): New variable.  godot@3 is the LTS release.
> * gnu/packages/games.scm (superstarfighter)[native-inputs]: Use it.
> [inputs]: Use it.

[...]

> +(define-public godot-lts
>    (package
>      (name "godot")
>      (version "3.4.2")
> @@ -1982,6 +1988,253 @@ (define-public godot
>  scripted in a Python-like language.")
>      (license license:expat)))
>  
> +(define-public godot
> +  (package
> +    (name "godot")
> +    (version "4.1")

Looks like the arguments and snippet are too different to be factorized
via inheritance.  However, one could still inherit from the other to
factorize license/synopsis/description?

Apart from this minor issue, LGTM!

Thanks,
Ludo’.
diff mbox series

Patch

From 287373c727c5292e5778f60aacf3685a4feddeca Mon Sep 17 00:00:00 2001
Message-Id: <287373c727c5292e5778f60aacf3685a4feddeca.1688747031.git.john.kehayias@protonmail.com>
From: John Kehayias <john.kehayias@protonmail.com>
Date: Fri, 7 Jul 2023 12:05:39 -0400
Subject: [PATCH] gnu: godot: Update to 4.1.  Rename godot@3 to godot-lts.

* gnu/packages/game-development.scm (godot): Update to 4.1.
[source]: Update snippet: remove embree and enet; add amd-fsr, astcenc,
basis_universal, brotli, linuxbsd_headers, etcpak, meshoptimizer, msdfgen,
noise, openxr, rvo2, spirv-reflect, thorvg, volk, vulkan.
[arguments]: Remove #:scons.  Update #:scons-flags to unbundle more
libraries.
[phases]: Remove 'build-headless phase (headless is no longer has a separate
build).  Add 'fix-dl-open-paths and 'unbundle-xkbcommon phases.  In 'install
phase, remove headless output.  Update 'wrap phase to remove eudev.
[outputs]: Remove headless.
[inputs]: Add dbus, embree, enet, fontconfig, glslang, libpng, harfbuzz,
icu4c, libxkbcommon, openxr, speech-dispatcher, vulkan-loader, zlib.  Remove
bullet.  Rename freetype to freetype-brotli.
(godot-lts): New variable.  godot@3 is the LTS release.
* gnu/packages/games.scm (superstarfighter)[native-inputs]: Use it.
[inputs]: Use it.
---
 gnu/packages/game-development.scm | 255 +++++++++++++++++++++++++++++-
 gnu/packages/games.scm            |   4 +-
 2 files changed, 256 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/game-development.scm b/gnu/packages/game-development.scm
index aa99109cca..e40beacb60 100644
--- a/gnu/packages/game-development.scm
+++ b/gnu/packages/game-development.scm
@@ -28,6 +28,7 @@ 
 ;;; Copyright © 2022 Felix Gruber <felgru@posteo.net>
 ;;; Copyright © 2022 Jai Vetrivelan <jaivetrivelan@gmail.com>
 ;;; Copyright © 2022 dan <i@dan.games>
+;;; Copyright © 2023 John Kehayias <john.kehayias@protonmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -54,6 +55,7 @@  (define-module (gnu packages game-development)
   #:use-module (guix git-download)
   #:use-module (guix svn-download)
   #:use-module (guix utils)
+  #:use-module (guix build utils)
   #:use-module (guix build-system cmake)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system python)
@@ -86,6 +88,7 @@  (define-module (gnu packages game-development)
   #:use-module (gnu packages graphviz)
   #:use-module (gnu packages gtk)
   #:use-module (gnu packages guile)
+  #:use-module (gnu packages icu4c)
   #:use-module (gnu packages image)
   #:use-module (gnu packages linux)
   #:use-module (gnu packages llvm)
@@ -95,6 +98,7 @@  (define-module (gnu packages game-development)
   #:use-module (gnu packages multiprecision)
   #:use-module (gnu packages music)
   #:use-module (gnu packages ncurses)
+  #:use-module (gnu packages networking)
   #:use-module (gnu packages pcre)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages pulseaudio)
@@ -105,12 +109,14 @@  (define-module (gnu packages game-development)
   #:use-module (gnu packages readline)
   #:use-module (gnu packages qt)
   #:use-module (gnu packages sdl)
+  #:use-module (gnu packages speech)
   #:use-module (gnu packages sphinx)
   #:use-module (gnu packages stb)
   #:use-module (gnu packages texinfo)
   #:use-module (gnu packages textutils)
   #:use-module (gnu packages tls)
   #:use-module (gnu packages video)
+  #:use-module (gnu packages vulkan)
   #:use-module (gnu packages web)
   #:use-module (gnu packages wxwidgets)
   #:use-module (gnu packages xdisorg)
@@ -1812,7 +1818,7 @@  (define-public openmw
     (home-page "https://openmw.org")
     (license license:gpl3)))
 
-(define-public godot
+(define-public godot-lts
   (package
     (name "godot")
     (version "3.4.2")
@@ -1982,6 +1988,253 @@  (define-public godot
 scripted in a Python-like language.")
     (license license:expat)))
 
+(define-public godot
+  (package
+    (name "godot")
+    (version "4.1")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/godotengine/godot")
+                    (commit (string-append version "-stable"))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0rc34w4nb1qwmxk7ijcm689kk4gdxrmgzbj4qqz8gkqhysn8mnmz"))
+              (modules '((guix build utils)
+                         (ice-9 ftw)
+                         (srfi srfi-1)))
+              (snippet
+               '(begin
+                  ;; Keep only those bundled files we have not (yet) replaced
+                  ;; with Guix versions. Note that some of these may be
+                  ;; modified; see "thirdparty/README.md".
+                  (with-directory-excursion "thirdparty"
+                    (let* ((preserved-files
+                            '("README.md"
+                              "amd-fsr"
+                              "assimp"
+                              "astcenc"
+                              "basis_universal"
+                              ;; TODO: Can unbundle once
+                              ;; <https://github.com/godotengine/godot/pull/79101>
+                              ;; is merged
+                              "brotli"
+                              ;; Godot needs ca-certificates.crt, but that is
+                              ;; not available in build environment
+                              "certs"
+                              "cvtt"
+                              "linuxbsd_headers"
+                              "etc2comp"
+                              "etcpak"
+                              "fonts"
+                              "glad"
+                              "jpeg-compressor"
+                              "libsimplewebm"
+                              "meshoptimizer"
+                              "minimp3"
+                              "miniupnpc"
+                              "minizip"
+                              "misc"
+                              "msdfgen"
+                              "nanosvg"
+                              "noise"
+                              "oidn"
+                              "openxr"
+                              "pvrtccompressor"
+                              "recastnavigation"
+                              "rvo2"
+                              "spirv-reflect"
+                              "squish"
+                              "stb_rect_pack"
+                              "thorvg"
+                              "tinyexr"
+                              "vhacd"
+                              "volk"
+                              "vulkan"
+                              "xatlas")))
+                      (for-each delete-file-recursively
+                                (lset-difference string=?
+                                                 (scandir ".")
+                                                 (cons* "." ".." preserved-files)))))))))
+    (build-system scons-build-system)
+    (arguments
+     (list
+      #:scons-flags #~`("platform=linuxbsd" "target=editor" "production=yes"
+                        ;; XXX: There may be advantages to enabling volk,
+                        ;; requiring unbundling and patching to use our input.
+                        "use_volk=no"
+                        ;; Avoid using many of the bundled libs.
+                        ;; Note: These options can be found in the SConstruct file.
+                        "builtin_embree=no"
+                        "builtin_enet=no"
+                        "builtin_freetype=no"
+                        "builtin_glslang=no"
+                        "builtin_graphite=no"
+                        "builtin_harfbuzz=no"
+                        "builtin_icu4c=no"
+                        "builtin_libogg=no"
+                        "builtin_libpng=no"
+                        "builtin_libtheora=no"
+                        "builtin_libvorbis=no"
+                        "builtin_libwebp=no"
+                        "builtin_mbedtls=no"
+                        "builtin_pcre2=no"
+                        "builtin_pcre2_with_jit=no"
+                        "builtin_wslay=no"
+                        "builtin_zlib=no"
+                        "builtin_zstd=no")
+      #:tests? #f                      ; There are no tests
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'unpack 'scons-use-env
+            (lambda _
+              ;; Scons does not use the environment variables by default,
+              ;; but this substitution makes it do so.
+              (substitute* "SConstruct"
+                (("env_base = Environment\\(tools=custom_tools\\)")
+                 (string-append
+                  "env_base = Environment(tools=custom_tools)\n"
+                  "env_base = Environment(ENV=os.environ)")))))
+          (add-after 'scons-use-env 'fix-dlopen-paths
+            (lambda* (#:key inputs #:allow-other-keys)
+              (let ((files '("drivers/alsa/asound-so_wrap.c"
+                             "drivers/pulseaudio/pulse-so_wrap.c"
+                             "platform/linuxbsd/dbus-so_wrap.c"
+                             "platform/linuxbsd/fontconfig-so_wrap.c"
+                             "platform/linuxbsd/libudev-so_wrap.c"
+                             "platform/linuxbsd/speechd-so_wrap.c"
+                             "platform/linuxbsd/x11/display_server_x11.cpp"
+                             "platform/linuxbsd/x11/dynwrappers/xcursor-so_wrap.c"
+                             "platform/linuxbsd/x11/dynwrappers/xext-so_wrap.c"
+                             "platform/linuxbsd/x11/dynwrappers/xinerama-so_wrap.c"
+                             "platform/linuxbsd/x11/dynwrappers/xinput2-so_wrap.c"
+                             "platform/linuxbsd/x11/dynwrappers/xlib-so_wrap.c"
+                             "platform/linuxbsd/x11/dynwrappers/xrandr-so_wrap.c"
+                             "platform/linuxbsd/x11/dynwrappers/xrender-so_wrap.c"
+                             "platform/linuxbsd/xkbcommon-so_wrap.c"
+                             "thirdparty/volk/volk.c"
+                             "thirdparty/volk/volk.c"))
+                    (libs '("libasound.so.2"
+                            "libpulse.so.0"
+                            "libdbus-1.so.3"
+                            "libfontconfig.so.1"
+                            "libudev.so.1"
+                            "libspeechd.so.2"
+                            "libXrandr.so.2"
+                            "libXcursor.so.1"
+                            "libXext.so.6"
+                            "libXinerama.so.1"
+                            "libXi.so.6"
+                            "libX11.so.6"
+                            "libXrandr.so.2"
+                            "libXrender.so.1"
+                            "libxkbcommon.so.0"
+                            "libvulkan.so.1"
+                            "libvulkan.so")))
+                (for-each (lambda (file lib)
+                            (substitute* file
+                              (((string-append "dlopen\\(\"" lib "\""))
+                               (string-append "dlopen(\""
+                                              (search-input-file
+                                               inputs (string-append "lib/" lib))
+                                              "\""))))
+                          files libs))
+              (substitute* "thirdparty/glad/gl.c"
+                (("libGL.so") ; for both .so and .so.1
+                 (string-append (search-input-file inputs "lib/libGL.so"))))
+              (substitute* "thirdparty/glad/glx.c"
+                (("libGL.so") ; for both .so and .so.1
+                 (string-append (search-input-file inputs "lib/libGL.so"))))))
+          (add-after 'fix-dlopen-paths 'unbundle-xkbcommon
+            (lambda* (#:key inputs #:allow-other-keys)
+              (substitute* "platform/linuxbsd/xkbcommon-so_wrap.c"
+                (("./thirdparty/linuxbsd_headers/xkbcommon/xkbcommon.h")
+                 (string-append
+                  (search-input-file inputs "include/xkbcommon/xkbcommon.h")))
+                (("./thirdparty/linuxbsd_headers/xkbcommon/xkbcommon-compose.h")
+                 (string-append
+                  (search-input-file inputs "include/xkbcommon/xkbcommon-compose.h")))
+                (("./thirdparty/linuxbsd_headers/xkbcommon/xkbcommon-keysyms.h")
+                 (string-append
+                  (search-input-file inputs "include/xkbcommon/xkbcommon-keysyms.h"))))))
+          (replace 'install
+            (lambda* (#:key inputs #:allow-other-keys)
+              (let ((zenity (search-input-file inputs "bin/zenity")))
+                ;; Strip build info from filenames.
+                (with-directory-excursion "bin"
+                  (for-each
+                   (lambda (file)
+                     (let ((dest (car (string-split (basename file) #\.))))
+                       (rename-file file dest)))
+                   (find-files "." "godot.*\\.linuxbsd\\.editor.*"))
+                  (install-file "godot" (string-append #$output "/bin")))
+                ;; Tell the editor where to find zenity for OS.alert().
+                ;; TODO: This could be changed in
+                ;; platform/linuxbsd/os_linuxbsd.cpp directly, along with the
+                ;; other alert programs.
+                (wrap-program (string-append #$output "/bin/godot")
+                  `("PATH" ":" prefix (,(string-append zenity "/bin")))))))
+          (add-after 'install 'install-godot-desktop
+            (lambda _
+              (let ((applications (string-append #$output "/share/applications"))
+                     (icons (string-append #$output "/share/icons/hicolor")))
+                (mkdir-p applications)
+                (copy-file "misc/dist/linux/org.godotengine.Godot.desktop"
+                           (string-append applications "/godot.desktop"))
+                (for-each (lambda (icon dest)
+                            (mkdir-p (dirname dest))
+                            (copy-file icon dest))
+                          '("icon.png" "icon.svg")
+                           `(,(string-append icons "/256x256/apps/godot.png")
+                             ,(string-append icons "/scalable/apps/godot.svg")))))))))
+    (native-inputs
+     (list pkg-config))
+    (inputs
+     (list alsa-lib
+           dbus
+           embree
+           enet
+           eudev
+           fontconfig
+           freetype-brotli
+           glew
+           glslang
+           glu
+           libpng
+           harfbuzz
+           icu4c
+           libtheora
+           libvorbis
+           libvpx
+           libwebp
+           libx11
+           libxcursor
+           libxi
+           libxinerama
+           libxkbcommon
+           libxrandr
+           mbedtls-apache
+           mesa
+           openxr
+           opusfile
+           pcre2
+           pulseaudio
+           speech-dispatcher
+           vulkan-loader
+           wslay
+           zenity
+           zlib
+           `(,zstd "lib")))
+    (home-page "https://godotengine.org/")
+    (synopsis "Advanced 2D and 3D game engine")
+    (description
+     "Godot is an advanced multi-platform game engine written in C++.  If
+features design tools such as a visual editor, can import 3D models and
+provide high-quality 3D rendering, it contains an animation editor, and can be
+scripted in a Python-like language.")
+    (license license:expat)))
+
 (define-public entt
   (package
     (name "entt")
diff --git a/gnu/packages/games.scm b/gnu/packages/games.scm
index 7e36c66b6a..f0bfd0f9d5 100644
--- a/gnu/packages/games.scm
+++ b/gnu/packages/games.scm
@@ -2823,9 +2823,9 @@  (define-public superstarfighter
                 #:categories '("Game" "ArcadeGame")))
              #t)))))
     (native-inputs
-     `(("godot-headless" ,godot "headless")))
+     `(("godot-headless" ,godot-lts "headless")))
     (inputs
-     (list godot))
+     (list godot-lts))
     (home-page "https://notapixel.itch.io/superstarfighter")
     (synopsis "Fast-paced local multiplayer arcade game")
     (description "In SuperStarfighter, up to four local players compete in a

base-commit: 67c276a870b9d6be69c2a9e867683e58928c38ef
prerequisite-patch-id: e282a1c5d3286b7715cad72962f494d2d56d8fcc
prerequisite-patch-id: 656485c99b42352c0eedb241af948bd19ef1857c
prerequisite-patch-id: 89c7181debe0bc9d94a4035c5ddfc2e495becd65
prerequisite-patch-id: 7da573a9b135e39c3c1c6128ea8f2b9433bef949
prerequisite-patch-id: 7d38c3df34cc98d2d71e984cf4eb72d20a86f694
prerequisite-patch-id: 89c7181debe0bc9d94a4035c5ddfc2e495becd65
prerequisite-patch-id: 0f7d5306c9953ff425c1b5d44807c43d0908f5ff
prerequisite-patch-id: bf6e8bbc7adbef9dfeaa237b57806f0e051a1588
prerequisite-patch-id: d9b03fadf4e0617ae9fd99e2a4569088fa138cb0
prerequisite-patch-id: 89c7181debe0bc9d94a4035c5ddfc2e495becd65
prerequisite-patch-id: 3edd9b05dbcaf02b276087982465fc292fd23c95
prerequisite-patch-id: 5cefe6598904cb7ba36ccae9309084438d84069d
prerequisite-patch-id: eb2f92015e487fe1fb9e1f0803cb1c9614c05af7
prerequisite-patch-id: bf6e8bbc7adbef9dfeaa237b57806f0e051a1588
prerequisite-patch-id: 970c3e5af1d647a77c104cdaf487c986cf6660f3
prerequisite-patch-id: 81c8e47534c6523fa1c10f713bf6b10ae05e9b54
prerequisite-patch-id: a088a24f20373d230ed54818b1405ac76a336537
prerequisite-patch-id: ae0750f361cb74b38d61b705511e18b847791e9a
prerequisite-patch-id: f63b0379f89a9d6249b1270eec4042b7918ab8eb
prerequisite-patch-id: 99dbf414e972f019b3e6b2602932cfb6fa9a505f
prerequisite-patch-id: 4e19cc41474d02a2836ac745de1d6e565867fd55
prerequisite-patch-id: 00d8c76f452dad9009e90fce0dc8d1859ab51a0b
prerequisite-patch-id: eca1fb4c330a3925e55db95b18ae8ca7403569e5
prerequisite-patch-id: a9f671bd2505225d4ad1cb4a165ff18fa14f3302
-- 
2.40.1