1 |
commit: c100b3fdb22c2e8bc4ce9647fc252bb189bca5c4 |
2 |
Author: Yuan Liao <liaoyuan <AT> gmail <DOT> com> |
3 |
AuthorDate: Mon Dec 20 18:15:40 2021 +0000 |
4 |
Commit: Miroslav Šulc <fordfrog <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Feb 6 09:12:53 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c100b3fd |
7 |
|
8 |
dev-java/lz4-java: Initial import |
9 |
|
10 |
Signed-off-by: Yuan Liao <liaoyuan <AT> gmail.com> |
11 |
Closes: https://github.com/gentoo/gentoo/pull/23438/commits/282a51b4d0ed56855667f7d1dca6fbd3a87b253d |
12 |
Signed-off-by: Miroslav Šulc <fordfrog <AT> gentoo.org> |
13 |
|
14 |
dev-java/lz4-java/Manifest | 1 + |
15 |
dev-java/lz4-java/files/lz4-java-1.8.0-Makefile | 47 ++++++++++ |
16 |
.../files/lz4-java-1.8.0-gentoo-classpath.xml | 7 ++ |
17 |
.../files/lz4-java-1.8.0-print-os-props.patch | 31 +++++++ |
18 |
.../lz4-java/files/lz4-java-1.8.0-skip-ivy.patch | 91 +++++++++++++++++++ |
19 |
dev-java/lz4-java/lz4-java-1.8.0.ebuild | 101 +++++++++++++++++++++ |
20 |
dev-java/lz4-java/metadata.xml | 11 +++ |
21 |
7 files changed, 289 insertions(+) |
22 |
|
23 |
diff --git a/dev-java/lz4-java/Manifest b/dev-java/lz4-java/Manifest |
24 |
new file mode 100644 |
25 |
index 000000000000..47194c6142a1 |
26 |
--- /dev/null |
27 |
+++ b/dev-java/lz4-java/Manifest |
28 |
@@ -0,0 +1 @@ |
29 |
+DIST lz4-java-1.8.0.tar.gz 1069398 BLAKE2B 02ee363fc42eeeade01f04649416dd874513f4517264c6e1b6474d64e8b81e2ee9ff1f55e51b508608929e8d78cb30e98d929cc4a118c03f86b0e69bae237e8a SHA512 ae78748d984d2ede18018d5e9ae6aee0d5fe6ac8b56d717f863968cfad6e9f85b62305692345ba16002bee68278e87a0364aa98aeb92e2af6dc169e5d5b612d4 |
30 |
|
31 |
diff --git a/dev-java/lz4-java/files/lz4-java-1.8.0-Makefile b/dev-java/lz4-java/files/lz4-java-1.8.0-Makefile |
32 |
new file mode 100644 |
33 |
index 000000000000..8d59aa8df84a |
34 |
--- /dev/null |
35 |
+++ b/dev-java/lz4-java/files/lz4-java-1.8.0-Makefile |
36 |
@@ -0,0 +1,47 @@ |
37 |
+# Gentoo custom Makefile for the JNI portion of lz4-java |
38 |
+# |
39 |
+# Adapted from the logic for target "compile-jni" in build.xml, |
40 |
+# but uses lz4 installed on the system. This Makefile respects |
41 |
+# custom CFLAGS and LDFLAGS settings, whereas build.xml does not. |
42 |
+ |
43 |
+# Java system properties read by build.xml |
44 |
+PLATFORM ?= linux |
45 |
+SRC ?= src |
46 |
+BUILD ?= build |
47 |
+JAVA_HOME ?= |
48 |
+# Requires lz4-java-*-print-os-props.patch |
49 |
+OS_ARCH := $(shell ant os-props 2>&1 > /dev/null && \ |
50 |
+ grep 'os\.arch=' os.properties | sed -e 's/os\.arch=//') |
51 |
+ |
52 |
+MKDIR_P = mkdir -p |
53 |
+ |
54 |
+SRC_DIR := $(SRC)/jni |
55 |
+OBJS_DIR_PREFIX := $(BUILD)/objects |
56 |
+OBJS_DIR := $(OBJS_DIR_PREFIX)/$(SRC_DIR) |
57 |
+OUT_DIR := $(BUILD)/jni/net/jpountz/util/$(PLATFORM)/$(OS_ARCH) |
58 |
+ |
59 |
+SRC_FILES := $(wildcard $(SRC_DIR)/*.c) |
60 |
+OBJS := $(addprefix $(OBJS_DIR_PREFIX)/,$(SRC_FILES:.c=.o)) |
61 |
+SONAME = liblz4-java.so |
62 |
+ |
63 |
+# C compiler arguments may be obtained by running 'ant -v compile-jni', |
64 |
+# as long as dev-java/cpptasks is in the classpath |
65 |
+CFLAGS := -fPIC $(CFLAGS) |
66 |
+# '--as-needed' causes test failure |
67 |
+LDFLAGS := $(LDFLAGS) -Wl,--no-as-needed |
68 |
+ |
69 |
+$(OUT_DIR)/$(SONAME): $(OBJS) | $(OUT_DIR) |
70 |
+ $(CC) $(CFLAGS) -shared $(LDFLAGS) -Wl,-soname,$(SONAME) -o $@ -llz4 $^ |
71 |
+ |
72 |
+$(OBJS_DIR_PREFIX)/%.o: %.c | $(OBJS_DIR) |
73 |
+ $(CC) $(CFLAGS) -c -o $@ \ |
74 |
+ -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/$(PLATFORM) \ |
75 |
+ -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/$(PLATFORM) \ |
76 |
+ -I$(BUILD)/jni-headers \ |
77 |
+ $< |
78 |
+ |
79 |
+$(OUT_DIR): |
80 |
+ $(MKDIR_P) $@ |
81 |
+ |
82 |
+$(OBJS_DIR): |
83 |
+ $(MKDIR_P) $@ |
84 |
|
85 |
diff --git a/dev-java/lz4-java/files/lz4-java-1.8.0-gentoo-classpath.xml b/dev-java/lz4-java/files/lz4-java-1.8.0-gentoo-classpath.xml |
86 |
new file mode 100644 |
87 |
index 000000000000..2392679c4a69 |
88 |
--- /dev/null |
89 |
+++ b/dev-java/lz4-java/files/lz4-java-1.8.0-gentoo-classpath.xml |
90 |
@@ -0,0 +1,7 @@ |
91 |
+<?xml version="1.0" encoding="utf-8"?> |
92 |
+ |
93 |
+<project name="gentoo-classpath"> |
94 |
+ <path id="mvel.classpath"> |
95 |
+ <pathelement path="${gentoo.classpath}" /> |
96 |
+ </path> |
97 |
+</project> |
98 |
|
99 |
diff --git a/dev-java/lz4-java/files/lz4-java-1.8.0-print-os-props.patch b/dev-java/lz4-java/files/lz4-java-1.8.0-print-os-props.patch |
100 |
new file mode 100644 |
101 |
index 000000000000..d4363b6853e4 |
102 |
--- /dev/null |
103 |
+++ b/dev-java/lz4-java/files/lz4-java-1.8.0-print-os-props.patch |
104 |
@@ -0,0 +1,31 @@ |
105 |
+From b8d50d44ba1c0e4b5bf297f7499ad0fb5b82706e Mon Sep 17 00:00:00 2001 |
106 |
+From: Yuan Liao <liaoyuan@×××××.com> |
107 |
+Date: Wed, 19 Jan 2022 10:09:14 -0800 |
108 |
+Subject: [PATCH] build.xml: Add target that prints JVM system properties os.* |
109 |
+ |
110 |
+The Gentoo custom JNI Makefile needs some of those properties. |
111 |
+ |
112 |
+Signed-off-by: Yuan Liao <liaoyuan@×××××.com> |
113 |
+--- |
114 |
+ build.xml | 5 +++++ |
115 |
+ 1 file changed, 5 insertions(+) |
116 |
+ |
117 |
+diff --git a/build.xml b/build.xml |
118 |
+index b7940ab..96e52ea 100644 |
119 |
+--- a/build.xml |
120 |
++++ b/build.xml |
121 |
+@@ -62,6 +62,11 @@ |
122 |
+ <javaversion atleast="10"/> |
123 |
+ </condition> |
124 |
+ |
125 |
++ <target name="os-props" |
126 |
++ description="echo values of JVM system properties os.* to file os.properties"> |
127 |
++ <echoproperties prefix="os." destfile="os.properties" /> |
128 |
++ </target> |
129 |
++ |
130 |
+ <target name="clean" description="clean working copy"> |
131 |
+ <delete dir="${build}" /> |
132 |
+ <delete dir="${dist}" /> |
133 |
+-- |
134 |
+2.34.1 |
135 |
+ |
136 |
|
137 |
diff --git a/dev-java/lz4-java/files/lz4-java-1.8.0-skip-ivy.patch b/dev-java/lz4-java/files/lz4-java-1.8.0-skip-ivy.patch |
138 |
new file mode 100644 |
139 |
index 000000000000..26c09e147072 |
140 |
--- /dev/null |
141 |
+++ b/dev-java/lz4-java/files/lz4-java-1.8.0-skip-ivy.patch |
142 |
@@ -0,0 +1,91 @@ |
143 |
+From 95ae85542f39cecd1af6a3e661ad6120195d2304 Mon Sep 17 00:00:00 2001 |
144 |
+From: Yuan Liao <liaoyuan@×××××.com> |
145 |
+Date: Mon, 20 Dec 2021 09:57:31 -0800 |
146 |
+Subject: [PATCH] build.xml: Skip Ivy logic and use Gentoo classpath |
147 |
+ |
148 |
+Signed-off-by: Yuan Liao <liaoyuan@×××××.com> |
149 |
+--- |
150 |
+ build.xml | 22 +++++++--------------- |
151 |
+ 1 file changed, 7 insertions(+), 15 deletions(-) |
152 |
+ |
153 |
+diff --git a/build.xml b/build.xml |
154 |
+index b7940ab..ff321c6 100644 |
155 |
+--- a/build.xml |
156 |
++++ b/build.xml |
157 |
+@@ -20,6 +20,8 @@ |
158 |
+ xmlns:junit4="antlib:com.carrotsearch.junit4" |
159 |
+ xmlns:mvn="antlib:org.apache.maven.artifact.ant"> |
160 |
+ |
161 |
++ <import file="gentoo-classpath.xml" /> |
162 |
++ |
163 |
+ <property name="src" location="src"/> |
164 |
+ <property name="build" location="build"/> |
165 |
+ <property name="dist" location="dist"/> |
166 |
+@@ -81,8 +83,6 @@ |
167 |
+ </target> |
168 |
+ |
169 |
+ <target name="install-cpptasks" unless="cpptasks.available"> |
170 |
+- <ivy:cachepath organisation="ant-contrib" module="cpptasks" revision="1.0b5" |
171 |
+- inline="true" conf="default" transitive="true" pathid="cpptasks.classpath"/> |
172 |
+ <taskdef uri="antlib:net.sf.antcontrib.cpptasks" resource="net/sf/antcontrib/cpptasks/antlib.xml" classpathref="cpptasks.classpath"/> |
173 |
+ <property name="cpptasks.available" value="true"/> |
174 |
+ </target> |
175 |
+@@ -117,22 +117,14 @@ |
176 |
+ |
177 |
+ <target name="init"> |
178 |
+ <tstamp /> |
179 |
+- <ivy:resolve file="${ivy.xml.name}" conf="test" /> |
180 |
+- <ivy:retrieve /> |
181 |
+ </target> |
182 |
+ |
183 |
+ <target name="install-junit4" depends="init" unless="junit4.available"> |
184 |
+- <taskdef uri="antlib:com.carrotsearch.junit4"> |
185 |
+- <classpath> |
186 |
+- <fileset dir="${lib}" includes="*.jar" /> |
187 |
+- </classpath> |
188 |
+- </taskdef> |
189 |
++ <taskdef uri="antlib:com.carrotsearch.junit4" resource="com/carrotsearch/junit4/antlib.xml" classpath="${gentoo.classpath}"/> |
190 |
+ <property name="junit4.available" value="true" /> |
191 |
+ </target> |
192 |
+ |
193 |
+ <target name="generate-sources" depends="init"> |
194 |
+- <ivy:cachepath organisation="org.mvel" module="mvel2" revision="2.3.2.Final" |
195 |
+- inline="true" conf="default" transitive="true" pathid="mvel.classpath"/> |
196 |
+ <mkdir dir="${build}/java" /> |
197 |
+ <java |
198 |
+ fork="true" |
199 |
+@@ -244,12 +236,12 @@ |
200 |
+ <pathelement path="${build}/classes" /> |
201 |
+ <pathelement path="${build}/unsafe-classes" /> |
202 |
+ <pathelement path="${build}/generated-classes" /> |
203 |
+- <fileset dir="lib" includes="*.jar" /> |
204 |
++ <pathelement path="${gentoo.classpath}" /> |
205 |
+ </path> |
206 |
+ |
207 |
+ <path id="compile.tests.classpath.with.jar"> |
208 |
+ <pathelement path="${lz4-java.jar}" /> |
209 |
+- <fileset dir="lib" includes="*.jar" /> |
210 |
++ <pathelement path="${gentoo.classpath}" /> |
211 |
+ </path> |
212 |
+ |
213 |
+ <path id="test.classpath"> |
214 |
+@@ -260,14 +252,14 @@ |
215 |
+ <pathelement path="${build}/unsafe-classes" /> |
216 |
+ <pathelement path="${build}/generated-classes" /> |
217 |
+ <pathelement path="${build}/test-classes" /> |
218 |
+- <fileset dir="${lib}" includes="*.jar" /> |
219 |
++ <pathelement path="${gentoo.classpath}" /> |
220 |
+ </path> |
221 |
+ |
222 |
+ <path id="test.classpath.with.jar"> |
223 |
+ <pathelement path="${lz4-java.jar}" /> |
224 |
+ <pathelement path="${src}/test-resources" /> |
225 |
+ <pathelement path="${build}/test-classes" /> |
226 |
+- <fileset dir="${lib}" includes="*.jar" /> |
227 |
++ <pathelement path="${gentoo.classpath}" /> |
228 |
+ </path> |
229 |
+ |
230 |
+ <target name="test" description="run tests"> |
231 |
+-- |
232 |
+2.32.0 |
233 |
+ |
234 |
|
235 |
diff --git a/dev-java/lz4-java/lz4-java-1.8.0.ebuild b/dev-java/lz4-java/lz4-java-1.8.0.ebuild |
236 |
new file mode 100644 |
237 |
index 000000000000..15c53d947049 |
238 |
--- /dev/null |
239 |
+++ b/dev-java/lz4-java/lz4-java-1.8.0.ebuild |
240 |
@@ -0,0 +1,101 @@ |
241 |
+# Copyright 2021-2022 Gentoo Authors |
242 |
+# Distributed under the terms of the GNU General Public License v2 |
243 |
+ |
244 |
+EAPI=8 |
245 |
+ |
246 |
+JAVA_PKG_IUSE="doc source test" |
247 |
+MAVEN_ID="org.lz4:lz4-java:1.8.0" |
248 |
+ |
249 |
+inherit java-pkg-2 java-ant-2 toolchain-funcs |
250 |
+ |
251 |
+DESCRIPTION="LZ4 compression for Java" |
252 |
+HOMEPAGE="https://github.com/lz4/lz4-java" |
253 |
+SRC_URI="https://github.com/lz4/lz4-java/archive/refs/tags/${PV}.tar.gz -> ${P}.tar.gz" |
254 |
+ |
255 |
+LICENSE="Apache-2.0" |
256 |
+SLOT="0" |
257 |
+KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~x86" |
258 |
+ |
259 |
+# Tests require com.carrotsearch.randomizedtesting:junit4-ant, which is yet to |
260 |
+# be packaged. Some extra steps are required before running the tests: |
261 |
+# 1. Download junit4-ant 2.7.x from https://mvnrepository.com/artifact/com.carrotsearch.randomizedtesting/junit4-ant |
262 |
+# 2. Set EANT_GENTOO_CLASSPATH_EXTRA to the path to junit4-ant-2.7.*.jar |
263 |
+# 3. arm, arm64 and ppc64 only: Install test dependencies that are unkeyworded |
264 |
+# 4. Set ALLOW_TEST="all" |
265 |
+RESTRICT="test" |
266 |
+ |
267 |
+CDEPEND=" |
268 |
+ app-arch/lz4 |
269 |
+" |
270 |
+ |
271 |
+# The version requirement on mvel is strict; mvel-2.4.* generates source files |
272 |
+# incorrectly, which causes build failure of this package |
273 |
+DEPEND=" |
274 |
+ >=virtual/jdk-1.8:* |
275 |
+ dev-java/mvel:2.3 |
276 |
+ dev-libs/xxhash |
277 |
+ test? ( |
278 |
+ dev-java/junit:4 |
279 |
+ !arm? ( !arm64? ( !ppc64? ( |
280 |
+ dev-java/randomized-runner:0 |
281 |
+ ) ) ) |
282 |
+ ) |
283 |
+ ${CDEPEND} |
284 |
+" |
285 |
+ |
286 |
+RDEPEND=" |
287 |
+ >=virtual/jre-1.8:* |
288 |
+ ${CDEPEND} |
289 |
+" |
290 |
+ |
291 |
+# Ant is only needed to generate JNI headers; |
292 |
+# the JNI shared object will be built by the custom Makefile |
293 |
+EANT_BUILD_TARGET="compile-java generate-headers" |
294 |
+EANT_DOC_TARGET="docs" |
295 |
+EANT_EXTRA_ARGS="-Djava.io.tmpdir=${T}" |
296 |
+EANT_TEST_GENTOO_CLASSPATH="randomized-runner" |
297 |
+ |
298 |
+pkg_setup() { |
299 |
+ java-pkg-2_pkg_setup |
300 |
+ local build_only_cp="$(java-pkg_getjars --build-only mvel-2.3)" |
301 |
+ if [[ -z "${EANT_GENTOO_CLASSPATH_EXTRA}" ]]; then |
302 |
+ EANT_GENTOO_CLASSPATH_EXTRA="${build_only_cp}" |
303 |
+ else |
304 |
+ EANT_GENTOO_CLASSPATH_EXTRA+=":${build_only_cp}" |
305 |
+ fi |
306 |
+} |
307 |
+ |
308 |
+src_prepare() { |
309 |
+ eapply "${FILESDIR}/${P}-print-os-props.patch" |
310 |
+ eapply "${FILESDIR}/${P}-skip-ivy.patch" |
311 |
+ cp "${FILESDIR}/${P}-Makefile" Makefile || die "Failed to copy Makefile" |
312 |
+ cp "${FILESDIR}/${P}-gentoo-classpath.xml" gentoo-classpath.xml || |
313 |
+ die "Failed to copy Gentoo classpath injection XML" |
314 |
+ java-pkg-2_src_prepare |
315 |
+ rm -r src/resources || die "Failed to remove pre-built shared libraries" |
316 |
+} |
317 |
+ |
318 |
+src_compile() { |
319 |
+ java-pkg-2_src_compile |
320 |
+ emake CC="$(tc-getCC)" JAVA_HOME="${JAVA_HOME}" |
321 |
+ # JNI has already been built by the Makefile at this point |
322 |
+ # Also pretend cpptasks is available, which is required by build.xml |
323 |
+ EANT_EXTRA_ARGS+=" -Dcpptasks.available=true -Dskip.jni=true" |
324 |
+ # Manually call 'ant jar' to include the JNI shared object in JAR |
325 |
+ eant jar -f "${EANT_BUILD_XML}" ${EANT_EXTRA_ARGS} |
326 |
+} |
327 |
+ |
328 |
+src_test() { |
329 |
+ java-pkg-2_src_test |
330 |
+} |
331 |
+ |
332 |
+src_install() { |
333 |
+ java-pkg_newjar 'dist/${ivy.module}.jar' |
334 |
+ java-pkg_doso $(find build/jni -name "*.so") |
335 |
+ use doc && java-pkg_dojavadoc build/docs |
336 |
+ # Ant project's 'sources' target generates a source JAR rather than a Zip |
337 |
+ # archive; we simply let java-utils-2.eclass create the source Zip archive |
338 |
+ # from the same source directories the 'sources' target would access |
339 |
+ # https://github.com/lz4/lz4-java/blob/1.8.0/build.xml#L323-L330 |
340 |
+ use source && java-pkg_dosrc src/java/* src/java-unsafe/* |
341 |
+} |
342 |
|
343 |
diff --git a/dev-java/lz4-java/metadata.xml b/dev-java/lz4-java/metadata.xml |
344 |
new file mode 100644 |
345 |
index 000000000000..576cd0ee41f1 |
346 |
--- /dev/null |
347 |
+++ b/dev-java/lz4-java/metadata.xml |
348 |
@@ -0,0 +1,11 @@ |
349 |
+<?xml version="1.0" encoding="UTF-8"?> |
350 |
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> |
351 |
+<pkgmetadata> |
352 |
+ <maintainer type="project"> |
353 |
+ <email>java@g.o</email> |
354 |
+ <name>Java</name> |
355 |
+ </maintainer> |
356 |
+ <upstream> |
357 |
+ <remote-id type="github">lz4/lz4-java</remote-id> |
358 |
+ </upstream> |
359 |
+</pkgmetadata> |