diff mbox series

[bug#58261,v2,02/13] gnu: Add pocketfft.

Message ID 20221007152148.32591-3-david.elsing@posteo.net
State Accepted
Headers show
Series None | expand

Commit Message

David Elsing Oct. 7, 2022, 3:21 p.m. UTC
* gnu/packages/cpp.scm (pocketfft): New variable.
---
 gnu/packages/cpp.scm | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

Comments

Liliana Marie Prikler Oct. 9, 2022, 11:42 a.m. UTC | #1
Am Freitag, dem 07.10.2022 um 15:21 +0000 schrieb David Elsing:
> * gnu/packages/cpp.scm (pocketfft): New variable.
> ---
>  gnu/packages/cpp.scm | 44
> ++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 44 insertions(+)
> 
> diff --git a/gnu/packages/cpp.scm b/gnu/packages/cpp.scm
> index a7404df563..38a2a9e829 100644
> --- a/gnu/packages/cpp.scm
> +++ b/gnu/packages/cpp.scm
> @@ -1961,3 +1961,47 @@ (define-public fast-float
>  floating point numbers from strings.  It implements the C++
> from_chars
>  functions for the float and double types.")
>      (license (list license:asl2.0 license:expat)))) ; dual licensed
> +
> +(define-public pocketfft-cpp
> +  (let ((commit "daa8bb18327bc5c7d22c69428c25cf5dc64167d3")
> +        (revision "0"))
> +    (package
> +      (name "pocketfft-cpp")
> +      (version (git-version "0" revision commit))
> +      (source (origin
> +                (method git-fetch)
> +                (uri (git-reference
> +                      (url "https://github.com/mreineck/pocketfft")
> +                      (commit commit)))
> +                (file-name (git-file-name name version))
> +                (sha256
> +                 (base32
> +                 
> "1dbkkqkmkxgmz1qjpsqzic5ig3qw1pqndbb3dvjc7xq5f2rdzyq1"))))
> +      (build-system copy-build-system)
> +      (arguments
> +       (list
> +        #:install-plan
> +        #~'(("pocketfft_hdronly.h" "include/"))
> +        #:phases
> +        #~(modify-phases %standard-phases
> +            (add-before 'install 'patch-novectors
> +              (lambda _
> +                (substitute* "pocketfft_hdronly.h"
> +                  (("#ifndef POCKETFFT_NO_VECTORS")
> +                   "#if !(POCKETFFT_NO_VECTORS)")
> +                  (("#if defined\\(POCKETFFT_NO_VECTORS\\)")
> +                   "#if POCKETFFT_NO_VECTORS")
> +                  (("#define POCKETFFT_NO_VECTORS")
> +                   "#define POCKETFFT_NO_VECTORS 1")
This one I don't think changes anything.
> +                  (("#\\s*undef POCKETFFT_NO_VECTORS")
> +                   "#define POCKETFFT_NO_VECTORS 0")
Here too, I think you can ignore that.
> +                  (("#define POCKETFFT_HDRONLY_H.*" orig)
> +                   (string-append
> +                    orig "\n#ifndef POCKETFFT_NO_VECTORS\n"
> +                    "#define POCKETFFT_NO_VECTORS 1\n"
> "#endif\n"))))))))
More importantly, I think this should be done with a snippet or even
better a patch – I'd recommend the latter because I think it'd be
easier to reason about.
> +      (home-page "https://github.com/mreineck/pocketfft")
> +      (synopsis "C++11 header-only Fast Fourier Transform library")
> +      (description "This package provides a single-header C++11
> library for
> +computing Fast Fourier transformations.  It supports
> multidimensional arrays,
> +different floating point sizes and complex transformations.")
> +      (license license:bsd-3))))
diff mbox series

Patch

diff --git a/gnu/packages/cpp.scm b/gnu/packages/cpp.scm
index a7404df563..38a2a9e829 100644
--- a/gnu/packages/cpp.scm
+++ b/gnu/packages/cpp.scm
@@ -1961,3 +1961,47 @@  (define-public fast-float
 floating point numbers from strings.  It implements the C++ from_chars
 functions for the float and double types.")
     (license (list license:asl2.0 license:expat)))) ; dual licensed
+
+(define-public pocketfft-cpp
+  (let ((commit "daa8bb18327bc5c7d22c69428c25cf5dc64167d3")
+        (revision "0"))
+    (package
+      (name "pocketfft-cpp")
+      (version (git-version "0" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/mreineck/pocketfft")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "1dbkkqkmkxgmz1qjpsqzic5ig3qw1pqndbb3dvjc7xq5f2rdzyq1"))))
+      (build-system copy-build-system)
+      (arguments
+       (list
+        #:install-plan
+        #~'(("pocketfft_hdronly.h" "include/"))
+        #:phases
+        #~(modify-phases %standard-phases
+            (add-before 'install 'patch-novectors
+              (lambda _
+                (substitute* "pocketfft_hdronly.h"
+                  (("#ifndef POCKETFFT_NO_VECTORS")
+                   "#if !(POCKETFFT_NO_VECTORS)")
+                  (("#if defined\\(POCKETFFT_NO_VECTORS\\)")
+                   "#if POCKETFFT_NO_VECTORS")
+                  (("#define POCKETFFT_NO_VECTORS")
+                   "#define POCKETFFT_NO_VECTORS 1")
+                  (("#\\s*undef POCKETFFT_NO_VECTORS")
+                   "#define POCKETFFT_NO_VECTORS 0")
+                  (("#define POCKETFFT_HDRONLY_H.*" orig)
+                   (string-append
+                    orig "\n#ifndef POCKETFFT_NO_VECTORS\n"
+                    "#define POCKETFFT_NO_VECTORS 1\n" "#endif\n"))))))))
+      (home-page "https://github.com/mreineck/pocketfft")
+      (synopsis "C++11 header-only Fast Fourier Transform library")
+      (description "This package provides a single-header C++11 library for
+computing Fast Fourier transformations.  It supports multidimensional arrays,
+different floating point sizes and complex transformations.")
+      (license license:bsd-3))))