unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: julien@lepiller.eu
To: 29221@debbugs.gnu.org
Subject: [bug#29221] [PATCH 02/19] gnu: Add java-snappy.
Date: Wed,  8 Nov 2017 23:51:23 +0100	[thread overview]
Message-ID: <20171108225140.6587-2-julien@lepiller.eu> (raw)
In-Reply-To: <20171108225140.6587-1-julien@lepiller.eu>

From: Julien Lepiller <julien@lepiller.eu>

* gnu/packages/compression.scm (java-snappy): New variable.
---
 gnu/packages/compression.scm | 122 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 122 insertions(+)

diff --git a/gnu/packages/compression.scm b/gnu/packages/compression.scm
index fb3de8e07..e739546fd 100644
--- a/gnu/packages/compression.scm
+++ b/gnu/packages/compression.scm
@@ -42,6 +42,7 @@
   #:use-module (guix packages)
   #: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 perl)
@@ -54,6 +55,7 @@
   #:use-module (gnu packages check)
   #:use-module (gnu packages curl)
   #:use-module (gnu packages file)
+  #:use-module (gnu packages java)
   #:use-module (gnu packages maths)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
@@ -1082,6 +1084,126 @@ for most inputs, but the resulting compressed files are anywhere from 20% to
 100% bigger.")
     (license license:asl2.0)))
 
+(define bitshuffle-for-snappy
+  (package
+    (inherit bitshuffle)
+    (name "bitshuffle-for-snappy")
+    (build-system gnu-build-system)
+    (arguments
+     `(#:tests? #f
+       #:phases
+       (modify-phases %standard-phases
+         (replace 'configure
+           (lambda* (#:key outputs #:allow-other-keys)
+             (with-output-to-file "Makefile"
+               (lambda _
+                 (display
+                   (string-append
+                     "libbitshuffle.so: src/bitshuffle.o src/bitshuffle_core.o "
+                     "src/iochain.o lz4/lz4.o\n"
+                     "\tgcc -O3 -ffast-math -std=c99 -o $@ -shared -fPIC $^\n"
+                     "\n"
+                     "%.o: %.c\n"
+                     "\tgcc -O3 -ffast-math -std=c99 -fPIC -Isrc -Ilz4 -c $< -o $@\n"
+                     "\n"
+                     "PREFIX:=" (assoc-ref outputs "out") "\n"
+                     "LIBDIR:=$(PREFIX)/lib\n"
+                     "INCLUDEDIR:=$(PREFIX)/include\n"
+                     "install: libbitshuffle.so\n"
+                     "\tinstall -dm755 $(LIBDIR)\n"
+                     "\tinstall -dm755 $(INCLUDEDIR)\n"
+                     "\tinstall -m755 libbitshuffle.so $(LIBDIR)\n"
+                     "\tinstall -m644 src/bitshuffle.h $(INCLUDEDIR)\n"
+                     "\tinstall -m644 src/bitshuffle_core.h $(INCLUDEDIR)\n"
+                     "\tinstall -m644 src/iochain.h $(INCLUDEDIR)\n"
+                     "\tinstall -m644 lz4/lz4.h $(INCLUDEDIR)\n")))))))))
+    (inputs '())
+    (native-inputs '())))
+
+(define-public java-snappy
+  (package
+    (name "java-snappy")
+    (version "1.1.4")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://github.com/xerial/snappy-java/archive/"
+                                  version ".tar.gz"))
+              (file-name (string-append name "-" version ".tar.gz"))
+              (sha256
+               (base32
+                "1w58diryma7qz7aa24yv8shf3flxcbbw8jgcn2lih14wgmww58ww"))))
+    (build-system ant-build-system)
+    (arguments
+     `(#:jar-name "snappy.jar"
+       #:source-dir "src/main/java"
+       #:phases
+       (modify-phases %standard-phases
+         (add-before 'build 'remove-binaries
+           (lambda _
+             (delete-file "lib/org/xerial/snappy/OSInfo.class")
+             (delete-file-recursively "src/main/resources/org/xerial/snappy/native")
+             #t))
+         (add-before 'build 'build-jni
+           (lambda _
+             ;; Rebuild one of the binaries we removed earlier
+             (system* "javac" "src/main/java/org/xerial/snappy/OSInfo.java"
+                      "-d" "lib")
+             ;; Link to the dynamic bitshuffle and snappy, not the static ones
+             (substitute* "Makefile.common"
+               (("-shared")
+                "-shared -lbitshuffle -lsnappy"))
+             (substitute* "Makefile"
+               ;; Don't try to use git, don't download bitshuffle source
+               ;; and don't build it.
+               (("\\$\\(SNAPPY_GIT_UNPACKED\\) ")
+                "")
+               ((": \\$\\(SNAPPY_GIT_UNPACKED\\)")
+                ":")
+               (("\\$\\(BITSHUFFLE_UNPACKED\\) ")
+                "")
+               ((": \\$\\(SNAPPY_SOURCE_CONFIGURED\\)") ":")
+               ;; What we actually want to build
+               (("SNAPPY_OBJ:=.*")
+                "SNAPPY_OBJ:=$(addprefix $(SNAPPY_OUT)/, \
+                 SnappyNative.o BitShuffleNative.o)\n")
+               ;; Since we removed the directory structure in "native" during
+               ;; the previous phase, we need to recreate it.
+               (("NAME\\): \\$\\(SNAPPY_OBJ\\)")
+                "NAME): $(SNAPPY_OBJ)\n\t@mkdir -p $(@D)"))
+             ;; Finally we can run the Makefile to build the dynamic library.
+             (zero? (system* "make" "native"))))
+         ;; Once we have built the shared library, we need to place it in the
+         ;; "build" directory so it can be added to the jar file.
+         (add-after 'build-jni 'copy-jni
+           (lambda _
+             (copy-recursively "src/main/resources/org/xerial/snappy/native"
+                               "build/classes/org/xerial/snappy/native")))
+         (add-before 'check 'fix-failing
+           (lambda _
+             ;; This package assumes maven build, which puts results in "target".
+             ;; We put them in "build" instead, so fix that.
+             (substitute* "src/test/java/org/xerial/snappy/SnappyLoaderTest.java"
+               (("target/classes") "build/classes"))
+             ;; FIXME: probably an error
+             (substitute* "src/test/java/org/xerial/snappy/SnappyOutputStreamTest.java"
+               (("91080") "91013")))))))
+    (inputs
+     `(("osgi-framework" ,java-osgi-framework)))
+    (propagated-inputs
+     `(("bitshuffle" ,bitshuffle-for-snappy)
+       ("snappy" ,snappy)))
+    (native-inputs
+     `(("junit" ,java-junit)
+       ("hamcrest" ,java-hamcrest-core)
+       ("xerial-core" ,java-xerial-core)
+       ("classworlds" ,java-plexus-classworlds)
+       ("perl" ,perl)))
+    (home-page "https://github.com/xerial/snappy-java")
+    (synopsis "Compression/decompression algorithm in Java")
+    (description "Snappy-java is a Java port of the snappy, a fast C++
+compresser/decompresser.")
+    (license license:asl2.0)))
+
 (define-public p7zip
   (package
     (name "p7zip")
-- 
2.15.0

  reply	other threads:[~2017-11-08 22:54 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-08 22:48 [bug#29221] [PATCH] java packages Julien Lepiller
2017-11-08 22:51 ` [bug#29221] [PATCH 01/19] gnu: Add bitshuffle julien
2017-11-08 22:51   ` julien [this message]
2017-11-08 22:51   ` [bug#29221] [PATCH 03/19] gnu: Add java-iq80-snappy julien
2017-11-08 22:51   ` [bug#29221] [PATCH 04/19] licenses: Add cddl1.1 julien
2017-11-09 15:31     ` Ludovic Courtès
2017-11-16 20:54       ` Julien Lepiller
2017-11-16 21:16         ` Tobias Geerinckx-Rice
2017-11-16 21:13           ` Julien Lepiller
2017-11-17 10:08             ` Ludovic Courtès
2017-11-08 22:51   ` [bug#29221] [PATCH 05/19] gnu: Add java-mail julien
2017-11-08 23:03     ` ng0
2017-11-09  8:36       ` julien lepiller
2017-11-08 22:51   ` [bug#29221] [PATCH 06/19] gnu: Add java-jeromq julien
2017-11-08 22:51   ` [bug#29221] [PATCH 07/19] gnu: Add java-commons-csv julien
2017-11-08 22:51   ` [bug#29221] [PATCH 08/19] gnu: Add java-commons-collections julien
2017-11-08 22:51   ` [bug#29221] [PATCH 09/19] gnu: Add java-commons-beanutils julien
2017-11-08 22:51   ` [bug#29221] [PATCH 10/19] gnu: Add java-kafka-clients julien
2017-11-08 22:51   ` [bug#29221] [PATCH 11/19] gnu: Add java-log4j-core julien
2017-11-08 22:51   ` [bug#29221] [PATCH 12/19] gnu: Add java-log4j-1.2-api julien
2017-11-08 22:51   ` [bug#29221] [PATCH 13/19] gnu: Add java-jdom julien
2017-11-08 22:51   ` [bug#29221] [PATCH 14/19] gnu: Add java-geronimo-xbean-reflect julien
2017-11-08 22:51   ` [bug#29221] [PATCH 15/19] gnu: Add java-tukaani-xz julien
2017-11-08 22:51   ` [bug#29221] [PATCH 16/19] gnu: Add java-plexus-container-default-bootstrap julien
2017-11-08 22:51   ` [bug#29221] [PATCH 17/19] gnu: Add java-plexus-io julien
2017-11-08 22:51   ` [bug#29221] [PATCH 18/19] gnu: Add java-plexus-archiver julien
2017-11-08 22:51   ` [bug#29221] [PATCH 19/19] gnu: Add java-plexus-container-default julien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171108225140.6587-2-julien@lepiller.eu \
    --to=julien@lepiller.eu \
    --cc=29221@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).