Subject: Re: [bug#36978] [PATCH 0/3] Add Unknown Horizons and dependencies

From: Arun Isaac <[email-masked]>
Date: Mon, 26 Aug 2019 16:47:08 +0530

> fifengine and unknown-horizons do have tests, though. Could you try
> packaging them?

I had some WIP on packaging unknown-horizons and dependencies. I have
attached my unfinished patches. Perhaps that could be of some use to
you.

From 8e0dc413770628873ca2bcca4b1127f1fc4de4fb Mon Sep 17 00:00:00 2001
From: Arun Isaac <[email-masked]>
Date: Mon, 26 Aug 2019 16:40:28 +0530
Subject: [PATCH 1/3] gnu: Add fifechan.

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

diff --git a/gnu/packages/game-development.scm b/gnu/packages/game-development.scm
index 7eac935a69..6debaccb85 100644
--- a/gnu/packages/game-development.scm
+++ b/gnu/packages/game-development.scm
@@ -80,6 +80,7 @@
   #:use-module (gnu packages qt)
   #:use-module (gnu packages sdl)
   #:use-module (gnu packages stb)
+  #:use-module (gnu packages swig)
   #:use-module (gnu packages texinfo)
   #:use-module (gnu packages tls)
   #:use-module (gnu packages video)
@@ -1539,3 +1540,37 @@ projects.")
 hardware from multiple vendors without requiring that applications have
 specific knowledge of the hardware they are targeting.")
     (license license:bsd-3)))
+
+(define-public fifechan
+  (package
+    (name "fifechan")
+    (version "0.1.5")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/fifengine/fifechan")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "0hd34b9crs2hv0rxmvhn0m73q9ss4rxj2vq6ba2x01vqy1hrjfcg"))))
+    (build-system cmake-build-system)
+    (inputs
+     `(("sdl2-image" ,sdl2-image)))
+    (arguments
+     `(#:tests? #f))
+    (home-page "https://fifengine.github.io/fifechan/")
+    (synopsis "Lightweight cross platform GUI library specifically for games")
+    (description "Fifechan is a lightweight cross platform GUI library written
+in C++ specifically designed for games.  It has a small yet powerful built in
+set of extendable GUI Widgets allowing users to create virtually unlimited
+types of widgets.  Fifechan supports rendering in SDL, OpenGL, or Allegro out
+of the box or it can be adapted to use any rendering engine the user requires.
+Events are pushed to Fifechan which allows users to use any input library they
+wish or they could use the built in input handling through either SDL input or
+Allegro input.  The primary goal for Fifechan is to keep it extendable,
+lightweight and still be powerful enough to use in all types of games out of
+the box.")
+    ;; FIXME: incorrect
+    (license license:lgpl2.1+)))
-- 
2.22.0

From 1772e12b871aca615652e0e13bda2b11324c472f Mon Sep 17 00:00:00 2001
From: Arun Isaac <[email-masked]>
Date: Mon, 26 Aug 2019 16:40:59 +0530
Subject: [PATCH 2/3] gnu: Add fifengine.

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

diff --git a/gnu/packages/game-development.scm b/gnu/packages/game-development.scm
index 6debaccb85..808d3d3ade 100644
--- a/gnu/packages/game-development.scm
+++ b/gnu/packages/game-development.scm
@@ -1574,3 +1574,68 @@ lightweight and still be powerful enough to use in all types of games out of
 the box.")
     ;; FIXME: incorrect
     (license license:lgpl2.1+)))
+
+(define-public fifengine
+  (package
+    (name "fifengine")
+    (version "0.4.2")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/fifengine/fifengine")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "0vi84daj8jmhqq9lhsc3qjbmp0r2askzlzr1iv1iwn8i2qircil4"))))
+    (build-system cmake-build-system)
+    (inputs
+     `(("boost" ,boost)
+       ("fifechan" ,fifechan)
+       ("glew" ,glew)
+       ("libvorbis" ,libvorbis)
+       ("openal" ,openal)
+       ("python" ,python)
+       ("sdl-union" ,(sdl-union (list sdl2 sdl2-image sdl2-ttf)))
+       ("tinyxml" ,tinyxml)))
+    (native-inputs
+     `(("python" ,python)
+       ("swig" ,swig)
+       ("xvfb" ,xorg-server)))
+    (arguments
+     `(#:configure-flags
+       (list (string-append "-DOPENALSOFT_INCLUDE_DIR="
+                            (assoc-ref %build-inputs "openal") "/include")
+             (string-append "-DPYTHON_SITE_PACKAGES="
+                            %output "/lib/python3.7/site-packages")
+             "-Dbuild-library=ON")
+       #:phases
+       (modify-phases %standard-phases
+         ;; Run tests after installation so that we can make use of the built
+         ;; python modules.
+         (delete 'check)
+         (add-after 'install 'check
+           (lambda* (#:key outputs #:allow-other-keys)
+             ;; Set PYTHONPATH so that python finds the installed modules.
+             (setenv "PYTHONPATH"
+                     (string-append (getenv "PYTHONPATH") ":"
+                                    (assoc-ref outputs "out")
+                                    "/lib/python3.7/site-packages"))
+             ;; The tests require an X server.
+             (system "Xvfb :1 &")
+             (setenv "DISPLAY" ":1")
+             (setenv "XDG_RUNTIME_DIR" "/tmp")
+             ;; Run tests
+             (chdir "../source")
+             (invoke "python3" "run_tests.py" "-a"))))))
+    (home-page "https://www.fifengine.net/")
+    (synopsis "Cross platform game engine")
+    (description "FIFE is a cross-platform game engine.  It features
+hardware-accelerated 2D graphics, integrated GUI, audio support, lighting, map
+editor supporting top-down and isometric maps, pathfinding, virtual filesystem
+and more.  Games utilizing FIFE are programmed through Python scripting layer
+on top of the base C++ API.  Games can be also programmed using the C++ layer
+directly.")
+    ;; FIXME: incorrect license
+    (license license:lgpl2.1+)))
-- 
2.22.0

From cb3f833c38e948d1b45513124a786e81a2f70911 Mon Sep 17 00:00:00 2001
From: Arun Isaac <[email-masked]>
Date: Mon, 26 Aug 2019 16:41:45 +0530
Subject: [PATCH 3/3] gnu: Add unknown-horizons.

* gnu/packages/games.scm (unknown-horizons): New variable.
---
 gnu/packages/games.scm | 67 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)

diff --git a/gnu/packages/games.scm b/gnu/packages/games.scm
index 870becc50b..f49b451bbd 100644
--- a/gnu/packages/games.scm
+++ b/gnu/packages/games.scm
@@ -7637,3 +7637,70 @@ remake of that series or any other game.")
 the AlphaGo Zero paper.  The current best network weights file for the engine
 can be downloaded from @url{https://zero.sjeng.org/best-network}.")
    (license license:gpl3+)))
+
+(define-public unknown-horizons
+  (package
+    (name "unknown-horizons")
+    (version "2019.1")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/unknown-horizons/unknown-horizons")
+             (commit version)))
+       (sha256
+        (base32
+         "1khq9ajwi0fmphsjpa024v1px47mcjzvvx2vnrpz1fkis34y83h0"))))
+    (build-system python-build-system)
+    (inputs
+     `(("fifengine" ,fifengine)
+       ("python:tk" ,python "tk")
+       ("python-future" ,python-future)
+       ("python-pyyaml" ,python-pyyaml)))
+    (native-inputs
+     `(("intltool" ,intltool)
+       ;; required during the generate-atlases phase
+       ("python-pillow" ,python-pillow)
+
+       ;; required for tests
+       ("python-greenlet" ,python-greenlet)
+       ("python-polib" ,python-polib)
+       ("python-pytest" ,python-pytest)
+       ("python-pytest-mock" ,python-pytest-mock)))
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-before 'build 'configure
+           (lambda* (#:key outputs #:allow-other-keys)
+             (substitute* "run_uh.py"
+               (("options = \\[\\]")
+                (string-append "options = ['" (assoc-ref outputs "out")
+                               "/share/unknown-horizons']")))
+             #t))
+         (add-before 'build 'set-home
+           (lambda _
+             (setenv "HOME" "/tmp")
+             #t))
+         (add-before 'build 'generate-atlases
+           (lambda _
+             (invoke "python3" "horizons/engine/generate_atlases.py" "2048")))
+         ;; TODO: Run gui tests as well
+         (replace 'check
+           (lambda _
+             (substitute* "horizons/constants.py"
+               (("IS_DEV_VERSION = False")
+                "IS_DEV_VERSION = True"))
+             (invoke "pytest" "tests")
+             (substitute* "horizons/constants.py"
+               (("IS_DEV_VERSION = True")
+                "IS_DEV_VERSION = False"))
+             #t)))))
+    (home-page "http://unknown-horizons.org")
+    (synopsis "2D realtime strategy simulation game")
+    (description "Unknown Horizons is a 2D realtime strategy simulation game
+with an emphasis on economy and city building.  Expand your small settlement
+to a strong and wealthy colony, collect taxes and supply your inhabitants with
+valuable goods.  Increase your power with a well balanced economy and with
+strategic trade and diplomacy.")
+    ;; FIXME: fix license
+    (license license:gpl2)))
-- 
2.22.0