Subject: [PATCH 2/2] gnu: Add ps1 homebrew development kit

From: [email-masked]
Date: Sun, 15 Sep 2024 22:03:31 +0300

From: Manolis Ragkousis <[email-masked]>

* gnu/packages/game-development.scm (miniaudio): New variable.
  (miniaudio-0.10.43): New variable.
  (gulrak-filesystem): New variable.
  (ThreadPool): New variable.
  (mkpsxiso): New variable.
  (psn00bsdk): New variable.

Change-Id: I96cbfa6bb91ed90b183297cc3118bb9411e11705
---
 gnu/packages/game-development.scm | 249 +++++++++++++++++++++++++++++-
 1 file changed, 248 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/game-development.scm b/gnu/packages/game-development.scm
index efbbabaaf5..af5d2506d9 100644
--- a/gnu/packages/game-development.scm
+++ b/gnu/packages/game-development.scm
@@ -9,7 +9,7 @@
 ;;; Copyright © 2016, 2018, 2019, 2024 Ricardo Wurmus <[email-masked]>
 ;;; Copyright © 2016, 2017, 2018 Julian Graham <[email-masked]>
 ;;; Copyright © 2017–2021 Tobias Geerinckx-Rice <[email-masked]>
-;;; Copyright © 2017 Manolis Fragkiskos Ragkousis <[email-masked]>
+;;; Copyright © 2017, 2024 Manolis Fragkiskos Ragkousis <[email-masked]>
 ;;; Copyright © 2017 Peter Mikkelsen <[email-masked]>
 ;;; Copyright © 2017 Arun Isaac <[email-masked]>
 ;;; Copyright © 2017, 2019 Rutger Helling <[email-masked]>
@@ -75,6 +75,7 @@ (define-module (gnu packages game-development)
   #:use-module (gnu packages check)
   #:use-module (gnu packages curl)
   #:use-module (gnu packages documentation)
+  #:use-module (gnu packages embedded)
   #:use-module (gnu packages fltk)
   #:use-module (gnu packages fonts)
   #:use-module (gnu packages fontutils)
@@ -82,6 +83,7 @@ (define-module (gnu packages game-development)
   #:use-module (gnu packages fribidi)
   #:use-module (gnu packages dbm)
   #:use-module (gnu packages gawk)
+  #:use-module (gnu packages gcc)
   #:use-module (gnu packages gettext)
   #:use-module (gnu packages gl)
   #:use-module (gnu packages glib)
@@ -3382,3 +3384,248 @@ (define-public bbcsdl
 allowing you to write utilities and games, use sound and graphics, perform
 calculations and create complete applications.")
     (license license:zlib)))
+
+(define-public miniaudio
+  (package
+    (name "miniaudio")
+    (version "0.11.21")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/mackron/miniaudio")
+                    (commit version)
+                    (recursive? #f)))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0hlqp44ifi3vswvfpqljj89321y6yz3zq6rng51wfq8p4n9k5qhh"))))
+    (build-system copy-build-system)
+    (arguments
+     (list #:tests? #f))
+    (synopsis "Audio playback and capture library for C and C++")
+    (description
+     "Miniaudio is a lightweight, single-file audio playback and capture
+library designed for use in C and C++ applications.  It features no external
+dependencies, making it highly portable and easy to integrate.")
+    (home-page "https://miniaud.io/")
+    (license license:expat-0)))
+
+(define-public miniaudio-0.10.43
+  (package (inherit miniaudio)
+    (name "miniaudio")
+    (version "0.10.43")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/mackron/miniaudio")
+                    (commit "8686f52e6625e562f4756b946696692c016324ab")
+                    (recursive? #f)))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0lv5gq23rspa3s9yqr3lhrfvbz63zcnkbxngsl2bgvj79x49vw9a"))))))
+
+(define-public gulrak-filesystem
+  (package
+    (name "gulrak-filesystem")
+    (version "v1.5.14")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/gulrak/filesystem")
+                    (commit version)
+                    (recursive? #f)))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0n1w2q0fp31z2l7g16ysc5nwyhmy3rj3hb89ganws0j84g3hi7ax"))))
+    (build-system copy-build-system)
+    (arguments
+     (list #:tests? #f))
+    (synopsis "Header-only single-file std::filesystem helper library for C++")
+    (description
+ "This library provides std::filesystem-compatible functionality for C++11,
+C++14, C++17, and C++20.  It is portable, tested on various platforms, and
+resides in the ghc::filesystem namespace to avoid conflicts with
+std::filesystem.")
+    (home-page "https://github.com/gulrak/filesystem")
+    (license license:expat)))
+
+(define-public ThreadPool
+  (package
+    (name "ThreadPool")
+    ;; No actual version in upstream
+    (version "v0.1")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/progschj/ThreadPool")
+                    (commit "9a42ec1329f259a5f4881a291db1dcb8f2ad9040")
+                    (recursive? #f)))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "020j6cgvl9aq2gs6fndl31w7wni7djwl90nw465bnmx0648ss89n"))))
+    (build-system copy-build-system)
+    (arguments
+     (list #:tests? #f))
+    (synopsis "Simple C++11 Thread Pool implementation")
+    (description
+     "A simple C++11 Thread Pool implementation.")
+    (home-page "https://github.com/progschj/ThreadPool")
+    (license license:expat)))
+
+(define-public mkpsxiso
+  (package
+    (name "mkpsxiso")
+    (version "v2.04")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/Lameguy64/mkpsxiso")
+                    (commit version)
+                    (recursive? #f)))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "19cs5i39qhgwabrcklm6dym9p1zqmsgfgv6hcfc5z207yzdc9qhl"))))
+    (build-system cmake-build-system)
+    (arguments
+     (list #:tests? #f  ;no test
+           #:configure-flags
+           #~(list "-DCMAKE_CXX_FLAGS=-fpermissive")
+           #:phases
+           #~(modify-phases %standard-phases
+               (add-after 'unpack 'copy-tinyxml2
+                 (lambda _
+                   (copy-recursively
+                    #$(package-source tinyxml2)
+                    "tinyxml2")))
+               (add-after 'copy-tinyxml2 'copy-miniaudio
+                 (lambda _
+                   (copy-recursively
+                    #$(package-source miniaudio-0.10.43)
+                    "miniaudio")))
+               (add-after 'copy-miniaudio 'copy-gulrak-filesystem
+                 (lambda _
+                   (copy-recursively
+                    #$(package-source gulrak-filesystem)
+                    "ghc")))
+               (add-after 'copy-gulrak-filesystem 'copy-threadpool
+                 (lambda _
+                   (copy-recursively
+                    #$(package-source ThreadPool)
+                    "ThreadPool")))
+               (add-after 'copy-threadpool 'copy-flac
+                 (lambda _
+                   (mkdir-p "flac")
+                   (with-directory-excursion "flac"
+                     (invoke "tar" "xvf" #$(package-source flac)
+                             "--strip-components=1")))))))
+    (inputs (list glfw pulseaudio))
+    (native-inputs
+     (list
+      pkg-config
+      tinyxml2
+      miniaudio-0.10.43
+      gulrak-filesystem
+      ThreadPool
+      flac
+      ninja))
+    (synopsis "Builds PlayStation CD images from an XML document")
+    (description
+     "MKPSXISO is capable of generating 2352 byte per sector ISO images with
+CD-DA audio tracks and mixed-mode CD-XA and interleaved data for streaming
+content.  It also uses XML with very simple to use directives for scripting the
+contents of the image project.")
+    (home-page "http://lameguy64.net/")
+    (license license:gpl2)))
+
+(define-public psn00bsdk
+  (package
+    (name "psn00bsdk")
+    (version "v0.24")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/Lameguy64/PSn00bSDK")
+                    (commit "702bb601fb5712e2ae962a34b89204c646fe98f5")
+                    (recursive? #f)))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "1nvy6lff4p54127awc4pl0a73myrgssihksvpaxamadzpk12vvl4"))))
+    (build-system cmake-build-system)
+    (arguments
+     (list #:tests? #f  ;no test
+           #:configure-flags
+           #~(list "-DCMAKE_BUILD_TYPE=Release"
+                   "-DSKIP_EXAMPLES=true"
+                   (string-append
+                    "-DCMAKE_ASM_FLAGS=-Wa,-I"
+                    #$source
+                    "/libpsn00b/include,-march=r3000"))
+           #:phases
+           #~(modify-phases %standard-phases
+               (add-after 'unpack 'patch-cmake
+                 (lambda _
+                   (substitute* "CMakeLists.txt"
+                     ;; Modify ExternalProject_Add for 'libpsn00b-debug'
+                     (("CMAKE_CACHE_ARGS[^\n]+-DCMAKE_BUILD_TYPE:STRING=Debug")
+                      (string-append
+                       "CMAKE_CACHE_ARGS ${_libpsn00b_args} -DCMAKE_BUILD_TYPE:STRING=Debug "
+                       "-DCMAKE_ASM_FLAGS:STRING=-Wa,-I"
+                       #$source "/libpsn00b/include,-march=r3000"))
+                     ;; Modify ExternalProject_Add for 'libpsn00b-release'
+                     (("CMAKE_CACHE_ARGS[^\n]+-DCMAKE_BUILD_TYPE:STRING=Release")
+                      (string-append
+                       "CMAKE_CACHE_ARGS ${_libpsn00b_args} -DCMAKE_BUILD_TYPE:STRING=Release "
+                       "-DCMAKE_ASM_FLAGS:STRING=-Wa,-I"
+                       #$source "/libpsn00b/include,-march=r3000")))))
+               (add-after 'patch-cmake 'copy-mkpsxiso
+                 (lambda _
+                   (copy-recursively
+                    #$(package-source mkpsxiso)
+                    "tools/mkpsxiso")))
+               (add-after 'copy-mkpsxiso 'copy-tinyxml2
+                 (lambda _
+                   (copy-recursively #$(package-source tinyxml2) "tools/tinyxml2")
+                   (with-directory-excursion "tools/mkpsxiso"
+                     (copy-recursively
+                      #$(package-source tinyxml2)
+                      "tinyxml2"))))
+               (add-after 'copy-tinyxml2 'copy-miniaudio
+                 (lambda _
+                   (with-directory-excursion "tools/mkpsxiso"
+                     (copy-recursively
+                      #$(package-source miniaudio-0.10.43)
+                      "miniaudio"))))
+               (add-after 'copy-miniaudio 'copy-gulrak-filesystem
+                 (lambda _
+                   (with-directory-excursion "tools/mkpsxiso"
+                     (copy-recursively
+                      #$(package-source gulrak-filesystem)
+                      "ghc"))))
+               (add-after 'copy-gulrak-filesystem 'copy-threadpool
+                 (lambda _
+                   (with-directory-excursion "tools/mkpsxiso"
+                     (copy-recursively
+                      #$(package-source ThreadPool)
+                      "ThreadPool"))))
+               (add-after 'copy-threadpool 'copy-flac
+                 (lambda _
+                   (mkdir-p "flac")
+                   (with-directory-excursion "tools/mkpsxiso/flac"
+                     (invoke "tar" "xvf" #$(package-source flac)
+                             "--strip-components=1")))))))
+    (propagated-inputs
+     `(("mipsel-none-elf-toolchain" ,(make-mipsel-none-elf-toolchain-ps1))))
+    (native-inputs (list pkg-config))
+    (synopsis "Homebrew software development kit for the original Sony
+PlayStation")
+    (description
+     "Sn00bSDK is a set of libraries that implements most of the core
+functionality of the official Sony SDK (excluding higher-level libraries) plus
+several new extensions to it.")
+    (home-page "http://lameguy64.net/")
+    (license license:mpl2.0)))
-- 
2.46.0