1 # Copyright 1999-2016 Gentoo Foundation
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-pkg-simple
10 DESCRIPTION="JFlex is a lexical analyzer generator for Java"
11 HOMEPAGE="http://www.jflex.de/"
12 SRC_URI="http://${PN}.de/${P}.tar.gz"
15 KEYWORDS="amd64 ~arm ppc64 x86 ~amd64-fbsd ~ppc-macos ~x64-macos ~x86-macos"
16 IUSE="examples test vim-syntax"
18 CDEPEND="dev-java/ant-core:0"
20 RDEPEND=">=virtual/jre-1.6
21 vim-syntax? ( || ( app-editors/vim app-editors/gvim ) )
24 DEPEND=">=virtual/jdk-1.6
25 test? ( dev-java/junit:4 )
28 PDEPEND=">=dev-java/javacup-0.11b_p20151001:0"
31 JAVA_SRC_DIR="src/main/java"
34 # See below for details.
35 epatch "${FILESDIR}/icedtea-arm.patch"
37 # We need the bundled jflex.jar.
38 rm -rv ${JAVA_SRC_DIR}/java_cup examples/pom.xml || die
40 # Remove the bundled java-cup.jar if unneeded.
41 if has_version ${PDEPEND}; then
42 rm -v lib/java-cup-*.jar || die
47 # javacup is a cyclic dependency. Use the package if we have it,
48 # otherwise use the bundled version and install the package later.
49 if has_version ${PDEPEND}; then
50 # Use PORTAGE_QUIET to suppress a QA warning that is spurious
51 # thanks to has_version above. This is Portage-specific but
52 # showing the warning elsewhere isn't the end of the world.
53 JAVACUP=$(PORTAGE_QUIET=1 java-pkg_getjar --build-only javacup javacup.jar)
55 JAVACUP=$(echo lib/java-cup-*.jar)
58 JAVA_GENTOO_CLASSPATH_EXTRA="$(java-pkg_getjars --build-only ant-core):${JAVACUP}"
62 java "${@}" jflex.Main -d ${JAVA_SRC_DIR}/${PN} --skel src/main/${PN}/skeleton.nested src/main/${PN}/LexScan.flex || die
63 java-pkg-simple_src_compile
64 java-pkg_addres ${PN}.jar src/main/resources
68 java -jar "${JAVACUP}" -destdir ${JAVA_SRC_DIR}/${PN} -package ${PN} -parser LexParse -interface src/main/cup/LexParse.cup || die
70 # The IcedTea ARM HotSpot port (as of 2.6.1) hangs when running
71 # jflex. We have patched jflex to fix it but we have to run the
72 # bundled version first. -Xint works around the problem. See
73 # http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=2678.
74 use arm && local JFLEX_ARGS="-Xint"
76 # First compile (without doc/source) using the bundled jflex.
77 JAVA_PKG_IUSE= jflex_compile -cp "lib/${P}.jar:${JAVACUP}" ${JFLEX_ARGS}
79 # Then recompile using the fresh jflex.
80 jflex_compile -cp "${PN}.jar:${JAVACUP}"
84 java-pkg-simple_src_install
85 java-pkg_dolauncher ${PN} --main ${PN}.Main
87 java-pkg_register-dependency javacup javacup-runtime.jar
88 java-pkg_register-ant-task
90 use examples && java-pkg_doexamples examples
91 dodoc {changelog,README}.md
96 dodoc doc/*.{css,html,png} doc/COPYRIGHT
99 if use vim-syntax; then
100 insinto /usr/share/vim/vimfiles/syntax
106 if use arm && java-pkg_current-vm-matches oracle-jdk-bin-1.8; then
107 # This results in a StackOverflowError as of 1.8.0.65 but works
108 # fine on icedtea:7. Don't know about icedtea:8 yet.
109 rm -v src/test/java/jflex/EmitterTest.java || die
112 local CP="src/test/java:${PN}.jar:${JAVA_GENTOO_CLASSPATH_EXTRA}:$(java-pkg_getjars junit-4)"
114 local TESTS=$(find src/test/java -name "*Test*.java" -printf "%P\n")
115 TESTS="${TESTS//.java}"
116 TESTS="${TESTS//\//.}"
118 ejavac -classpath "${CP}" $(find src/test/java -name "*.java")
119 ejunit4 -classpath "${CP}" ${TESTS}