;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017, 2019 Ricardo Wurmus ;;; Copyright © 2017, 2018 Julien Lepiller ;;; Copyright © 2018 Marius Bakke ;;; Copyright © 2018 Mark H Weaver ;;; Copyright © 2018, 2020 Tobias Geerinckx-Rice ;;; Copyright © 2021 Efraim Flashner ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see . (define-module (gnu packages java-compression) #:use-module ((guix licenses) #:prefix license:) #:use-module (guix utils) #:use-module (guix packages) #:use-module (guix download) #:use-module (guix git-download) #:use-module (guix build-system ant) #:use-module (gnu packages) #:use-module (gnu packages compression) #:use-module (gnu packages java) #:use-module (gnu packages perl) #:use-module (gnu packages python-compression)) (define-public java-snappy (package (name "java-snappy") (version "1.1.7.5") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/xerial/snappy-java") (commit version))) (sha256 (base32 "0894zyasrmbi268d1ky9db16wrnc6x8b9ilq0b5paaxi2pwgjlrp")) (file-name (git-file-name name version)))) (build-system ant-build-system) (arguments `(#:jar-name "snappy.jar" #:source-dir "src/main/java" #:phases (modify-phases %standard-phases (add-after 'unpack 'make-git-checkout-writable (lambda _ (for-each make-file-writable (find-files ".")) #t)) (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 (invoke "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. ;; Use the -nocmake target to avoid a dependency on cmake, ;; which in turn requires the "git_unpacked" directory. (invoke "make" "native-nocmake"))) ;; 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") #t)) (add-before 'build 'set-test-memory-size (lambda _ (substitute* "build.xml" ((" 4.0.0 com.github.luben zstd-jni ~a jar zstd-jni " ,version))))) (replace 'install (install-from-pom "pom.xml"))))) (inputs `(("zstd" ,zstd))) (home-page "https://github.com/luben/zstd-jni") (synopsis "JNI bindings for Zstd native library") (description "Zstd, short for Zstandard, is a lossless compression algorithm, which provides both good compression ratio and speed for standard compression needs. This package provides JNI bindings for Zstd native library that provides fast and high compression lossless algorithm for Android, Java and all JVM languages.") (license license:bsd-2))) (define-public java-zstd-1.5.7 (package (inherit java-zstd) (version "1.5.7") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/luben/zstd-jni") (commit (string-append "v" version "-6")))) (file-name (git-file-name "java-zstd" version)) (sha256 (base32 "014pmfix7rd1p1kmalvxyigqyiii5q3l7qahfnp32pz886pjd41i")))) (arguments `(#:jar-name "zstd-jni.jar" #:source-dir "src/main/java" #:tests? #f #:phases (modify-phases %standard-phases (add-before 'build 'generate-version (lambda _ (with-output-to-file "src/main/java/com/github/luben/zstd/util/ZstdVersion.java" (lambda _ (format #t "package com.github.luben.zstd.util; public class ZstdVersion { public static final String VERSION = \"~a\"; }" ,version))))) (add-before 'install 'generate-pom (lambda _ (with-output-to-file "pom.xml" (lambda _ (format #t " 4.0.0 com.github.luben zstd-jni ~a jar zstd-jni " ,version))))) (replace 'install (install-from-pom "pom.xml")))))))