[PATCH 0/5] Add superstarfighter

  • Done
  • quality assurance status badge
Details
3 participants
  • Nicolò Balzarotti
  • Nicolas Goaziou
  • Timotej Lazar
Owner
unassigned
Submitted by
Timotej Lazar
Severity
normal
T
T
Timotej Lazar wrote on 17 May 2020 17:52
(address . guix-patches@gnu.org)
878shqr23j.fsf@araneo.si
Hi,

this series adds SuperStarfighter¹, a small game built with the Godot
engine. I’m submitting it together with patches for godot needed to
build the game, and some other improvements. I built the game for x86,
x86_64 and aarch64 (can’t run it there due to missing 3D acceleration).

The main change to godot is building the headless binary, which is used
to compile game assets without requiring X. I put this into a separate
output because it doubles the install size. Compile time is also nearly
doubled, since most files get compiled twice.

If the longer compile time (in total ~20 minutes on an old i7, and
~80 minutes on an even older core duo) is problematic, this can be split
in two packages. The game depends on both versions to build and run
though. Thoughts?

I also enabled release build for Godot, removed an old workaround for
aarch64 (disabling threads caused an infinite loop when building the
game), and installed the icons to the correct location to be used with
the .desktop file.

Thanks!


Timotej Lazar (5):
gnu: godot: Enable release build.
gnu: godot: Remove obsolete workaround for aarch64.
gnu: godot: Build and install the headless version.
gnu: godot: Install provided .desktop file and icons.
gnu: Add superstarfighter.

gnu/packages/game-development.scm | 68 ++++++++++++++--------------
gnu/packages/games.scm | 75 +++++++++++++++++++++++++++++++
2 files changed, 109 insertions(+), 34 deletions(-)

--
2.26.2
T
T
Timotej Lazar wrote on 17 May 2020 17:55
[PATCH 2/5] gnu: godot: Remove obsolete workaround for aarch64.
(address . 41365@debbugs.gnu.org)(name . Timotej Lazar)(address . timotej.lazar@araneo.si)
20200517155520.26183-2-timotej.lazar@araneo.si
* gnu/packages/game-development.scm (godot)[arguments]: Remove -DNO_THREADS
from scons-flags as Godot now builds and runs without it on aarch64.
---
gnu/packages/game-development.scm | 4 ----
1 file changed, 4 deletions(-)

Toggle diff (17 lines)
diff --git a/gnu/packages/game-development.scm b/gnu/packages/game-development.scm
index dfa55b136f..d84b3fb24a 100644
--- a/gnu/packages/game-development.scm
+++ b/gnu/packages/game-development.scm
@@ -1586,10 +1586,6 @@ games.")
(arguments
`(#:scons ,scons-python2
#:scons-flags (list "platform=x11" "target=release_debug"
- ,@(if (string-prefix? "aarch64" (or (%current-target-system)
- (%current-system)))
- `("CCFLAGS=-DNO_THREADS")
- '())
;; Avoid using many of the bundled libs.
;; Note: These options can be found in the SConstruct file.
"builtin_bullet=no"
--
2.26.2
T
T
Timotej Lazar wrote on 17 May 2020 17:55
[PATCH 1/5] gnu: godot: Enable release build.
(address . 41365@debbugs.gnu.org)(name . Timotej Lazar)(address . timotej.lazar@araneo.si)
20200517155520.26183-1-timotej.lazar@araneo.si
* gnu/packages/game-development.scm (godot)[arguments]: Set release_debug
target in #:scons-flags to enable optimized build.
---
gnu/packages/game-development.scm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Toggle diff (15 lines)
diff --git a/gnu/packages/game-development.scm b/gnu/packages/game-development.scm
index 26aa4f714b..dfa55b136f 100644
--- a/gnu/packages/game-development.scm
+++ b/gnu/packages/game-development.scm
@@ -1585,7 +1585,7 @@ games.")
(build-system scons-build-system)
(arguments
`(#:scons ,scons-python2
- #:scons-flags (list "platform=x11"
+ #:scons-flags (list "platform=x11" "target=release_debug"
,@(if (string-prefix? "aarch64" (or (%current-target-system)
(%current-system)))
`("CCFLAGS=-DNO_THREADS")
--
2.26.2
T
T
Timotej Lazar wrote on 17 May 2020 17:55
[PATCH 3/5] gnu: godot: Build and install the headless version.
(address . 41365@debbugs.gnu.org)(name . Timotej Lazar)(address . timotej.lazar@araneo.si)
20200517155520.26183-3-timotej.lazar@araneo.si
* 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.
---
gnu/packages/game-development.scm | 32 ++++++++++++++++++++-----------
1 file changed, 21 insertions(+), 11 deletions(-)

Toggle diff (55 lines)
diff --git a/gnu/packages/game-development.scm b/gnu/packages/game-development.scm
index d84b3fb24a..2ed3055cfc 100644
--- a/gnu/packages/game-development.scm
+++ b/gnu/packages/game-development.scm
@@ -1617,20 +1617,29 @@ games.")
"env_base = Environment(tools=custom_tools)\n"
"env_base = Environment(ENV=os.environ)")))
#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
- (lambda* (#:key outputs #:allow-other-keys)
+ (lambda* (#:key inputs outputs #:allow-other-keys)
(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"
- (if (file-exists? "godot.x11.tools.64")
- (rename-file "godot.x11.tools.64" "godot")
- (rename-file "godot.x11.tools.32" "godot"))
- (install-file "godot" bin))
- ;; Tell Godot where to find zenity for OS.alert().
- (wrap-program (string-append bin "/godot")
- `("PATH" ":" prefix
- (,(string-append (assoc-ref %build-inputs "zenity") "/bin"))))
- #t)))
+ (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")))))
+ #t))
(add-after 'install 'install-godot-desktop
(lambda* (#:key outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
@@ -1652,6 +1661,7 @@ games.")
Type=Application~%"
out)))
#t))))))
+ (outputs '("out" "headless"))
(native-inputs `(("pkg-config" ,pkg-config)))
(inputs `(("alsa-lib" ,alsa-lib)
("bullet" ,bullet)
--
2.26.2
T
T
Timotej Lazar wrote on 17 May 2020 17:55
[PATCH 5/5] gnu: Add superstarfighter.
(address . 41365@debbugs.gnu.org)(name . Timotej Lazar)(address . timotej.lazar@araneo.si)
20200517155520.26183-5-timotej.lazar@araneo.si
* gnu/packages/games.scm (superstarfighter): New variable.
---
gnu/packages/games.scm | 75 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 75 insertions(+)

Toggle diff (88 lines)
diff --git a/gnu/packages/games.scm b/gnu/packages/games.scm
index 177436e6ec..b893ba8cc4 100644
--- a/gnu/packages/games.scm
+++ b/gnu/packages/games.scm
@@ -1733,6 +1733,81 @@ can be explored and changed freely.")
license:gpl3+
license:silofl1.1))))
+(define-public superstarfighter
+ (package
+ (name "superstarfighter")
+ (version "0.6.4")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/notapixelstudio/superstarfighter.git")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "1fly63yf5ls1xwm15if4lxwy67wi84k4gvjllljpykrl18vw2y0y"))))
+ (build-system gnu-build-system)
+ (arguments
+ `(#:tests? #f ; There are no tests.
+ #:phases
+ (modify-phases %standard-phases
+ (replace 'configure
+ (lambda _
+ (chdir "godot")
+ (setenv "HOME" (getcwd))
+ (with-output-to-file "export_presets.cfg"
+ (lambda ()
+ (display
+ "[preset.0]
+name=\"Guix\"
+platform=\"Linux/X11\"
+runnable=true
+[preset.0.options]")))
+ #t))
+ (replace 'build
+ (lambda _
+ (let ((godot (assoc-ref %build-inputs "godot-headless")))
+ (invoke (string-append godot "/bin/godot_server")
+ "--export-pack" "Guix"
+ "superstarfighter.pck" "project.godot"))
+ #t))
+ (replace 'install
+ (lambda _
+ (let* ((out (assoc-ref %outputs "out"))
+ (bin (string-append out "/bin"))
+ (share (string-append out "/share/superstarfighter"))
+ (icons (string-append out "/share/icons/hicolor/256x256/apps")))
+ (install-file "superstarfighter.pck" share)
+ (mkdir-p bin)
+ (call-with-output-file (string-append bin "/superstarfighter")
+ (lambda (port)
+ (format port "#!/bin/sh
+exec ~a/bin/godot --main-pack ~a/superstarfighter.pck"
+ (assoc-ref %build-inputs "godot")
+ share)
+ (chmod port #o755)))
+ (mkdir-p icons)
+ (copy-file "icon.png" (string-append icons "/" ,name ".png"))
+ (make-desktop-entry-file
+ (string-append out "/share/applications/" ,name ".desktop")
+ #:name "SuperStarfighter"
+ #:comment "Fast-paced arcade combat game"
+ #:exec ,name
+ #:icon ,name
+ #:categories '("Game" "ArcadeGame")))
+ #t)))))
+ (native-inputs
+ `(("godot-headless" ,godot "headless")))
+ (inputs
+ `(("godot" ,godot)))
+ (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
+2D arena with fast-moving ships and missiles. Different game types are
+available, as well as a single-player mode with AI-controlled ships.")
+ (license (list license:expat ; game
+ license:silofl1.1)))) ; fonts
+
(define-public xshogi
(package
(name "xshogi")
--
2.26.2
N
N
Nicolò Balzarotti wrote on 17 May 2020 17:55
Re: [bug#41365] [PATCH 0/5] Add superstarfighter
87pnb2wo74.fsf@guixSD.i-did-not-set--mail-host-address--so-tickle-me
Hi! This is nice to have.

If other godot games can be built this way, does it make sense to create
a godot-build-system?

Thanks, Nicolò

Timotej Lazar <timotej.lazar@araneo.si> writes:

Toggle quote (39 lines)
> Hi,
>
> this series adds SuperStarfighter¹, a small game built with the Godot
> engine. I’m submitting it together with patches for godot needed to
> build the game, and some other improvements. I built the game for x86,
> x86_64 and aarch64 (can’t run it there due to missing 3D acceleration).
>
> The main change to godot is building the headless binary, which is used
> to compile game assets without requiring X. I put this into a separate
> output because it doubles the install size. Compile time is also nearly
> doubled, since most files get compiled twice.
>
> If the longer compile time (in total ~20 minutes on an old i7, and
> ~80 minutes on an even older core duo) is problematic, this can be split
> in two packages. The game depends on both versions to build and run
> though. Thoughts?
>
> I also enabled release build for Godot, removed an old workaround for
> aarch64 (disabling threads caused an infinite loop when building the
> game), and installed the icons to the correct location to be used with
> the .desktop file.
>
> Thanks!
>
> ¹ https://notapixel.itch.io/superstarfighter
>
> Timotej Lazar (5):
> gnu: godot: Enable release build.
> gnu: godot: Remove obsolete workaround for aarch64.
> gnu: godot: Build and install the headless version.
> gnu: godot: Install provided .desktop file and icons.
> gnu: Add superstarfighter.
>
> gnu/packages/game-development.scm | 68 ++++++++++++++--------------
> gnu/packages/games.scm | 75 +++++++++++++++++++++++++++++++
> 2 files changed, 109 insertions(+), 34 deletions(-)
>
> --
> 2.26.2
T
T
Timotej Lazar wrote on 17 May 2020 17:55
[PATCH 4/5] gnu: godot: Install provided .desktop file and icons.
(address . 41365@debbugs.gnu.org)(name . Timotej Lazar)(address . timotej.lazar@araneo.si)
20200517155520.26183-4-timotej.lazar@araneo.si
* gnu/packages/game-development.scm (godot)[arguments]: Install the provided
godot.desktop instead of creating a new one. Copy icons to the correct
location in share/icons/hicolor as per XDG.
---
gnu/packages/game-development.scm | 30 ++++++++++++------------------
1 file changed, 12 insertions(+), 18 deletions(-)

Toggle diff (43 lines)
diff --git a/gnu/packages/game-development.scm b/gnu/packages/game-development.scm
index 2ed3055cfc..1cbe0e4f0d 100644
--- a/gnu/packages/game-development.scm
+++ b/gnu/packages/game-development.scm
@@ -1643,24 +1643,18 @@ games.")
(add-after 'install 'install-godot-desktop
(lambda* (#:key outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
- (desktop (string-append out "/share/applications"))
- (icon-dir (string-append out "/share/pixmaps")))
- (rename-file "icon.png" "godot.png")
- (install-file "godot.png" icon-dir)
- (mkdir-p desktop)
- (with-output-to-file
- (string-append desktop "/godot.desktop")
- (lambda _
- (format #t
- "[Desktop Entry]~@
- Name=godot~@
- Comment=The godot game engine~@
- Exec=~a/bin/godot~@
- TryExec=~@*~a/bin/godot~@
- Icon=godot~@
- Type=Application~%"
- out)))
- #t))))))
+ (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"))))
+ #t)))))
(outputs '("out" "headless"))
(native-inputs `(("pkg-config" ,pkg-config)))
(inputs `(("alsa-lib" ,alsa-lib)
--
2.26.2
T
T
Timotej Lazar wrote on 17 May 2020 18:03
Re: [bug#41365] [PATCH 0/5] Add superstarfighter
(address . 41365@debbugs.gnu.org)(name . Nicolò Balzarotti)(address . anothersms@gmail.com)
875zcur1k9.fsf@araneo.si
Nicolò Balzarotti <anothersms@gmail.com> [2020-05-17 17:55:43+0200]:
Toggle quote (3 lines)
> If other godot games can be built this way, does it make sense to create
> a godot-build-system?

I think so. At least the configure and build phases should be mostly the
same. I figured I’d submit this to see if anything can be improved, then
try to package a couple more games and see what can be factored out.
N
N
Nicolas Goaziou wrote on 18 May 2020 20:53
(name . Timotej Lazar)(address . timotej.lazar@araneo.si)(address . 41365-done@debbugs.gnu.org)
871rnhula8.fsf@nicolasgoaziou.fr
Hello,

Timotej Lazar <timotej.lazar@araneo.si> writes:

Toggle quote (6 lines)
> this series adds SuperStarfighter¹, a small game built with the Godot
> engine. I’m submitting it together with patches for godot needed to
> build the game, and some other improvements. I built the game for x86,
> x86_64 and aarch64 (can’t run it there due to missing 3D
> acceleration).

Great. Thank you.

Toggle quote (10 lines)
> The main change to godot is building the headless binary, which is used
> to compile game assets without requiring X. I put this into a separate
> output because it doubles the install size. Compile time is also nearly
> doubled, since most files get compiled twice.
>
> If the longer compile time (in total ~20 minutes on an old i7, and
> ~80 minutes on an even older core duo) is problematic, this can be split
> in two packages. The game depends on both versions to build and run
> though. Thoughts?

I think 80 minutes is not that bad. We can reconsider later.

Toggle quote (5 lines)
> I also enabled release build for Godot, removed an old workaround for
> aarch64 (disabling threads caused an infinite loop when building the
> game), and installed the icons to the correct location to be used with
> the .desktop file.

Perfect.

I applied your patches with minor tweaks.

Regards,

--
Nicolas Goaziou
Closed
?