[bug#67755,v5,5/9] gnu: Add miniaudio.

Message ID 77018049d6d7979267a08e2c758433fe53ac7bd4.1741720525.git.sergio.pastorperez@gmail.com
State New
Headers
Series [bug#67755,v5,1/9] gnu: Add edlib. |

Commit Message

Sergio Pastor Pérez March 11, 2025, 7:15 p.m. UTC
  From: Sergio Pastor Pérez <sergio.pastorperez@outlook.es>

* gnu/packages/cpp.scm (miniaudio): New variable.

Change-Id: I27b74793dd7b80af4437e0a1b997cc87fe8822e5
---
 gnu/packages/cpp.scm | 60 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
  

Patch

diff --git a/gnu/packages/cpp.scm b/gnu/packages/cpp.scm
index 252e809a10..a4083604c1 100644
--- a/gnu/packages/cpp.scm
+++ b/gnu/packages/cpp.scm
@@ -1957,6 +1957,66 @@  (define (make-static-abseil-cpp version)
            #~(cons* "-DCMAKE_POSITION_INDEPENDENT_CODE=ON"
                     (delete "-DBUILD_SHARED_LIBS=ON" #$flags)))))))))
 
+(define-public miniaudio
+  (package
+    (name "miniaudio")
+    (version "0.11.22")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/mackron/miniaudio")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "1pjaiq71x24n9983vkhjxrsbraa24053h727db22b1rb2xyfrzm3"))))
+    (build-system gnu-build-system)
+    (arguments
+     (list
+      #:phases
+      #~(modify-phases %standard-phases
+          (delete 'build)
+          (delete 'configure)
+          (replace 'check
+            (lambda* (#:key tests? #:allow-other-keys)
+              (when tests?
+                (with-directory-excursion "tests/_build"
+                  (let ((tests '("conversion" "filtering" "generation")))
+                    (mkdir "bin")
+                    ;; Compile tests
+                    (for-each (lambda (test)
+                                (invoke "gcc"
+                                        (string-append "../" test "/" test
+                                                       ".c")
+                                        "-o"
+                                        (string-append "bin/" test)
+                                        "-ldl"
+                                        "-lm"
+                                        "-lpthread"
+                                        "-Wall"
+                                        "-Wextra"
+                                        "-Wpedantic")
+                                (let ((bin (string-append "./bin/" test)))
+                                  (if (string= test "filtering")
+                                      ;; NOTE: the 'filtering' test
+                                      ;; requires an input file.
+                                      (invoke bin bin)
+                                      (invoke bin))))
+                              tests))))))
+          (replace 'install
+            (lambda _
+              (install-file "miniaudio.h"
+                            (string-append #$output "/include"))
+              (copy-recursively "extras"
+                                (string-append #$output
+                                               "/include/extras/")))))))
+    (home-page "https://miniaud.io")
+    (synopsis "Audio playback and capture library for C and C++")
+    (description
+     "Miniaudio is an audio playback and capture library for C and C++.  It is
+made up of a single source file and has no external dependencies.")
+    (license license:expat)))
+
 (define-public abseil-cpp-cxxstd17
   (abseil-cpp-for-c++-standard abseil-cpp 17))  ;XXX: the default with GCC 11?