[bug#76862,6/6] gnu: Add tic80.

Message ID f3e5e210d9049939923aca1946b0e09874692512.1741431068.git.iyzsong@member.fsf.org
State New
Headers
Series Add tic80 |

Commit Message

King, Spencer via Guix-patches" via March 8, 2025, 10:55 a.m. UTC
  From: 宋文武 <iyzsong@member.fsf.org>

* gnu/packages/game-development.scm (tic80): New variable.

Change-Id: I459d2a3270ac2524f7024d2aac32b954eba15c59
---
 gnu/packages/game-development.scm | 132 ++++++++++++++++++++++++++++++
 1 file changed, 132 insertions(+)
  

Patch

diff --git a/gnu/packages/game-development.scm b/gnu/packages/game-development.scm
index a026e114c4..3f01fbd192 100644
--- a/gnu/packages/game-development.scm
+++ b/gnu/packages/game-development.scm
@@ -34,6 +34,7 @@ 
 ;;; Copyright © 2024 Nicolas Graves <ngraves@ngraves.fr>
 ;;; Copyright © 2024 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2025 Sharlatan Hellseher <sharlatanus@gmail.com>
+;;; Copyright © 2025 宋文武 <iyzsong@envs.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -76,6 +77,7 @@  (define-module (gnu packages game-development)
   #:use-module (gnu packages bison)
   #:use-module (gnu packages boost)
   #:use-module (gnu packages build-tools)
+  #:use-module (gnu packages c)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages check)
   #:use-module (gnu packages curl)
@@ -101,7 +103,9 @@  (define-module (gnu packages game-development)
   #:use-module (gnu packages haskell-xyz)
   #:use-module (gnu packages icu4c)
   #:use-module (gnu packages image)
+  #:use-module (gnu packages javascript)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages lisp)
   #:use-module (gnu packages llvm)
   #:use-module (gnu packages lua)
   #:use-module (gnu packages m4)
@@ -122,12 +126,14 @@  (define-module (gnu packages game-development)
   #:use-module (gnu packages python-web)
   #:use-module (gnu packages python-xyz)
   #:use-module (gnu packages readline)
+  #:use-module (gnu packages ruby)
   #:use-module (gnu packages qt)
   #:use-module (gnu packages sdl)
   #:use-module (gnu packages serialization)
   #:use-module (gnu packages speech)
   #:use-module (gnu packages sphinx)
   #:use-module (gnu packages sqlite)
+  #:use-module (gnu packages squirrel)
   #:use-module (gnu packages stb)
   #:use-module (gnu packages swig)
   #:use-module (gnu packages texinfo)
@@ -135,6 +141,7 @@  (define-module (gnu packages game-development)
   #:use-module (gnu packages tls)
   #:use-module (gnu packages version-control)
   #:use-module (gnu packages video)
+  #:use-module (gnu packages vim)
   #:use-module (gnu packages vulkan)
   #:use-module (gnu packages web)
   #:use-module (gnu packages wxwidgets)
@@ -3710,6 +3717,131 @@  (define-public raylib
     (home-page "https://www.raylib.com/")
     (license license:zlib)))
 
+(define-public tic80
+  ;; Use an unreleased version for 'PREFER_SYSTEM_LIBRARIES'.
+  (let ((commit "fcfd7c9862e9157512bcab53affecd592b320131")
+        ;; These C libraries are used in source form by tic80.
+        (3rd/jsmn
+         (origin                        ;Expat
+           (method git-fetch)
+           (uri (git-reference
+                 (url "https://github.com/zserge/jsmn")
+                 (commit "25647e692c7906b96ffd2b05ca54c097948e879c")))
+           (file-name "jsmn-checkout")
+           (sha256
+            (base32
+             "19xgrap95a8ziicgd0c3fns51z1g4q06b5lb5pg76ah4ychhgg5p"))))
+        (3rd/blip-buf
+         (origin                        ;LGPL2.1+
+           (method git-fetch)
+           (uri (git-reference
+                 (url "https://github.com/nesbox/blip-buf")
+                 (commit "330226d9b55ecbeea644e17b5e0f096a165ca07e")))
+           (file-name "blip-buf-checkout")
+           (sha256
+            (base32
+             "0fycffd6pbh9ilmr032dlrwd6dhvpkjp2r9x98r0kmwqpxc4x90d"))))
+        (3rd/msf-gif
+         (origin                        ;Expat or Public Domain
+           (method url-fetch)
+           (uri (string-append
+                 "https://github.com/notnullnotvoid/msf_gif/releases/download/"
+                 "v2.3/msf_gif.h"))
+           (sha256
+            (base32
+             "1ivjwwqxqjfhm8caz1srkp8wx7fpzvpf7s26ifif7cryvqch8vnf")))))
+    (package
+      (name "tic80")
+      (version (git-version "1.2.0" "1" commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/nesbox/TIC-80")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32
+           "17zxfiji6cb9ad7j3l82bdig0k7bz77bzwg7m0vd9ywrwk0kgxjk"))
+         (modules '((guix build utils)))
+         (snippet
+          #~(begin
+              (delete-file-recursively "vendor")
+              (copy-recursively #$3rd/jsmn "vendor/jsmn")
+              (copy-recursively #$3rd/blip-buf "vendor/blip-buf")
+              (mkdir "vendor/msf_gif")
+              (copy-file #$3rd/msf-gif "vendor/msf_gif/msf_gif.h")))))
+      (build-system cmake-build-system)
+      (arguments
+       (list #:tests? #f                ;no tests
+             #:configure-flags
+             #~'("-DBUILD_STATIC=ON" ;don't build runtimes as shared libraries
+                 "-DPREFER_SYSTEM_LIBRARIES=ON"
+                 "-DCMAKE_EXE_LINKER_FLAGS=-lpulse" ;for miniaudio
+                 ;; TODO: moon, python, wren
+                 "-DBUILD_WITH_FENNEL=ON"
+                 "-DBUILD_WITH_JANET=ON"
+                 "-DBUILD_WITH_JS=ON"
+                 "-DBUILD_WITH_LUA=ON"
+                 "-DBUILD_WITH_RUBY=ON"
+                 "-DBUILD_WITH_SCHEME=ON"
+                 "-DBUILD_WITH_SQUIRREL=ON"
+                 "-DBUILD_WITH_WASM=ON")
+             #:phases
+             #~(modify-phases %standard-phases
+                 (add-after 'unpack 'prepare-sources
+                   (lambda _
+                     (let* ((s7 #$(this-package-input "s7"))
+                            (fennel #$(this-package-input "fennel")))
+                       (install-file (string-append s7 "/include/s7.h")
+                                     "vendor/s7/")
+                       (install-file (string-append s7 "/share/s7/s7.c")
+                                     "vendor/s7/")
+                       (mkdir "vendor/fennel")
+                       (copy-file (car (find-files fennel "fennel\\.lua"))
+                                  "vendor/fennel/loadfennel.lua")
+                       (with-directory-excursion "vendor/fennel"
+                         (substitute* "loadfennel.lua"
+                           (("return mod") "package.loaded['fennel'] = mod"))
+                         (invoke "xxd" "-i" "loadfennel.lua" "fennel.h")))
+                     (substitute* "src/api/mruby.c"
+                       (("#include <mruby\\.h>" all)
+                        (string-append
+                         all "\n#include <mruby/internal.h>")))
+                     (substitute* "src/ext/fft.c"
+                       (("#include \"miniaudio\\.h\"") "
+#define MA_NO_RUNTIME_LINKING
+#define MA_ENABLE_ONLY_SPECIFIC_BACKENDS
+#define MA_ENABLE_PULSEAUDIO
+#define MA_ENABLE_NULL
+#include \"miniaudio.h\"
+")))))))
+      (native-inputs
+       (list pkg-config xxd))
+      (inputs
+       (list argparse
+             fennel
+             giflib
+             janet
+             kubazip
+             libpng
+             lua
+             mruby
+             naett
+             pulseaudio
+             quickjs
+             s7
+             sdl2
+             squirrel
+             wasm3))
+      (synopsis "Fantasy tiny computer")
+      (home-page "https://tic80.com/")
+      (description
+       "TIC-80 is a fantasy computer for making, playing and sharing tiny
+games.  There are built-in tools for development: code, sprites, maps, sound
+editors and the command line, which is enough to create a mini retro game.")
+      (license license:expat))))
+
 (define-public bbcsdl
   (package
     (name "bbcsdl")