Update e-mail for Theodoros Foradis.
[jackhill/guix/guix.git] / gnu / packages / libusb.scm
index 3932f1e..875d50a 100644 (file)
@@ -4,7 +4,8 @@
 ;;; Copyright © 2015 Andy Wingo <wingo@igalia.com>
 ;;; Copyright © 2015, 2016, 2017 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
-;;; Copyright © 2016 Theodoros Foradis <theodoros.for@openmailbox.org>
+;;; Copyright © 2016 Theodoros Foradis <theodoros@foradis.org>
+;;; Copyright © 2017 Jonathan Brielmaier <jonathan.brielmaier@web.de>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -28,6 +29,7 @@
   #:use-module (guix utils)
   #:use-module (guix download)
   #:use-module (guix git-download)
+  #:use-module (guix build-system ant)
   #:use-module (guix build-system cmake)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system glib-or-gtk)
@@ -94,6 +96,21 @@ devices on various operating systems.")
 version of libusb to run with newer libusb.")
     (license lgpl2.1+)))
 
+;; required by 0xffff, which compiles with libusb-compat, but executes only
+;; with libusb-0.1
+(define-public libusb-0.1
+  (package (inherit libusb)
+    (version "0.1.12")
+    (source
+     (origin
+      (method url-fetch)
+      (uri (string-append "mirror://sourceforge/libusb/libusb-0.1 (LEGACY)/"
+                          version "/libusb-" version ".tar.gz"))
+      (sha256
+       (base32
+        "0i4bacxkyr7xyqxbmb00ypkrv4swkgm0mghbzjsnw6blvvczgxip"))
+      (patches (search-patches "libusb-0.1-disable-tests.patch"))))))
+
 (define-public libusb4java
   ;; There is no public release so we take the latest version from git.
   (let ((commit "396d642a57678a0d9663b062c980fe100cc0ea1e")
@@ -129,6 +146,65 @@ version of libusb to run with newer libusb.")
 with usb4java.")
       (license expat))))
 
+(define-public java-usb4java
+  (package
+    (name "java-usb4java")
+    (version "1.2.0")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://github.com/usb4java/usb4java/"
+                                  "archive/usb4java-" version ".tar.gz"))
+              (sha256
+               (base32
+                "0gzpsnzwgsdyra3smq288yvxnwrgvdwxr6g8jbknnsk56kv6wc34"))))
+    (build-system ant-build-system)
+    (arguments
+     `(#:jar-name "usb4java.jar"
+       #:phases
+       (modify-phases %standard-phases
+         ;; Usually, native libusb4java libraries for all supported systems
+         ;; would be included in the jar and extracted at runtime.  Since we
+         ;; build everything from source we cannot just bundle pre-built
+         ;; binaries for other systems.  Instead, we patch the loader to
+         ;; directly return the appropriate library for this system.  The
+         ;; downside is that the jar will only work on the same architecture
+         ;; that it was built on.
+         (add-after 'unpack 'copy-libusb4java
+           (lambda* (#:key inputs #:allow-other-keys)
+             (substitute* "src/main/java/org/usb4java/Loader.java"
+               (("private static String extractLibrary" line)
+                (string-append
+                 line "(final String a, final String b) {"
+                 "return \""
+                 (assoc-ref inputs "libusb4java") "/lib/libusb4java.so"
+                 "\"; }\n"
+                 "private static String _extractLibrary")))
+             #t))
+         (add-after 'unpack 'disable-broken-tests
+           (lambda _
+             (with-directory-excursion "src/test/java/org/usb4java"
+               ;; These tests should only be run when USB devices are present.
+               (substitute* '("LibUsbGlobalTest.java"
+                              "TransferTest.java")
+                 (("this.context = new Context\\(\\);")
+                  "this.context = null;")
+                 (("LibUsb.init") "//"))
+               (substitute* "DeviceListIteratorTest.java"
+                 (("this.iterator.remove" line)
+                  (string-append "assumeUsbTestsEnabled();" line))))
+             #t)))))
+    (inputs
+     `(("libusb4java" ,libusb4java)
+       ("java-commons-lang3" ,java-commons-lang3)
+       ("java-junit" ,java-junit)
+       ("java-hamcrest-core" ,java-hamcrest-core)))
+    (home-page "http://usb4java.org/")
+    (synopsis "USB library for Java")
+    (description
+     "This package provides a USB library for Java based on libusb and
+implementing @code{javax.usb} (JSR-80).")
+    (license expat)))
+
 (define-public python-pyusb
   (package
     (name "python-pyusb")
@@ -256,7 +332,7 @@ devices.")
     (arguments
      '(#:phases
        (modify-phases %standard-phases
-         (add-before 'configure 'bootstrap
+         (add-after 'unpack 'bootstrap
            (lambda _
              (zero? (system* "autoreconf" "-vfi")))))))
     (inputs