nqp-2017.02.ebuild 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. inherit java-pkg-opt-2 multibuild
  5. if [[ ${PV} == "9999" ]]; then
  6. EGIT_REPO_URI="https://github.com/perl6/${PN}.git"
  7. inherit git-r3
  8. KEYWORDS=""
  9. else
  10. SRC_URI="https://github.com/perl6/${PN}/tarball/${PV} -> ${P}.tar.gz"
  11. inherit vcs-snapshot
  12. KEYWORDS="~amd64 ~x86"
  13. fi
  14. DESCRIPTION="Not Quite Perl, a Perl 6 bootstrapping compiler"
  15. HOMEPAGE="http://rakudo.org/"
  16. LICENSE="Artistic-2"
  17. SLOT="0"
  18. IUSE="doc clang java +moar test"
  19. REQUIRED_USE="|| ( java moar )"
  20. CDEPEND="java? (
  21. dev-java/asm:4
  22. dev-java/jline:0
  23. dev-java/jna:4
  24. )
  25. moar? ( ~dev-lang/moarvm-${PV}[clang=] )"
  26. RDEPEND="${CDEPEND}
  27. java? ( >=virtual/jre-1.7 )"
  28. DEPEND="${CDEPEND}
  29. clang? ( sys-devel/clang )
  30. java? ( >=virtual/jdk-1.7 )
  31. dev-lang/perl"
  32. pkg_pretend() {
  33. if has_version dev-lang/rakudo || has_version dev-lang/nqp; then
  34. ewarn "NQP is known to fail compilation/installation with Rakudo and/or NQP"
  35. ewarn "already being installed. So if it fails, try uninstalling both"
  36. ewarn "dev-lang/nqp and dev-lang/rakudo, then do a new installation."
  37. ewarn "(see Bug #584394)"
  38. fi
  39. }
  40. java_prepare() {
  41. # Don't clean stage0 jars.
  42. einfo "Cleaning upstream jars"
  43. java-pkg_clean 3rdparty/
  44. # Don't use jars we just deleted.
  45. sed -i -r 's/(:3rdparty[^:]*)+/:${THIRDPARTY_JARS}/g' \
  46. src/vm/jvm/runners/nqp-j || die
  47. }
  48. src_prepare() {
  49. MULTIBUILD_VARIANTS=()
  50. use moar && MULTIBUILD_VARIANTS+=( moar )
  51. use java && MULTIBUILD_VARIANTS+=( jvm )
  52. multibuild_copy_sources
  53. # This will pull in conditional java_prepare
  54. default
  55. }
  56. nqp_configure() {
  57. pushd "${BUILD_DIR}" > /dev/null || die
  58. local myconfargs=(
  59. "--backend=${MULTIBUILD_VARIANT}"
  60. "--prefix=/usr" )
  61. perl Configure.pl "${myconfargs[@]}" || die
  62. popd || die
  63. }
  64. nqp_compile() {
  65. if [[ "${MULTIBUILD_VARIANT}" = jvm ]]; then
  66. emake -j1 \
  67. -C "${BUILD_DIR}" \
  68. THIRDPARTY_JARS=$(java-pkg_getjars --with-dependencies asm-4,jline,jna-4) \
  69. JAVAC="$(java-pkg_get-javac) $(java-pkg_javac-args)"
  70. elif [[ "${MULTIBUILD_VARIANT}" = moar ]]; then
  71. emake -j1 \
  72. -C "${BUILD_DIR}"
  73. fi
  74. }
  75. nqp_test() {
  76. emake -j1 \
  77. -C "${BUILD_DIR}" \
  78. test
  79. }
  80. nqp_install() {
  81. # This is the actual reason we need multibuild.eclass.
  82. # We need to distinguish the install procedure for MoarVM and JVM backends.
  83. case "${MULTIBUILD_VARIANT}" in
  84. moar)
  85. emake \
  86. DESTDIR="${ED}" \
  87. -C "${BUILD_DIR}" \
  88. install
  89. ;;
  90. jvm)
  91. pushd "${BUILD_DIR}" > /dev/null || die
  92. # Set JAVA_PKG_JARDEST early.
  93. java-pkg_init_paths_
  94. # Upstream sets the classpath to this location. Perhaps it's
  95. # used to locate the additional libraries?
  96. java-pkg_addcp "${JAVA_PKG_JARDEST}"
  97. insinto "${JAVA_PKG_JARDEST}"
  98. local jar
  99. for jar in *.jar; do
  100. if has ${jar} ${PN}.jar ${PN}-runtime.jar; then
  101. # jars for NQP itself.
  102. java-pkg_dojar ${jar}
  103. else
  104. # jars used by NQP.
  105. doins ${jar}
  106. fi
  107. done
  108. # Upstream uses -Xbootclasspath/a, which is faster due to lack
  109. # of verification, but gjl isn't flexible enough yet. :(
  110. java-pkg_dolauncher ${PN}-j --main ${PN}
  111. dosym ${PN}-j /usr/bin/${PN}
  112. dobin tools/jvm/eval-client.pl
  113. popd > /dev/null || die
  114. ;;
  115. *)
  116. die "Unknown MULTIBUILD_VARIANT ${MULTIBUILD_VARIANT}."
  117. ;;
  118. esac
  119. }
  120. src_configure() {
  121. multibuild_foreach_variant nqp_configure
  122. }
  123. src_compile() {
  124. multibuild_foreach_variant nqp_compile
  125. }
  126. src_test() {
  127. multibuild_foreach_variant nqp_test
  128. }
  129. src_install() {
  130. multibuild_foreach_variant nqp_install
  131. dodoc CREDITS README.pod
  132. use doc && dodoc -r docs/*
  133. }