unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#28723] Add HDF-Java. [PATCH 1/2] gnu: Add java-slf4-simple.
@ 2017-10-06 16:01 Thomas Danckaert
  2017-10-06 16:20 ` [bug#28723] [PATCH 2/2] gnu: Add hdf-java Thomas Danckaert
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Thomas Danckaert @ 2017-10-06 16:01 UTC (permalink / raw)
  To: 28723

[-- Attachment #1: Type: Text/Plain, Size: 288 bytes --]

Hi Guix,

this patch adds the “Simple” implementation of the SLF4J interface, 
used by HDF-Java's tests.

About this patch: the tests of slf4j-simple require some of 
slf4j-api's test code, which are therefore compiled in a somewhat 
ad-hoc fashion, but it works...

Thomas

[-- Attachment #2: 0001-gnu-Add-java-slf4-simple.patch --]
[-- Type: Text/X-Patch, Size: 2467 bytes --]

From d034b46040d51b7e82fb95df3601dc9925fa1502 Mon Sep 17 00:00:00 2001
From: Thomas Danckaert <post@thomasdanckaert.be>
Date: Fri, 6 Oct 2017 12:38:34 +0200
Subject: [PATCH 1/2] gnu: Add java-slf4-simple.

* gnu/packages/java.scm (java-slf4j-simple): New variable.
---
 gnu/packages/java.scm | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index 4418b67ea..60590b117 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -4,6 +4,7 @@
 ;;; Copyright © 2016, 2017 Roel Janssen <roel@gnu.org>
 ;;; Copyright © 2017 Carlo Zancanaro <carlo@zancanaro.id.au>
 ;;; Copyright © 2017 Julien Lepiller <julien@lepiller.eu>
+;;; Copyright © 2017 Thomas Danckaert <post@thomasdanckaert.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -4207,6 +4208,40 @@ allowing the end user to plug in the desired logging framework at deployment
 time.")
     (license license:expat)))
 
+(define-public java-slf4j-simple
+  (package
+    (name "java-slf4j-simple")
+    (version "1.7.25")
+    (source (package-source java-slf4j-api))
+    (build-system ant-build-system)
+    (arguments
+     `(#:jar-name "slf4j-simple.jar"
+       #:source-dir "slf4j-simple/src/main"
+       #:test-dir "slf4j-simple/src/test"
+       #:phases
+       (modify-phases %standard-phases
+         ;; The tests need some test classes from slf4j-api
+         (add-before 'check 'build-slf4j-api-test-helpers
+           (lambda _
+             ;; Add current dir to CLASSPATH ...
+             (setenv "CLASSPATH"
+                     (string-append (getcwd) ":" (getenv "CLASSPATH")))
+             ;; ... and build test helper classes here:
+             (zero?
+              (apply system*
+                     `("javac" "-d" "."
+                       ,@(find-files "slf4j-api/src/test" ".*\\.java")))))))))
+    (inputs
+     `(("java-junit" ,java-junit)
+       ("java-hamcrest-core" ,java-hamcrest-core)
+       ("java-slf4j-api" ,java-slf4j-api)))
+    (home-page "https://www.slf4j.org/")
+    (synopsis "Simple implementation of simple logging facade for Java")
+    (description "SLF4J binding for the Simple implementation, which outputs
+all events to System.err.  Only messages of level INFO and higher are
+printed.")
+    (license license:expat)))
+
 (define-public antlr2
   (package
     (name "antlr2")
-- 
2.14.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [bug#28723] [PATCH 2/2] gnu: Add hdf-java.
  2017-10-06 16:01 [bug#28723] Add HDF-Java. [PATCH 1/2] gnu: Add java-slf4-simple Thomas Danckaert
@ 2017-10-06 16:20 ` Thomas Danckaert
  2017-10-09 19:27   ` Leo Famulari
  2017-10-09 19:25 ` [bug#28723] Add HDF-Java. [PATCH 1/2] gnu: Add java-slf4-simple Leo Famulari
  2017-10-10  8:31 ` bug#28723: (no subject) Thomas Danckaert
  2 siblings, 1 reply; 7+ messages in thread
From: Thomas Danckaert @ 2017-10-06 16:20 UTC (permalink / raw)
  To: 28723

[-- Attachment #1: Type: Text/Plain, Size: 300 bytes --]

Hi Guix,

this patch adds hdf-java.

It's quite ugly, but it seems the autotools build for this package is 
barely working and really needs a lot of patching...  (Actually, 
using CMake is recommended, but then we would have to build the HDF4 
and HDF5 packages with CMake as well).

cheers,

Thomas

[-- Attachment #2: 0002-gnu-Add-hdf-java.patch --]
[-- Type: Text/X-Patch, Size: 7151 bytes --]

From 619b38cc889bc41e0128f038aa78e54f71fb7dab Mon Sep 17 00:00:00 2001
From: Thomas Danckaert <thomas.danckaert@gmail.com>
Date: Wed, 4 Oct 2017 17:17:03 +0200
Subject: [PATCH 2/2] gnu: Add hdf-java.

* gnu/packages/maths.scm (hdf-java): New variable.
---
 gnu/packages/maths.scm | 122 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 121 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index 9aa037838..4e95fea59 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -14,7 +14,7 @@
 ;;; Copyright © 2016 Kei Kebreau <kkebreau@posteo.net>
 ;;; Copyright © 2016, 2017 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2016 Leo Famulari <leo@famulari.name>
-;;; Copyright © 2016 Thomas Danckaert <post@thomasdanckaert.be>
+;;; Copyright © 2016, 2017 Thomas Danckaert <post@thomasdanckaert.be>
 ;;; Copyright © 2017 Paul Garlick <pgarlick@tourbillion-technology.com>
 ;;; Copyright © 2017 ng0 <contact.ng0@cryptolab.net>
 ;;; Copyright © 2017 Ben Woodcroft <donttrustben@gmail.com>
@@ -69,6 +69,7 @@
   #:use-module (gnu packages graphviz)
   #:use-module (gnu packages gtk)
   #:use-module (gnu packages image)
+  #:use-module (gnu packages java)
   #:use-module (gnu packages less)
   #:use-module (gnu packages lisp)
   #:use-module (gnu packages logging)
@@ -742,6 +743,125 @@ extremely large and complex data collections.")
     (license (license:x11-style
               "http://www.hdfgroup.org/ftp/HDF5/current/src/unpacked/COPYING"))))
 
+(define-public hdf-java
+  (package
+   (name "hdf-java")
+   (version "3.3.2")
+   (source
+    (origin
+      (method url-fetch)
+      (uri (string-append
+            "http://www.hdfgroup.org/ftp/HDF5/releases/HDF-JAVA/hdfjni-"
+            version "/src/CMake-hdfjava-" version ".tar.gz"))
+      (sha256
+       (base32 "0m1gp2aspcblqzmpqbdpfp6giskws85ds6p5gz8sx7asyp7wznpr"))
+      (modules '((guix build utils)))
+      (snippet ; Make sure we don't use the bundled sources and binaries.
+       `(begin
+          (for-each delete-file
+                    (list "SZip.tar.gz" "ZLib.tar.gz" "JPEG8d.tar.gz"
+                          "HDF4.tar.gz" "HDF5.tar.gz"))
+          (delete-file-recursively ,(string-append "hdfjava-" version "/lib"))))))
+   (build-system gnu-build-system)
+   (native-inputs
+    `(("jdk" ,icedtea "jdk")
+      ("automake" ,automake) ; For up to date 'config.guess' and 'config.sub'.
+      ;; For tests:
+      ("hamcrest-core" ,java-hamcrest-core)
+      ("junit" ,java-junit)
+      ("slf4j-simple" ,java-slf4j-simple)))
+   (inputs
+    `(("hdf4" ,hdf4)
+      ("hdf5" ,hdf5)
+      ("zlib" ,zlib)
+      ("libjpeg" ,libjpeg)
+      ("slf4j-api" ,java-slf4j-api)))
+   (arguments
+    `(#:configure-flags
+      (list (string-append "--target=" ,(or (%current-target-system) (%current-system)))
+            (string-append "--with-jdk=" (assoc-ref %build-inputs "jdk") "/include,"
+                           (assoc-ref %build-inputs "jdk") "/lib" )
+            (string-append "--with-hdf4=" (assoc-ref %build-inputs "hdf4") "/lib")
+            (string-append "--with-hdf5=" (assoc-ref %build-inputs "hdf5") "/lib"))
+
+      #:make-flags
+      (list (string-append "HDFLIB=" (assoc-ref %build-inputs "hdf4") "/lib")
+            (string-append "HDF5LIB=" (assoc-ref %build-inputs "hdf5") "/lib")
+            (string-append "ZLIB=" (assoc-ref %build-inputs "zlib") "/lib/libz.so")
+            (string-append "JPEGLIB="
+                           (assoc-ref %build-inputs "libjpeg") "/lib/libjpeg.so")
+            "LLEXT=so")
+
+      #:phases
+      (modify-phases %standard-phases
+        (add-before 'configure 'chdir-to-source
+          (lambda _ (chdir ,(string-append "hdfjava-" version))))
+        (add-before 'configure 'patch-build
+          (lambda* (#:key inputs outputs #:allow-other-keys)
+            (substitute* "configure"
+              (("COPT=\"") "COPT=\"-O2 ") ; CFLAGS is ignored in Makefiles
+              (("/bin/cat") (which "cat")))
+            ;; Set classpath for compilation
+            (substitute* '("hdf/hdf5lib/Makefile.in"
+                           "hdf/hdf5lib/exceptions/Makefile.in"
+                           "hdf/hdflib/Makefile.in")
+              (("\\$\\(TOP\\)/lib/slf4j-api-1\\.7\\.5\\.jar")
+               (string-append (assoc-ref inputs "slf4j-api")
+                              "/share/java/slf4j-api.jar")))
+            ;; Replace outdated config.sub and config.guess:
+            (with-directory-excursion "config"
+              (for-each (lambda (file)
+                          (copy-file
+                           (string-append (assoc-ref inputs "automake")
+                                          "/share/automake-1.15/" file) file))
+                        '("config.sub" "config.guess")))
+            (mkdir-p (string-append (assoc-ref outputs "out")))
+            ;; Set classpath for tests
+            (let* ((build-dir (getcwd))
+                   (lib (string-append build-dir "/lib"))
+                   (jhdf (string-append lib "/jhdf.jar"))
+                   (jhdf5 (string-append lib "/jhdf5.jar"))
+                   (testjars
+                    (map (lambda (i)
+                           (string-append (assoc-ref inputs i)
+                                          "/share/java/" i ".jar"))
+                         '("junit" "hamcrest-core" "slf4j-api" "slf4j-simple")))
+                   (class-path
+                    (string-join `("." ,build-dir ,jhdf ,jhdf5 ,@testjars) ":")))
+
+              (substitute* '("test/hdf5lib/Makefile.in"
+                             "test/hdf5lib/junit.sh.in"
+                             "examples/runExample.sh.in")
+                (("/usr/bin/test")
+                 (string-append (assoc-ref inputs "coreutils")
+                                "/bin/test"))
+                (("/usr/bin/uname")
+                 (string-append (assoc-ref inputs "coreutils")
+                                "/bin/uname"))
+                (("CLASSPATH=[^\n]*")
+                 (string-append "CLASSPATH=" class-path)))
+              (setenv "CLASSPATH" class-path))
+            #t))
+        (add-before 'check 'build-examples
+          (lambda _
+            (apply system* `("javac"
+                             ,@(find-files "examples" ".*\\.java")))
+            #t)))
+
+      #:parallel-build? #f
+
+      #:parallel-tests? #f ))
+   (home-page "https://support.hdfgroup.org/products/java")
+   (synopsis "Java interface for the HDF4 and HDF5 libraries")
+   (description "Java HDF Interface (JHI) and Java HDF5 Interface (JHI5) use
+the Java Native Interface to wrap the HDF4 and HDF5 libraries, which are
+implemented in C.")
+
+   ;; BSD-style license:
+   (license (license:x11-style
+             "https://support.hdfgroup.org/ftp/HDF5/hdf-java\
+/current/src/unpacked/COPYING"))))
+
 (define-public hdf-eos2
   (package
     (name "hdf-eos2")
-- 
2.14.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [bug#28723] Add HDF-Java. [PATCH 1/2] gnu: Add java-slf4-simple.
  2017-10-06 16:01 [bug#28723] Add HDF-Java. [PATCH 1/2] gnu: Add java-slf4-simple Thomas Danckaert
  2017-10-06 16:20 ` [bug#28723] [PATCH 2/2] gnu: Add hdf-java Thomas Danckaert
@ 2017-10-09 19:25 ` Leo Famulari
  2017-10-10  8:18   ` julien lepiller
  2017-10-10  8:31 ` bug#28723: (no subject) Thomas Danckaert
  2 siblings, 1 reply; 7+ messages in thread
From: Leo Famulari @ 2017-10-09 19:25 UTC (permalink / raw)
  To: Thomas Danckaert; +Cc: 28723

[-- Attachment #1: Type: text/plain, Size: 684 bytes --]

On Fri, Oct 06, 2017 at 06:01:53PM +0200, Thomas Danckaert wrote:
> Hi Guix,
> 
> this patch adds the “Simple” implementation of the SLF4J interface, used by
> HDF-Java's tests.
> 
> About this patch: the tests of slf4j-simple require some of slf4j-api's test
> code, which are therefore compiled in a somewhat ad-hoc fashion, but it
> works...
> 
> Thomas

> From d034b46040d51b7e82fb95df3601dc9925fa1502 Mon Sep 17 00:00:00 2001
> From: Thomas Danckaert <post@thomasdanckaert.be>
> Date: Fri, 6 Oct 2017 12:38:34 +0200
> Subject: [PATCH 1/2] gnu: Add java-slf4-simple.
> 
> * gnu/packages/java.scm (java-slf4j-simple): New variable.

Okay, looks good to me!

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#28723] [PATCH 2/2] gnu: Add hdf-java.
  2017-10-06 16:20 ` [bug#28723] [PATCH 2/2] gnu: Add hdf-java Thomas Danckaert
@ 2017-10-09 19:27   ` Leo Famulari
  2017-10-10  6:48     ` Thomas Danckaert
  0 siblings, 1 reply; 7+ messages in thread
From: Leo Famulari @ 2017-10-09 19:27 UTC (permalink / raw)
  To: Thomas Danckaert; +Cc: 28723

[-- Attachment #1: Type: text/plain, Size: 1017 bytes --]

On Fri, Oct 06, 2017 at 06:20:42PM +0200, Thomas Danckaert wrote:
> Hi Guix,
> 
> this patch adds hdf-java.
> 
> It's quite ugly, but it seems the autotools build for this package is barely
> working and really needs a lot of patching...  (Actually, using CMake is
> recommended, but then we would have to build the HDF4 and HDF5 packages with
> CMake as well).
> 
> cheers,
> 
> Thomas

> From 619b38cc889bc41e0128f038aa78e54f71fb7dab Mon Sep 17 00:00:00 2001
> From: Thomas Danckaert <thomas.danckaert@gmail.com>
> Date: Wed, 4 Oct 2017 17:17:03 +0200
> Subject: [PATCH 2/2] gnu: Add hdf-java.
> 
> * gnu/packages/maths.scm (hdf-java): New variable.

Overall, LGTM...

> +        (add-before 'check 'build-examples
> +          (lambda _
> +            (apply system* `("javac"
> +                             ,@(find-files "examples" ".*\\.java")))
> +            #t)))

Do we have to explicity return #t here? Does the javac call not return
a value that we can pass to (zero? ...)?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#28723] [PATCH 2/2] gnu: Add hdf-java.
  2017-10-09 19:27   ` Leo Famulari
@ 2017-10-10  6:48     ` Thomas Danckaert
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Danckaert @ 2017-10-10  6:48 UTC (permalink / raw)
  To: leo; +Cc: 28723

From: Leo Famulari <leo@famulari.name>
Subject: Re: [bug#28723] [PATCH 2/2] gnu: Add hdf-java.
Date: Mon, 9 Oct 2017 15:27:02 -0400

>> +        (add-before 'check 'build-examples
>> +          (lambda _
>> +            (apply system* `("javac"
>> +                             ,@(find-files "examples" ".*\\.java")))
>> +            #t)))
> 
> Do we have to explicity return #t here? Does the javac call not return
> a value that we can pass to (zero? ...)?

Yes, I'm pretty sure this can be improved.  Good catch!

Thanks for taking a look.

Thomas

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#28723] Add HDF-Java. [PATCH 1/2] gnu: Add java-slf4-simple.
  2017-10-09 19:25 ` [bug#28723] Add HDF-Java. [PATCH 1/2] gnu: Add java-slf4-simple Leo Famulari
@ 2017-10-10  8:18   ` julien lepiller
  0 siblings, 0 replies; 7+ messages in thread
From: julien lepiller @ 2017-10-10  8:18 UTC (permalink / raw)
  To: 28723

Le 2017-10-09 21:25, Leo Famulari a écrit :
> On Fri, Oct 06, 2017 at 06:01:53PM +0200, Thomas Danckaert wrote:
>> Hi Guix,
>> 
>> this patch adds the “Simple” implementation of the SLF4J interface, 
>> used by
>> HDF-Java's tests.
>> 
>> About this patch: the tests of slf4j-simple require some of 
>> slf4j-api's test
>> code, which are therefore compiled in a somewhat ad-hoc fashion, but 
>> it
>> works...
>> 
>> Thomas
> 
>> From d034b46040d51b7e82fb95df3601dc9925fa1502 Mon Sep 17 00:00:00 2001
>> From: Thomas Danckaert <post@thomasdanckaert.be>
>> Date: Fri, 6 Oct 2017 12:38:34 +0200
>> Subject: [PATCH 1/2] gnu: Add java-slf4-simple.
>> 
>> * gnu/packages/java.scm (java-slf4j-simple): New variable.
> 
> Okay, looks good to me!

I don't know whether it's better, but I had to build slf4j-simple for 
maven. Here is what I have:

(define java-slf4j-api-tests
   (package
     (inherit java-slf4j-api)
     (name "java-slf4j-api-tests")
     (arguments
      `(#:jar-name "slf4j-api-tests.jar"
        #:source-dir "slf4j-api/src/test/java"
        #:tests? #f))
     (inputs
      `(("slf4j" ,java-slf4j-api)
        ,@(package-inputs java-slf4j-api)
        ,@(package-native-inputs java-slf4j-api)))
     (native-inputs '())))

(define-public java-slf4j-simple
   (package
     (inherit java-slf4j-api)
     (name "java-slf4j-simple")
     (arguments
      `(#:jar-name "slf4j-simple.jar"
        #:source-dir "slf4j-simple/src/main/java"
        #:test-dir "slf4j-simple/src/test"))
     (inputs
      `(("slf4j" ,java-slf4j-api)
        ,@(package-inputs java-slf4j-api)))
     (native-inputs
      `(("tests" ,java-slf4j-api-tests)
        ,@(package-native-inputs java-slf4j-api)))))

The idea is that maybe other packages in the slf4j archive will need 
these tests, so I built a package for them.

Otherwise your version LGTM too. Why do you need to build in the current 
directory and not in build/test-classes? If you build in 
build/test-classes, I think you don't need to set CLASSPATH in the 
build-slf4j-api-test-helpers phase.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#28723: (no subject)
  2017-10-06 16:01 [bug#28723] Add HDF-Java. [PATCH 1/2] gnu: Add java-slf4-simple Thomas Danckaert
  2017-10-06 16:20 ` [bug#28723] [PATCH 2/2] gnu: Add hdf-java Thomas Danckaert
  2017-10-09 19:25 ` [bug#28723] Add HDF-Java. [PATCH 1/2] gnu: Add java-slf4-simple Leo Famulari
@ 2017-10-10  8:31 ` Thomas Danckaert
  2 siblings, 0 replies; 7+ messages in thread
From: Thomas Danckaert @ 2017-10-10  8:31 UTC (permalink / raw)
  To: 28723-done



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-10-10  8:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-06 16:01 [bug#28723] Add HDF-Java. [PATCH 1/2] gnu: Add java-slf4-simple Thomas Danckaert
2017-10-06 16:20 ` [bug#28723] [PATCH 2/2] gnu: Add hdf-java Thomas Danckaert
2017-10-09 19:27   ` Leo Famulari
2017-10-10  6:48     ` Thomas Danckaert
2017-10-09 19:25 ` [bug#28723] Add HDF-Java. [PATCH 1/2] gnu: Add java-slf4-simple Leo Famulari
2017-10-10  8:18   ` julien lepiller
2017-10-10  8:31 ` bug#28723: (no subject) Thomas Danckaert

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).