@@ 1,239 @@
+(define-module (gnu packages godot)
+ #:use-module ((srfi srfi-1) #:hide (zip))
+ #:use-module (ice-9 match)
+ #:use-module ((guix licenses) #:prefix license:)
+ #:use-module (guix packages)
+ #:use-module (guix gexp)
+ #:use-module (guix download)
+ #:use-module (guix git-download)
+ #:use-module (guix svn-download)
+ #:use-module (guix utils)
+ #:use-module (guix build-system cmake)
+ #:use-module (guix build-system gnu)
+ #:use-module (guix build-system python)
+ #:use-module (guix build-system scons)
+ #:use-module (gnu packages)
+ #:use-module (gnu packages audio)
+ #:use-module (gnu packages autotools)
+ #:use-module (gnu packages base)
+ #:use-module (gnu packages bash)
+ #:use-module (gnu packages boost)
+ #:use-module (gnu packages compression)
+ #:use-module (gnu packages check)
+ #:use-module (gnu packages curl)
+ #:use-module (gnu packages documentation)
+ #:use-module (gnu packages fltk)
+ #:use-module (gnu packages fonts)
+ #:use-module (gnu packages fontutils)
+ #:use-module (gnu packages freedesktop)
+ #:use-module (gnu packages fribidi)
+ #:use-module (gnu packages dbm)
+ #:use-module (gnu packages gettext)
+ #:use-module (gnu packages gl)
+ #:use-module (gnu packages glib)
+ #:use-module (gnu packages gnome)
+ #:use-module (gnu packages gnunet)
+ #:use-module (gnu packages graphics)
+ #:use-module (gnu packages graphviz)
+ #:use-module (gnu packages gtk)
+ #:use-module (gnu packages guile)
+ #:use-module (gnu packages image)
+ #:use-module (gnu packages linux)
+ #:use-module (gnu packages lua)
+ #:use-module (gnu packages m4)
+ #:use-module (gnu packages mono)
+ #:use-module (gnu packages mp3)
+ #:use-module (gnu packages multiprecision)
+ #:use-module (gnu packages music)
+ #:use-module (gnu packages ncurses)
+ #:use-module (gnu packages pcre)
+ #:use-module (gnu packages pkg-config)
+ #:use-module (gnu packages pulseaudio)
+ #:use-module (gnu packages python)
+ #:use-module (gnu packages python-web)
+ #:use-module (gnu packages python-xyz)
+ #:use-module (gnu packages readline)
+ #:use-module (gnu packages qt)
+ #:use-module (gnu packages sdl)
+ #: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 web)
+ #:use-module (gnu packages wxwidgets)
+ #:use-module (gnu packages xdisorg)
+ #:use-module (gnu packages xiph)
+ #:use-module (gnu packages xml)
+ #:use-module (gnu packages xorg)
+ #:use-module (gnu packages game-development))
+
+(package
+ (name "godot")
+ (version "3.4.4")
+ (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
+ "1a8kdiqzypjl6qnjw7r188r1kf3sfz4z0bndfg2jxkm878pi40fw"))
+ (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"
+ "assimp"
+ "certs"
+ "cvtt"
+ "embree"
+ "enet"
+ "etc2comp"
+ "fonts"
+ "glad"
+ "jpeg-compressor"
+ "libsimplewebm"
+ "minimp3"
+ "miniupnpc"
+ "minizip"
+ "misc"
+ "nanosvg"
+ "oidn"
+ "pvrtccompressor"
+ "recastnavigation"
+ "squish"
+ "stb_rect_pack"
+ "tinyexr"
+ "vhacd"
+ "xatlas")))
+ (for-each delete-file-recursively
+ (lset-difference string=?
+ (scandir ".")
+ (cons* "." ".." preserved-files)))))))))
+ (build-system scons-build-system)
+ (arguments
+ `(#:scons ,scons-python2
+ #:scons-flags (list "platform=x11" "target=release_debug"
+ ;; Avoid using many of the bundled libs.
+ ;; Note: These options can be found in the SConstruct file.
+ "builtin_bullet=no"
+ "builtin_freetype=no"
+ "builtin_glew=no"
+ "builtin_libmpdec=no"
+ "builtin_libogg=no"
+ "builtin_libpng=no"
+ "builtin_libtheora=no"
+ "builtin_libvorbis=no"
+ "builtin_libvpx=no"
+ "builtin_libwebp=no"
+ "builtin_mbedtls=no"
+ "builtin_opus=no"
+ "builtin_pcre2=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)")))))
+ ;; Build headless tools, used for packaging games without depending on X.
+ (add-after 'build 'build-headless
+ (lambda* (#:key scons-flags #:allow-other-keys)
+ (apply invoke "scons"
+ `(,(string-append "-j" (number->string (parallel-job-count)))
+ "platform=server" ,@(delete "platform=x11" scons-flags)))))
+ (replace 'install
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out"))
+ (headless (assoc-ref outputs "headless"))
+ (zenity (assoc-ref inputs "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.*\\.x11\\.opt\\.tools.*"))
+ (install-file "godot" (string-append out "/bin"))
+ (install-file "godot_server" (string-append headless "/bin")))
+ ;; Tell the editor where to find zenity for OS.alert().
+ (wrap-program (string-append out "/bin/godot")
+ `("PATH" ":" prefix (,(string-append zenity "/bin")))))))
+ (add-after 'install 'wrap
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ ;; FIXME: Mesa tries to dlopen libudev.so.0 and fails. Pending a
+ ;; fix of the mesa package we wrap the pcb executable such that
+ ;; Mesa can find libudev.so.0 through LD_LIBRARY_PATH.
+ ;; also append ld path for pulseaudio and alsa-lib
+ (let* ((out (assoc-ref outputs "out"))
+ (udev_path (string-append (assoc-ref inputs "eudev") "/lib"))
+ (pulseaudio_path (string-append (assoc-ref inputs "pulseaudio") "/lib"))
+ (alas_lib_path (string-append (assoc-ref inputs "alsa-lib") "/lib")))
+ (wrap-program (string-append out "/bin/godot")
+ `("LD_LIBRARY_PATH" ":" prefix (,udev_path ,pulseaudio_path ,alas_lib_path))))))
+ (add-after 'install 'install-godot-desktop
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out"))
+ (applications (string-append out "/share/applications"))
+ (icons (string-append out "/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")))))))))
+ (outputs '("out" "headless"))
+ (native-inputs
+ (list pkg-config))
+ (inputs
+ (list alsa-lib
+ bullet
+ freetype
+ glew
+ glu
+ libtheora
+ libvorbis
+ libvpx
+ libwebp
+ libx11
+ libxcursor
+ libxi
+ libxinerama
+ libxrandr
+ mbedtls-apache
+ mesa
+ opusfile
+ pcre2
+ pulseaudio
+ eudev ; FIXME: required by mesa
+ wslay
+ zenity
+ `(,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))