gnu: godot: Build and install the headless version.

* gnu/packages/game-development.scm (godot): Build the headless (server)
binary. This is needed to package games using Godot without depending on X.
[outputs]: Add "headless".
[arguments]<#:phases>[build-headless]: New phase.
[arguments]<#:phases>[install]: Install headless version to separate output.

Signed-off-by: Nicolas Goaziou <mail@nicolasgoaziou.fr>
This commit is contained in:
Timotej Lazar 2020-05-17 17:55:18 +02:00 committed by Nicolas Goaziou
parent 6028541e61
commit 545511df77
No known key found for this signature in database
GPG key ID: DA00B4F048E92F2D

View file

@ -1604,7 +1604,7 @@ (define-public godot
"builtin_wslay=no" "builtin_wslay=no"
"builtin_zlib=no" "builtin_zlib=no"
"builtin_zstd=no") "builtin_zstd=no")
#:tests? #f ; There are no tests #:tests? #f ; There are no tests
#:phases #:phases
(modify-phases %standard-phases (modify-phases %standard-phases
(add-after 'unpack 'scons-use-env (add-after 'unpack 'scons-use-env
@ -1617,20 +1617,30 @@ (define-public godot
"env_base = Environment(tools=custom_tools)\n" "env_base = Environment(tools=custom_tools)\n"
"env_base = Environment(ENV=os.environ)"))) "env_base = Environment(ENV=os.environ)")))
#t)) #t))
;; 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 (replace 'install
(lambda* (#:key outputs #:allow-other-keys) (lambda* (#:key inputs outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out")) (let* ((out (assoc-ref outputs "out"))
(bin (string-append out "/bin"))) (headless (assoc-ref outputs "headless"))
(zenity (assoc-ref inputs "zenity")))
;; Strip build info from filenames.
(with-directory-excursion "bin" (with-directory-excursion "bin"
(if (file-exists? "godot.x11.tools.64") (for-each
(rename-file "godot.x11.tools.64" "godot") (lambda (file)
(rename-file "godot.x11.tools.32" "godot")) (let ((dest (car (string-split (basename file) #\.))))
(install-file "godot" bin)) (rename-file file dest)))
;; Tell Godot where to find zenity for OS.alert(). (find-files "." "godot.*\\.x11\\.opt\\.tools.*"))
(wrap-program (string-append bin "/godot") (install-file "godot" (string-append out "/bin"))
`("PATH" ":" prefix (install-file "godot_server" (string-append headless "/bin")))
(,(string-append (assoc-ref %build-inputs "zenity") "/bin")))) ;; Tell the editor where to find zenity for OS.alert().
#t))) (wrap-program (string-append out "/bin/godot")
`("PATH" ":" prefix (,(string-append zenity "/bin")))))
#t))
(add-after 'install 'install-godot-desktop (add-after 'install 'install-godot-desktop
(lambda* (#:key outputs #:allow-other-keys) (lambda* (#:key outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out")) (let* ((out (assoc-ref outputs "out"))
@ -1652,6 +1662,7 @@ (define-public godot
Type=Application~%" Type=Application~%"
out))) out)))
#t)))))) #t))))))
(outputs '("out" "headless"))
(native-inputs `(("pkg-config" ,pkg-config))) (native-inputs `(("pkg-config" ,pkg-config)))
(inputs `(("alsa-lib" ,alsa-lib) (inputs `(("alsa-lib" ,alsa-lib)
("bullet" ,bullet) ("bullet" ,bullet)