| 3 |
3 |
|
| 4 |
4 |
EAPI=8
|
| 5 |
5 |
|
| 6 |
|
JAVA_PKG_IUSE="doc test"
|
| 7 |
|
|
| 8 |
|
inherit java-pkg-2 java-pkg-simple
|
|
6 |
inherit eapi9-ver java-pkg-2
|
| 9 |
7 |
|
| 10 |
8 |
DESCRIPTION="A parser generator for many languages"
|
| 11 |
9 |
HOMEPAGE="https://www.antlr3.org/"
|
| 12 |
|
SRC_URI="https://www.antlr3.org/download/${P}.tar.gz
|
| 13 |
|
https://www.antlr3.org/download/${P}.jar" # Prebuilt version needed.
|
| 14 |
|
S="${WORKDIR}/${P}"
|
|
10 |
# Reuse tarball for DOCS
|
|
11 |
SRC_URI="https://github.com/${PN}/${PN}3/archive/${PV}.tar.gz -> ${P}.tar.gz"
|
| 15 |
12 |
|
| 16 |
13 |
LICENSE="BSD"
|
| 17 |
|
SLOT="3"
|
|
14 |
SLOT="3.5"
|
| 18 |
15 |
KEYWORDS="amd64 arm64 ppc64 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris"
|
| 19 |
|
RESTRICT="!test? ( test )"
|
| 20 |
|
|
| 21 |
|
CP_DEPEND=">=dev-java/antlr-2.7.7-r7:0
|
| 22 |
|
dev-java/stringtemplate:0"
|
| 23 |
16 |
|
| 24 |
|
RDEPEND="${CP_DEPEND}
|
| 25 |
|
>=virtual/jre-1.8:*"
|
|
17 |
CP_DEPEND="
|
|
18 |
~dev-java/antlr-runtime-${PV}:${SLOT}
|
|
19 |
~dev-java/antlr-tool-${PV}:${SLOT}
|
|
20 |
"
|
| 26 |
21 |
|
| 27 |
|
DEPEND="${CP_DEPEND}
|
|
22 |
DEPEND="
|
| 28 |
23 |
>=virtual/jdk-1.8:*
|
| 29 |
|
test? ( dev-java/junit:4 )"
|
| 30 |
|
|
| 31 |
|
PATCHES=(
|
| 32 |
|
# These fixes have been applied in 3.5.
|
| 33 |
|
"${FILESDIR}/${PV}-test-fixes.patch"
|
| 34 |
|
"${FILESDIR}/${PV}-java-8.patch"
|
| 35 |
|
"${FILESDIR}/antlr-3.2-java21.patch"
|
| 36 |
|
)
|
|
24 |
${CP_DEPEND}
|
|
25 |
"
|
| 37 |
26 |
|
| 38 |
|
JAVA_GENTOO_CLASSPATH_EXTRA="${S}/${PN}-runtime.jar"
|
| 39 |
|
|
| 40 |
|
src_unpack() {
|
| 41 |
|
unpack ${P}.tar.gz
|
| 42 |
|
}
|
|
27 |
RDEPEND="
|
|
28 |
>=virtual/jre-1.8:*
|
|
29 |
${CP_DEPEND}
|
|
30 |
"
|
| 43 |
31 |
|
| 44 |
|
src_prepare() {
|
| 45 |
|
default
|
| 46 |
|
java-pkg_clean
|
| 47 |
|
|
| 48 |
|
# Some tests fail under Java 8 in ways that probably aren't limited
|
| 49 |
|
# to the tests. This is bad but upstream is never going to update
|
| 50 |
|
# 3.2 even though other projects still rely on it. If any issues
|
| 51 |
|
# arise, we can only put pressure on those projects to upgrade.
|
| 52 |
|
local vm_version="$(java-config -g PROVIDES_VERSION)"
|
| 53 |
|
if ver_test "${vm_version}" -ge 1.8; then
|
| 54 |
|
rm -v tool/src/test/java/org/antlr/test/Test{DFAConversion,SemanticPredicates,TopologicalSort}.java || die
|
| 55 |
|
fi
|
|
32 |
S="${WORKDIR}/${PN}3-${PV}"
|
| 56 |
33 |
|
| 57 |
|
# 3.2 has strange hidden files.
|
| 58 |
|
find -type f -name "._*.*" -delete || die
|
| 59 |
|
}
|
|
34 |
DOCS=( contributors.txt README.txt )
|
| 60 |
35 |
|
| 61 |
36 |
src_compile() {
|
| 62 |
|
cd "${S}/runtime/Java/src/main" || die
|
| 63 |
|
JAVA_JAR_FILENAME="${S}/${PN}-runtime.jar" java-pkg-simple_src_compile
|
| 64 |
|
|
| 65 |
|
cd "${S}/tool/src/main" || die
|
| 66 |
|
|
| 67 |
|
local G; for G in antlr codegen antlr.print assign.types buildnfa define; do # from pom.xml
|
| 68 |
|
antlr -o antlr2/org/antlr/grammar/v2/{,${G}.g} || die
|
| 69 |
|
done
|
| 70 |
|
|
| 71 |
|
# We have applied a patch to fix this version under Java 8. Trouble
|
| 72 |
|
# is that we need to run a prebuilt version before we can build our
|
| 73 |
|
# own and that version doesn't have the fix applied. We work around
|
| 74 |
|
# this by building just the offending class against the prebuilt
|
| 75 |
|
# version and then putting them together in the classpath. That
|
| 76 |
|
# isn't all. Due to a compiler limitation that Chewi doesn't fully
|
| 77 |
|
# understand, this class cannot be compiled by itself without a
|
| 78 |
|
# couple of tweaks that have been applied in the Java 8 patch.
|
| 79 |
|
ejavac -classpath "${DISTDIR}/${P}.jar" java/org/antlr/tool/CompositeGrammar.java
|
| 80 |
|
|
| 81 |
|
java -classpath "java:${DISTDIR}/${P}.jar" org.antlr.Tool $(find antlr3 -name "*.g") || die
|
| 82 |
|
JAVA_JAR_FILENAME="${S}/${PN}-tool.jar" java-pkg-simple_src_compile
|
| 83 |
|
java-pkg_addres "${S}/${PN}-tool.jar" resources
|
|
37 |
:
|
| 84 |
38 |
}
|
| 85 |
39 |
|
| 86 |
40 |
src_install() {
|
| 87 |
|
java-pkg_dojar ${PN}-{runtime,tool}.jar
|
| 88 |
|
java-pkg_dolauncher ${PN}${SLOT} --main org.antlr.Tool
|
| 89 |
|
use doc && java-pkg_dojavadoc runtime/Java/src/main/target/api
|
| 90 |
|
}
|
|
41 |
java-pkg_regjar "$(java-pkg_getjar "antlr-runtime-${SLOT}" antlr-runtime.jar)"
|
|
42 |
java-pkg_regjar "$(java-pkg_getjar "antlr-tool-${SLOT}" antlr-tool.jar)"
|
| 91 |
43 |
|
| 92 |
|
src_test() {
|
| 93 |
|
cd tool/src/test/java || die
|
| 94 |
|
local CP=".:${S}/${PN}-runtime.jar:${S}/${PN}-tool.jar:$(java-pkg_getjars --build-only junit-4,${JAVA_GENTOO_CLASSPATH})"
|
| 95 |
|
|
| 96 |
|
local TESTS=$(find * -name "Test*.java")
|
| 97 |
|
TESTS="${TESTS//.java}"
|
| 98 |
|
TESTS="${TESTS//\//.}"
|
|
44 |
java-pkg_dolauncher "${PN}${SLOT}" --main org.antlr.Tool
|
|
45 |
einstalldocs # https://bugs.gentoo.org/789582
|
|
46 |
}
|
| 99 |
47 |
|
| 100 |
|
ejavac -classpath "${CP}" $(find -name "*.java")
|
| 101 |
|
ejunit4 -classpath "${CP}" ${TESTS}
|
|
48 |
pkg_postinst() {
|
|
49 |
# If upgrading from a version of this slot that installs JARs,
|
|
50 |
# display a message about submodule split
|
|
51 |
local changed_ver="3.5.2-r2"
|
|
52 |
ver_replacing -lt "${changed_ver}" || return
|
|
53 |
elog "Since version ${changed_ver}, ${PN}-${SLOT} no longer installs JARs."
|
|
54 |
elog "Please find the JARs from files installed by submodule packages"
|
|
55 |
elog "antlr-runtime-${SLOT} and antlr-tool-${SLOT}."
|
| 102 |
56 |
}
|