1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 JAVA_PKG_IUSE="doc source"
8 inherit eutils java-pkg-2 java-ant-2
13 MY_P=java-cup-${MY_PV%-*}
15 DESCRIPTION="CUP Parser Generator for Java"
16 HOMEPAGE="http://www2.cs.tum.edu/projects/cup/"
17 SRC_URI="http://www2.cs.tum.edu/projects/cup/releases/java-cup-src-${MY_PV}.tar.gz"
20 KEYWORDS="amd64 ~arm arm64 ppc64 x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
22 DEPEND=">=virtual/jdk-1.7
23 >=dev-java/ant-core-1.7.0:0
24 >=dev-java/jflex-1.6.1:0"
26 RDEPEND=">=virtual/jre-1.7"
28 JAVA_ANT_REWRITE_CLASSPATH="yes"
29 JAVA_ANT_CLASSPATH_TAGS+=" taskdef"
34 # Bizarrely, you can't build from the tarball without this patch.
35 epatch "${FILESDIR}"/${PN}-0.11b_beta20150326-build-xml-svn.patch
37 # The JFlex package name has changed to lower case.
38 sed -i "s/JFlex\./jflex./g" build.xml || die
40 # Remove the bundled JFlex.
41 rm -v bin/JFlex.jar || die
45 EANT_GENTOO_CLASSPATH_EXTRA=$(java-pkg_getjars --build-only ant-core,jflex)
46 java-ant-2_src_configure
50 # Annoyingly javacup bundles an older version of itself that will
51 # break jflex if that has already been built against this newer
52 # version beforehand. Even more annoyingly, the binary download is
53 # built with Java 8, which isn't much use to us. We therefore use
54 # any installed javacup that is newer than the bundled version where
55 # possible. If this approach turns out to be unworkable then we may
56 # just have to use the bundled jflex for bootstrapping.
57 if has_version \>=${CATEGORY}/${PN}-0.11b:${SLOT}; then
58 # Use PORTAGE_QUIET to suppress a QA warning that is spurious
59 # thanks to has_version above. This is Portage-specific but
60 # showing the warning elsewhere isn't the end of the world.
61 einfo "Bootstrapping with installed javacup ..."
62 EANT_GENTOO_CLASSPATH_EXTRA+=":$(PORTAGE_QUIET=1 java-pkg_getjars --build-only javacup)" eant
64 einfo "Bootstrapping with bundled javacup ..."
65 EANT_GENTOO_CLASSPATH_EXTRA+=":${S}/bin/${MY_P:0:-1}.jar" eant
68 # Clean everything except the new jar.
69 rm -rv java/ classes/ || die
71 einfo "Recompiling with newly built javacup ..."
72 EANT_GENTOO_CLASSPATH_EXTRA+=":${S}/dist/${MY_P}.jar" eant
74 use doc && ejavadoc -sourcepath src/ -d javadoc java_cup
78 java-pkg_newjar dist/${MY_P}.jar
79 java-pkg_newjar dist/${MY_P}-runtime.jar ${PN}-runtime.jar
80 java-pkg_dolauncher ${PN} --jar ${PN}.jar
81 java-pkg_register-ant-task
87 use source && java-pkg_dosrc java/*
88 use doc && java-pkg_dojavadoc javadoc