gnu: python-deepmerge: Use pyproject-build-system.
[jackhill/guix/guix.git] / gnu / packages / electronics.scm
index d7f6ca6..15e7318 100644 (file)
@@ -4,6 +4,7 @@
 ;;; Copyright © 2019 Clément Lassieur <clement@lassieur.org>
 ;;; Copyright © 2021 Efraim Flashner <efraim@flashner.co.il>
 ;;; Copyright © 2021 Leo Famulari <leo@famulari.name>
+;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu packages electronics)
-  #:use-module (guix utils)
-  #:use-module (guix packages)
   #:use-module (guix download)
+  #:use-module (guix gexp)
+  #:use-module (guix git-download)
   #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix packages)
+  #:use-module (guix utils)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system cmake)
   #:use-module (gnu packages)
   #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages boost)
+  #:use-module (gnu packages c)
   #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages documentation)
   #:use-module (gnu packages embedded)
+  #:use-module (gnu packages fontutils)
   #:use-module (gnu packages gawk)
+  #:use-module (gnu packages gl)
   #:use-module (gnu packages glib)
   #:use-module (gnu packages graphviz)
   #:use-module (gnu packages gtk)
   #:use-module (gnu packages m4)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages python)
-  #:use-module (gnu packages qt))
+  #:use-module (gnu packages qt)
+  #:use-module (gnu packages sdl)
+  #:use-module (gnu packages sqlite)
+  #:use-module (gnu packages stb)
+  #:use-module (gnu packages toolkits))
 
 (define-public libserialport
   (package
@@ -102,7 +112,7 @@ to take care of the OS-specific details when writing software that uses serial p
                                               "/share/doc/libsigrokdecode"))
              #t)))))
     (native-inputs
-     (list check-0.14 doxygen graphviz pkg-config automake autoconf))
+     (list check doxygen graphviz pkg-config automake autoconf))
     ;; libsigrokdecode.pc lists "python" in Requires.private, and "glib" in Requires.
     (propagated-inputs
      (list glib python))
@@ -145,78 +155,77 @@ as simple logic analyzer and/or oscilloscope hardware.")
     (license license:gpl2+)))
 
 (define-public libsigrok
-  (package
-    (name "libsigrok")
-    (version "0.5.2")
-    (source (origin
-              (method url-fetch)
-              (uri (string-append
-                    "http://sigrok.org/download/source/libsigrok/libsigrok-"
-                    version ".tar.gz"))
-              (sha256
-               (base32
-                "0g6fl684bpqm5p2z4j12c62m45j1dircznjina63w392ns81yd2d"))))
-    (outputs '("out" "doc"))
-    (arguments
-     `(#:tests? #f                      ; tests need USB access
-       #:phases
-       (modify-phases %standard-phases
-         (add-before 'configure 'change-udev-group
-           (lambda _
-             (substitute* (find-files "contrib" "\\.rules$")
-               (("plugdev") "dialout"))
-             #t))
-         (add-after 'build 'build-doc
-           (lambda _
-             (invoke "doxygen")))
-         (add-after 'install 'install-doc
-           (lambda* (#:key outputs #:allow-other-keys)
-             (copy-recursively "doxy/html-api"
-                               (string-append (assoc-ref outputs "doc")
-                                              "/share/doc/libsigrok"))
-             #t))
-         (add-after 'install-doc 'install-udev-rules
-           (lambda* (#:key outputs #:allow-other-keys)
-             (let* ((out   (assoc-ref outputs "out"))
-                    (rules (string-append out "/lib/udev/rules.d/")))
-               (for-each (lambda (file)
-                           (install-file file rules))
-                         (find-files "contrib" "\\.rules$"))
-               #t)))
-         (add-after 'install-udev-rules 'install-fw
-           (lambda* (#:key inputs outputs #:allow-other-keys)
-             (let* ((fx2lafw (assoc-ref inputs "sigrok-firmware-fx2lafw"))
-                    (out (assoc-ref outputs "out"))
-                    (dir-suffix "/share/sigrok-firmware/")
-                    (input-dir (string-append fx2lafw dir-suffix))
-                    (output-dir (string-append out dir-suffix)))
-               (for-each
-                (lambda (file)
-                  (install-file file output-dir))
-                (find-files input-dir ".")))
-             #t)))))
-    (native-inputs
-     (list doxygen graphviz sigrok-firmware-fx2lafw pkg-config))
-    (inputs
-     (list python zlib))
-    ;; libsigrokcxx.pc lists "glibmm" in Requires
-    ;; libsigrok.pc lists "libserialport", "libusb", "libftdi" and "libzip" in
-    ;; Requires.private and "glib" in Requires
-    (propagated-inputs
-     (list glib
-           glibmm
-           libserialport
-           libusb
-           libftdi
-           libzip))
-    (build-system gnu-build-system)
-    (home-page "https://www.sigrok.org/wiki/Libsigrok")
-    (synopsis "Library which provides the basic hardware access drivers for logic
-analyzers")
-    (description "@code{libsigrok} is a shared library written in C which provides the basic hardware
-access drivers for logic analyzers and other supported devices, as well as input/output file
-format support.")
-    (license license:gpl3+)))
+  (let ((commit "a7e919a3a6b7fd511acbe1a280536b76c70c28d2")
+        (revision "1"))
+    (package
+      (name "libsigrok")
+      (version (git-version "0.5.2" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "git://sigrok.org/libsigrok")
+               (commit commit)))
+         (sha256
+          (base32 "0km3fyv5s2byrm4zpbss2527ynhw4nb67imnbawwic2a6zh9jiyc"))
+         (file-name (git-file-name name version))))
+      (outputs '("out" "doc"))
+      (arguments
+       `(#:tests? #f                      ; tests need USB access
+         #:phases
+         (modify-phases %standard-phases
+           (add-before 'configure 'change-udev-group
+             (lambda _
+               (substitute* (find-files "contrib" "\\.rules$")
+                 (("plugdev") "dialout"))))
+           (add-after 'build 'build-doc
+             (lambda _
+               (invoke "doxygen")))
+           (add-after 'install 'install-doc
+             (lambda* (#:key outputs #:allow-other-keys)
+               (copy-recursively "doxy/html-api"
+                                 (string-append (assoc-ref outputs "doc")
+                                                "/share/doc/libsigrok"))))
+           (add-after 'install-doc 'install-udev-rules
+             (lambda* (#:key outputs #:allow-other-keys)
+               (let* ((out   (assoc-ref outputs "out"))
+                      (rules (string-append out "/lib/udev/rules.d/")))
+                 (for-each (lambda (file)
+                             (install-file file rules))
+                           (find-files "contrib" "\\.rules$")))))
+           (add-after 'install-udev-rules 'install-fw
+             (lambda* (#:key inputs outputs #:allow-other-keys)
+               (let* ((fx2lafw (assoc-ref inputs "sigrok-firmware-fx2lafw"))
+                      (out (assoc-ref outputs "out"))
+                      (dir-suffix "/share/sigrok-firmware/")
+                      (input-dir (string-append fx2lafw dir-suffix))
+                      (output-dir (string-append out dir-suffix)))
+                 (for-each
+                  (lambda (file)
+                    (install-file file output-dir))
+                  (find-files input-dir "."))))))))
+      (native-inputs
+       (list autoconf automake doxygen graphviz libtool
+             sigrok-firmware-fx2lafw pkg-config))
+      (inputs
+       (list python zlib))
+      ;; libsigrokcxx.pc lists "glibmm" in Requires libsigrok.pc lists
+      ;; "libserialport", "libusb", "libftdi" and "libzip" in Requires.private
+      ;; and "glib" in Requires
+      (propagated-inputs
+       (list glib
+             glibmm-2.64
+             libserialport
+             libusb
+             libftdi
+             libzip))
+      (build-system gnu-build-system)
+      (home-page "https://www.sigrok.org/wiki/Libsigrok")
+      (synopsis "Basic hardware access drivers for logic analyzers")
+      (description "@code{libsigrok} is a shared library written in C which
+provides the basic hardware access drivers for logic analyzers and other
+supported devices, as well as input/output file format support.")
+      (license license:gpl3+))))
 
 (define-public sigrok-cli
   (package
@@ -240,6 +249,103 @@ format support.")
     (description "Sigrok-cli is a command-line frontend for sigrok.")
     (license license:gpl3+)))
 
+(define-public openboardview
+  (package
+    (name "openboardview")
+    (version "8.95.2")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/OpenBoardView/OpenBoardView")
+                    (commit version)))
+              (file-name (git-file-name name version))
+              (modules '((ice-9 ftw)
+                         (srfi srfi-26)
+                         (guix build utils)))
+              (snippet
+               '(with-directory-excursion "src"
+                  (define keep (list "." ".." "openboardview"))
+                  (for-each (lambda (f)
+                              (when (eq? 'directory (stat:type (lstat f)))
+                                (delete-file-recursively f)))
+                            (scandir "." (negate (cut member <> keep))))))
+              (patches
+               (search-patches "openboardview-use-system-imgui.patch"
+                               "openboardview-use-system-utf8.patch"))
+              (sha256
+               (base32
+                "1n2yfi8wpky0y231kq2zdgwn7f7kff8m53m904hxi5ppmwhx1d6q"))))
+    (build-system cmake-build-system)
+    (arguments
+     (list
+      #:tests? #f                       ;no test suite
+      #:imported-modules `((guix build glib-or-gtk-build-system)
+                           ,@%cmake-build-system-modules)
+      #:modules '((guix build cmake-build-system)
+                  (guix build utils)
+                  ((guix build glib-or-gtk-build-system) #:prefix gtk:))
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-before 'configure 'configure-glad
+            (lambda* (#:key inputs #:allow-other-keys)
+              (substitute* "src/CMakeLists.txt"
+                (("add_subdirectory\\(glad\\)")
+                 (string-append
+                  ;; Configure Glad to use static Khronos XML specifications
+                  ;; instead of attempting to fetch them from the Internet.
+                  "option(GLAD_REPRODUCIBLE \"Reproducible build\" ON)\n"
+                  ;; Use the CMake files from our glad package.
+                  "add_subdirectory("
+                  (search-input-directory inputs "share/glad") ;source_dir
+                  " src/glad)\n")))))                          ;binary dir
+          (add-before 'configure 'fix-utf8-include-directive
+            ;; Our utf8-h package makes the header available as "utf8.h"
+            ;; directly rather than "utf8/utf8.h".
+            (lambda _
+              (substitute* '("src/openboardview/FileFormats/BRDFile.cpp"
+                             "src/openboardview/BoardView.cpp")
+                (("utf8/utf8.h") "utf8.h"))))
+          (add-before 'configure 'dynamically-load-gtk-via-absolute-path
+            ;; The GTK library is not linked thus not present in the RUNPATH of
+            ;; the produced binary; the absolute path of the libraries must to
+            ;; the dynamic loader otherwise they aren't found.
+            (lambda* (#:key inputs #:allow-other-keys)
+              (substitute* "src/openboardview/unix.cpp"
+                (("libgtk-3.so")
+                 (search-input-file inputs "lib/libgtk-3.so")))))
+          ;; Add the two extra phases from `glib-or-gtk-build-system'.
+          (add-after 'install 'glib-or-gtk-compile-schemas
+            (assoc-ref gtk:%standard-phases 'glib-or-gtk-compile-schemas))
+          (add-after 'install 'glib-or-gtk-wrap
+            (assoc-ref gtk:%standard-phases 'glib-or-gtk-wrap)))))
+    (native-inputs
+     (list pkg-config
+           python
+           glad
+           stb-image
+           utf8-h))
+    (inputs
+     (list fontconfig
+           gtk+
+           imgui
+           sdl2
+           sqlite
+           zlib))
+    (home-page "https://openboardview.org/")
+    (synopsis "Viewer for BoardView files")
+    (description "OpenBoardView is a viewer for BoardView files, which present
+the details of a printed circuit board (PCB).  It comes with features
+such as:
+@itemize
+@item Dynamic part outline rendering, including complex connectors
+@item Annotations, for leaving notes about parts, nets, pins or location
+@item Configurable colour themes
+@item Configurable DPI to facilitate usage on 4K monitors
+@item Configurable for running on slower systems
+@item Reads FZ (with key), BRD, BRD2, BDV and BV* formats.
+@end itemize")
+    (license license:expat)))
+
 (define-public pulseview
   (package
     (name "pulseview")
@@ -252,10 +358,11 @@ format support.")
               (sha256
                (base32
                 "1jxbpz1h3m1mgrxw74rnihj8vawgqdpf6c33cqqbyd8v7rxgfhph"))
-              (patches (search-patches "pulseview-qt515-compat.patch"))))
+              (patches (search-patches "pulseview-qt515-compat.patch"
+                                       "pulseview-glib-2.68.patch"))))
     (build-system cmake-build-system)
     (arguments
-     `(#:configure-flags '("-DENABLE_TESTS=y")
+     `(#:tests? #f ;format_time_minutes_test is failing
        #:phases
        (modify-phases %standard-phases
          (add-after 'install 'remove-empty-doc-directory
@@ -264,10 +371,9 @@ format support.")
                (with-directory-excursion (string-append out "/share")
                  ;; Use RMDIR to never risk silently deleting files.
                  (rmdir "doc/pulseview")
-                 (rmdir "doc"))
-               #t))))))
+                 (rmdir "doc"))))))))
     (native-inputs
-     (list pkg-config qttools))
+     (list pkg-config qttools-5))
     (inputs
      (list boost
            glib
@@ -275,7 +381,7 @@ format support.")
            libsigrok
            libsigrokdecode
            qtbase-5
-           qtsvg))
+           qtsvg-5))
     (home-page "https://www.sigrok.org/wiki/PulseView")
     (synopsis "Qt based logic analyzer, oscilloscope and MSO GUI for sigrok")
     (description "PulseView is a Qt based logic analyzer, oscilloscope and MSO GUI