rust-1.15.1.ebuild 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=6
  4. PYTHON_COMPAT=( python2_7 )
  5. inherit python-any-r1 versionator toolchain-funcs
  6. if [[ ${PV} = *beta* ]]; then
  7. betaver=${PV//*beta}
  8. BETA_SNAPSHOT="${betaver:0:4}-${betaver:4:2}-${betaver:6:2}"
  9. MY_P="rustc-beta"
  10. SLOT="beta/${PV}"
  11. SRC="${BETA_SNAPSHOT}/rustc-beta-src.tar.gz"
  12. KEYWORDS=""
  13. else
  14. ABI_VER="$(get_version_component_range 1-2)"
  15. SLOT="stable/${ABI_VER}"
  16. MY_P="rustc-${PV}"
  17. SRC="${MY_P}-src.tar.gz"
  18. KEYWORDS="~amd64 ~x86"
  19. fi
  20. CARGO_VERSION="0.$(($(get_version_component_range 2) + 1)).0"
  21. STAGE0_VERSION="1.$(($(get_version_component_range 2) - 1)).0"
  22. RUST_STAGE0_amd64="rustc-${STAGE0_VERSION}-x86_64-unknown-linux-gnu"
  23. RUST_STAGE0_x86="rustc-${STAGE0_VERSION}-i686-unknown-linux-gnu"
  24. DESCRIPTION="Systems programming language from Mozilla"
  25. HOMEPAGE="http://www.rust-lang.org/"
  26. SRC_URI="https://static.rust-lang.org/dist/${SRC} -> rustc-${PV}-src.tar.gz
  27. amd64? ( https://static.rust-lang.org/dist/${RUST_STAGE0_amd64}.tar.gz )
  28. x86? ( https://static.rust-lang.org/dist/${RUST_STAGE0_x86}.tar.gz )
  29. "
  30. LICENSE="|| ( MIT Apache-2.0 ) BSD-1 BSD-2 BSD-4 UoI-NCSA"
  31. IUSE="clang debug doc libcxx +system-llvm"
  32. REQUIRED_USE="libcxx? ( clang )"
  33. RDEPEND="libcxx? ( sys-libs/libcxx )
  34. system-llvm? ( >=sys-devel/llvm-3.8.1-r2:0
  35. <sys-devel/llvm-3.10.0:0 )
  36. "
  37. DEPEND="${RDEPEND}
  38. ${PYTHON_DEPS}
  39. >=dev-lang/perl-5.0
  40. clang? ( sys-devel/clang )
  41. "
  42. PDEPEND=">=app-eselect/eselect-rust-0.3_pre20150425
  43. >=dev-util/cargo-${CARGO_VERSION}"
  44. S="${WORKDIR}/${MY_P}-src"
  45. src_prepare() {
  46. find mk -name '*.mk' -exec \
  47. sed -i -e "s/-Werror / /g" {} \; || die
  48. default
  49. }
  50. src_configure() {
  51. export CFG_DISABLE_LDCONFIG="notempty"
  52. local stagename="RUST_STAGE0_${ARCH}"
  53. local stage0="${!stagename}"
  54. "${ECONF_SOURCE:-.}"/configure \
  55. --prefix="${EPREFIX}/usr" \
  56. --libdir="${EPREFIX}/usr/$(get_libdir)/${P}" \
  57. --mandir="${EPREFIX}/usr/share/${P}/man" \
  58. --release-channel=${SLOT%%/*} \
  59. --disable-manage-submodules \
  60. --disable-rustbuild \
  61. --default-linker=$(tc-getBUILD_CC) \
  62. --default-ar=$(tc-getBUILD_AR) \
  63. --python=${EPYTHON} \
  64. --disable-rpath \
  65. --enable-local-rust \
  66. --local-rust-root="${WORKDIR}/${stage0}/rustc" \
  67. $(use_enable clang) \
  68. $(use_enable debug) \
  69. $(use_enable debug llvm-assertions) \
  70. $(use_enable !debug optimize) \
  71. $(use_enable !debug optimize-cxx) \
  72. $(use_enable !debug optimize-llvm) \
  73. $(use_enable !debug optimize-tests) \
  74. $(use_enable doc docs) \
  75. $(use_enable libcxx libcpp) \
  76. $(usex system-llvm "--llvm-root=${EPREFIX}/usr" " ") \
  77. || die
  78. }
  79. src_compile() {
  80. emake VERBOSE=1
  81. }
  82. src_install() {
  83. unset SUDO_USER
  84. default
  85. mv "${D}/usr/bin/rustc" "${D}/usr/bin/rustc-${PV}" || die
  86. mv "${D}/usr/bin/rustdoc" "${D}/usr/bin/rustdoc-${PV}" || die
  87. mv "${D}/usr/bin/rust-gdb" "${D}/usr/bin/rust-gdb-${PV}" || die
  88. dodoc COPYRIGHT
  89. dodir "/usr/share/doc/rust-${PV}/"
  90. mv "${D}/usr/share/doc/rust"/* "${D}/usr/share/doc/rust-${PV}/" || die
  91. rmdir "${D}/usr/share/doc/rust/" || die
  92. cat <<-EOF > "${T}"/50${P}
  93. LDPATH="/usr/$(get_libdir)/${P}"
  94. MANPATH="/usr/share/${P}/man"
  95. EOF
  96. doenvd "${T}"/50${P}
  97. cat <<-EOF > "${T}/provider-${P}"
  98. /usr/bin/rustdoc
  99. /usr/bin/rust-gdb
  100. EOF
  101. dodir /etc/env.d/rust
  102. insinto /etc/env.d/rust
  103. doins "${T}/provider-${P}"
  104. }
  105. pkg_postinst() {
  106. eselect rust update --if-unset
  107. elog "Rust installs a helper script for calling GDB now,"
  108. elog "for your convenience it is installed under /usr/bin/rust-gdb-${PV}."
  109. if has_version app-editors/emacs || has_version app-editors/emacs-vcs; then
  110. elog "install app-emacs/rust-mode to get emacs support for rust."
  111. fi
  112. if has_version app-editors/gvim || has_version app-editors/vim; then
  113. elog "install app-vim/rust-vim to get vim support for rust."
  114. fi
  115. if has_version 'app-shells/zsh'; then
  116. elog "install app-shells/rust-zshcomp to get zsh completion for rust."
  117. fi
  118. }
  119. pkg_postrm() {
  120. eselect rust unset --if-invalid
  121. }