1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 inherit eutils java-pkg-2 java-pkg-simple
8 DESCRIPTION="A parser generator for many languages"
9 HOMEPAGE="https://www.antlr3.org/"
10 SRC_URI="https://github.com/${PN}/${PN}3/archive/${PV}.tar.gz -> ${P}.tar.gz
11 https://www.antlr3.org/download/${P}-complete.jar" # Prebuilt version needed.
14 KEYWORDS="amd64 ~arm ppc64 x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
16 RESTRICT="!test? ( test )"
18 CDEPEND="dev-java/stringtemplate:4"
25 test? ( dev-java/junit:4 )"
27 S="${WORKDIR}/${PN}3-${PV}"
28 JAVA_GENTOO_CLASSPATH_EXTRA="${S}/${PN}-runtime.jar"
29 JAVA_GENTOO_CLASSPATH="stringtemplate-4"
38 # This requires StringTemplate v3 and is only needed for
39 # output=template. Nothing in the tree currently needs that and the
40 # dependency situation is already hairy enough as it is.
41 rm -v runtime/Java/src/main/java/org/antlr/runtime/tree/DOTTreeGenerator.java || die
43 # Some tests have to be removed as a result.
44 rm -v tool/src/test/java/org/antlr/test/Test{RewriteTemplates,Templates}.java || die
45 epatch "${FILESDIR}/${PV}-test-fixes.patch"
47 # Some tests fail under Java 8 in ways that probably aren't limited
48 # to the tests. This is bad but upstream is never going to update
49 # 3.5. At the time of writing, we only use it to build 4 anyway.
50 if java-pkg_is-vm-version-ge 1.8; then
51 rm -v tool/src/test/java/org/antlr/test/Test{DFAConversion,SemanticPredicates,TopologicalSort}.java || die
56 cd "${S}/runtime/Java/src/main" || die
57 JAVA_JAR_FILENAME="${S}/${PN}-runtime.jar" JAVA_PKG_IUSE="doc" java-pkg-simple_src_compile
59 cd "${S}/tool/src/main" || die
60 java -jar "${DISTDIR}/${P}-complete.jar" $(find antlr3 -name "*.g") || die
61 JAVA_JAR_FILENAME="${S}/${PN}-tool.jar" java-pkg-simple_src_compile
62 java-pkg_addres "${S}/${PN}-tool.jar" resources
66 java-pkg_dojar ${PN}-{runtime,tool}.jar
67 java-pkg_dolauncher ${PN}${SLOT} --main org.antlr.Tool
68 use doc && java-pkg_dojavadoc runtime/Java/src/main/target/api
72 cd tool/src/test/java || die
73 local CP=".:${S}/${PN}-runtime.jar:${S}/${PN}-tool.jar:$(java-pkg_getjars junit-4,${JAVA_GENTOO_CLASSPATH})"
75 local TESTS=$(find * -name "Test*.java")
76 TESTS="${TESTS//.java}"
77 TESTS="${TESTS//\//.}"
79 ejavac -classpath "${CP}" $(find -name "*.java")
81 # ejunit automatically adds all registered subdependencies to the
82 # classpath, which is annoying in this case because of the cyclic
83 # dependency on stringtemplate. It will blow up when trying to find
84 # antlr-3.5 on the system before it is installed. The easiest but
85 # somewhat ugly way to avoid this is to unset JAVA_PKG_DEPEND_FILE.
86 JAVA_PKG_DEPEND_FILE= ejunit4 -classpath "${CP}" ${TESTS}