diff mbox series

[bug#48767,7/7] gnu: Add msp430lib.

Message ID BYAPR05MB40233AE7EE9617C72B7C501CC53E9@BYAPR05MB4023.namprd05.prod.outlook.com
State New
Headers show
Series None | expand

Commit Message

Morgan Smith June 1, 2021, 3:09 a.m. UTC
From: Morgan Smith <Morgan.J.Smith@outlook.com>

* gnu/packages/debug.scm (msp430lib): New variable.
---
 gnu/packages/debug.scm | 59 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)
diff mbox series

Patch

diff --git a/gnu/packages/debug.scm b/gnu/packages/debug.scm
index c12013e50a..b4b037eb2a 100644
--- a/gnu/packages/debug.scm
+++ b/gnu/packages/debug.scm
@@ -36,6 +36,7 @@  (define-module (gnu packages debug)
   #:use-module (gnu packages autotools)
   #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
+  #:use-module (gnu packages boost)
   #:use-module (gnu packages bison)
   #:use-module (gnu packages c)
   #:use-module (gnu packages code)
@@ -738,3 +739,61 @@  (define-public mspdebug
 engineering.")
       (home-page "https://github.com/dlbeer/mspdebug")
       (license license:gpl2+))))
+
+(define (version-with-underscores version)
+  (string-map (lambda (x) (if (eq? x #\.) #\_ x)) version))
+
+(define-public msp430lib
+  (package
+    (name "msp430lib")
+    (version "3.15.1.1")
+    (source (origin
+              (method url-fetch/zipbomb)
+              (uri (string-append
+                    "https://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPDS/"
+                    (version-with-underscores (version-major+minor+point version))
+                    "_001/export/MSPDebugStack_OS_Package_"
+                    (version-with-underscores version) ".zip"))
+              (sha256
+               (base32
+                "1j5sljqwc20zrb50mrji4mnmw5i680qc7n0lb0pakrrxqjc9m9g3"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:make-flags
+       (list
+        (string-append "BOOST_DIR=" (assoc-ref %build-inputs "boost"))
+        (string-append "HIDOBJ=-I" (assoc-ref %build-inputs "hidapi") "/include/hidapi"
+                       " -lhidapi-libusb")
+        "STATIC_LIBS=-lbsl430")
+       #:phases
+       (modify-phases %standard-phases
+         (delete 'configure)
+         (delete 'check)
+         (add-before 'build 'fix-hidapi-includes
+           (lambda _
+             (substitute*
+                 '("ThirdParty/BSL430_DLL/BSL430_DLL/Physical_Interfaces/MSPBSL_PhysicalInterfaceUSB.h"
+                   "DLL430_v3/src/TI/DLL430/HidUpdateManager.cpp")
+               (("hidapi.h") "hidapi/hidapi.h"))
+             #t))
+         (replace 'install
+           (lambda* (#:key outputs #:allow-other-keys)
+             (install-file "libmsp430.so"
+                           (string-append (assoc-ref outputs "out") "/lib"))
+             #t)))))
+    (inputs
+     `(("boost" ,boost)
+       ("hidapi" ,hidapi)
+       ("libusb" ,libusb)))
+    (native-search-paths
+     (list (search-path-specification
+            ;; Used by mspdebug. mspdebug has a few different drivers it can
+            ;; use to interact with MSP430's so this is an optional dependency
+            (variable "MSPDEBUG_TILIB_PATH")
+            (files '("lib")))))
+    (home-page "https://www.ti.com/tool/MSPDS")
+    (synopsis "Library used to program and debug MSP430 microcontrollers")
+    (description "This library facilitates communication between a host computer and
+certain MSP430 debuggers.  This is an optional dependency of mspdebug (which calls
+this library \"tilib\")")
+    (license license:bsd-3)))