aboutsummaryrefslogtreecommitdiff
blob: 02c414dbb18902a8e46135126ba586dbdd9c2662 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

EAPI=5

inherit java-pkg-opt-2

if [[ ${PV} == "9999" ]]; then
	EGIT_REPO_URI="https://github.com/perl6/${PN}.git"
	inherit git-r3
	KEYWORDS=""
else
	SRC_URI="https://github.com/perl6/${PN}/tarball/${PV} -> ${P}.tar.gz"
	inherit vcs-snapshot
	KEYWORDS=""
fi

DESCRIPTION="Not Quite Perl, a Perl 6 bootstrapping compiler"
HOMEPAGE="http://rakudo.org/"

LICENSE="Artistic-2"
SLOT="0"
IUSE="doc clang java +moar test"
REQUIRED_USE="|| ( java moar )"

CDEPEND="java? (
		dev-java/asm:4
		dev-java/jline:0
		dev-java/jna:4
	)
	moar? ( ~dev-lang/moarvm-${PV}[clang=] )
	dev-libs/libffi"
RDEPEND="${CDEPEND}
	java? ( >=virtual/jre-1.7 )"
DEPEND="${CDEPEND}
	clang? ( sys-devel/clang )
	java? ( >=virtual/jdk-1.7 )
	dev-lang/perl"
PATCHES=( "${FILESDIR}/enable-external-jars.patch" )

java_prepare() {
	# Don't clean stage0 jars.
	einfo "Cleaning upstream jars"
	java-pkg_clean 3rdparty/

	# Don't use jars we just deleted.
	sed -i -r 's/(:3rdparty[^:]*)+/:${THIRDPARTY_JARS}/g' \
		src/vm/jvm/runners/nqp-j || die
}

src_configure() {
	local backends
	use java && backends+="jvm,"
	use moar && backends+="moar"

	local myconfargs=(
		"--backend=${backends}"
		"--prefix=/usr" )

	perl Configure.pl "${myconfargs[@]}" || die

	if use java; then
		# Export this for the script we sed'd above.
		export THIRDPARTY_JARS=$(java-pkg_getjars --with-dependencies asm-4,jline,jna-4)
	fi
}

src_compile() {
	if use java; then
		emake -j1 \
			  THIRDPARTY_JARS="${THIRDPARTY_JARS}" \
			  JAVAC="$(java-pkg_get-javac) $(java-pkg_javac-args)"
	else
		emake -j1
	fi
}

src_test() {
	emake -j1 test
}

src_install() {
	if use moar; then
		if use java; then
			# We need to re-run Configure.pl with only the MoarVM backend,
			# so we don't overwrite our custom java install.
			# This has to happen before the installation of nqp's MoarVM bits.
			# Also, those bits have to get installed before the JVM bits.
			perl Configure.pl --backend=moar --prefix=/usr || die
		fi
		emake DESTDIR="${ED}" install
	fi
	if use java; then
		# Set JAVA_PKG_JARDEST early.
		java-pkg_init_paths_

		# Upstream sets the classpath to this location. Perhaps it's
		# used to locate the additional libraries?
		java-pkg_addcp "${JAVA_PKG_JARDEST}"

		insinto "${JAVA_PKG_JARDEST}"
		local jar

		for jar in *.jar; do
			if has ${jar} ${PN}.jar ${PN}-runtime.jar; then
				# jars for NQP itself.
				java-pkg_dojar ${jar}
			else
				# jars used by NQP.
				doins ${jar}
			fi
		done

		# Upstream uses -Xbootclasspath/a, which is faster due to lack
		# of verification, but gjl isn't flexible enough yet. :(
		java-pkg_dolauncher ${PN}-j --main ${PN}
		dosym ${PN}-j /usr/bin/${PN}
		dobin tools/jvm/eval-client.pl
	fi

	dodoc CREDITS README.pod
	use doc && dodoc -r docs/*
}