Subject: [PATCH, WIP] Add godot.
From: Christopher Allan Webber <[email-masked]>
To: [email-masked]
Date: Tue, 28 Feb 2017 22:46:16 -0600
List-Id: <debbugs-submit.debbugs.gnu.org>

This is still WIP, and unfortunately it doesn't work.  Here's the error
I got:

                 from ./drivers/pulseaudio/audio_driver_pulseaudio.h:36,
                 from platform/x11/os_x11.h:46,
                 from platform/x11/godot_x11.cpp:30:
  /gnu/store/iwgi9001dmmihrjg4rqhd6pa6788prjw-glibc-2.24/include/bits/local_lim.h:38:26: fatal error: linux/limits.h: No such file or directory
  #include <linux/limits.h>

I also get this if I try to build it outside the package, from a git
checkout of Godot.

I don't know why I'm experiencing this; I added linux-libre-headers as
an input.  It seems that I'm not the first one to experience this with
Guix packages... I ran across these:

  https://lists.gnu.org/archive/html/help-guix/2016-06/msg00130.html

(I don't think I need to include gcc-toolchain though)

  https://gnunet.org/bot/log/guix/2016-07-27
  https://gnunet.org/bot/log/guix/2016-08-03

looks like jlicht eventually found a solution, and lfam said
   <lfam> jlicht: Have you tried setting -I in #:make-flags or #:configure-flags?

... not sure how that helps with scons :)

Other potential issues:
 - bundles a number of packages (can they be easily unbundled?)
 - license field should probably reflect bundled packages
 - very badly snarfs a whole bunch of phases code from aria-maestosa,
   which itself suggests refactoring into a scons-build-system...

Nonetheless, uh, maybe it's a good starting point!

From 8fe2eb621c0cc4556c112b0bd42714200f1332b2 Mon Sep 17 00:00:00 2001
From: Christopher Allan Webber <[email-masked]>
Date: Tue, 28 Feb 2017 22:39:38 -0600
Subject: [PATCH] gnu: Add godot.

* gnu/packages/game-development.scm (godot): New variable.
---
 gnu/packages/game-development.scm | 69 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 69 insertions(+)

diff --git a/gnu/packages/game-development.scm b/gnu/packages/game-development.scm
index 619c2f1bc..2f03041b3 100644
--- a/gnu/packages/game-development.scm
+++ b/gnu/packages/game-development.scm
@@ -8,6 +8,7 @@
 ;;; Copyright © 2016 Kei Kebreau <[email-masked]>
 ;;; Copyright © 2016 Ricardo Wurmus <[email-masked]>
 ;;; Copyright © 2016 Julian Graham <[email-masked]>
+;;; Copyright © 2017 Christopher Allan Webber <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -60,6 +61,7 @@
   #:use-module (gnu packages gnome)
   #:use-module (gnu packages gtk)
   #:use-module (gnu packages sdl)
+  #:use-module (gnu packages tls)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages xiph)
   #:use-module (gnu packages lua)
@@ -619,3 +621,70 @@ to create fully featured games and multimedia programs in the python language.")
                    license:psfl
                    license:public-domain
                    license:lgpl2.1+))))
+
+(define-public godot
+  (package
+    (name "godot")
+    (version "2.1.2")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append
+                    "https://github.com/godotengine/godot/archive/"
+                    version "-stable.tar.gz"))
+              (sha256
+               (base32
+                "16ml6kf338qqiazc2swvla89zapg41qc1i00x25r1jpq94a17cr9"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:phases
+       ;; TODO: This is copy-pasta'ed from aria-maestosa :)
+       ;; TODO: Add scons-build-system and use it here.
+       (modify-phases %standard-phases
+         (delete 'configure)
+         (add-after 'unpack 'scons-propagate-environment
+           (lambda _
+             ;; By design, SCons does not, by default, propagate
+             ;; environment variables to subprocesses.  See:
+             ;; <http://comments.gmane.org/gmane.linux.distributions.nixos/4969>
+             ;; Here, we modify the SConstruct file to arrange for
+             ;; environment variables to be propagated.
+             (substitute* "SConstruct"
+               (("env = Environment\\(\\)")
+                "env = Environment(ENV=os.environ)")
+               ;; Scons errors out when copying subdirectories from Resources,
+               ;; so we move them instead.
+               (("Copy") "Move")
+               ;; We move the "score" and "Documentation" directories at once,
+               ;; so we have to ignore files contained therein.
+               (("if \".svn\" in file" line)
+                (string-append line
+                               " or \"score/\" in file"
+                               " or \"Documentation/\" in file")))
+             #t))
+         (replace 'build (lambda _ (zero? (system* "scons" "platform=x11"))))
+         (replace 'install
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out")))
+               (and
+                (zero? (system* "scons"
+                                (string-append "prefix=" out)
+                                "install")))))))))
+    (native-inputs `(("pkg-config" ,pkg-config)
+                     ("scons" ,scons)))
+    (inputs `(("libx11" ,libx11)
+              ("libxcursor" ,libxcursor)
+              ("libxinerama" ,libxinerama)
+              ("linux-libre-headers" ,linux-libre-headers)
+              ("mesa" ,mesa)
+              ("mesa-headers" ,mesa-headers)
+              ("glu" ,glu)
+              ("pulseaudio" ,pulseaudio)
+              ("freetype" ,freetype)
+              ("openssl" ,openssl)
+              ("libxrandr" ,libxrandr)))
+    (home-page "https://godotengine.org/")
+    (synopsis "Advanced 2d and 3d game engine")
+    (description "Godot is a 2d and 3d game engine which with a powerful
+visual interface.")
+    ;; TODO: Maybe list bundled libs
+    (license license:expat)))
-- 
2.11.0