1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 inherit bash-completion-r1 rust-toolchain toolchain-funcs
10 DESCRIPTION="Systems programming language from Mozilla"
11 HOMEPAGE="https://www.rust-lang.org/"
12 SRC_URI="$(rust_all_arch_uris ${MY_P})"
14 LICENSE="|| ( MIT Apache-2.0 ) BSD-1 BSD-2 BSD-4 UoI-NCSA"
16 KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~x86"
17 IUSE="clippy cpu_flags_x86_sse2 doc libressl rustfmt"
21 >=app-eselect/eselect-rust-20190311
23 !libressl? ( dev-libs/openssl:0= )
24 libressl? ( dev-libs/libressl:0= )
29 REQUIRED_USE="x86? ( cpu_flags_x86_sse2 )"
34 opt/${P}/lib/rustlib/*/bin/*
35 opt/${P}/lib/rustlib/*/lib/*.so
36 opt/${P}/lib/rustlib/*/lib/*.rlib*
40 if [[ "$(tc-is-softfloat)" != "no" ]] && [[ ${CHOST} == armv7* ]]; then
41 die "${CHOST} is not supported by upstream Rust. You must use a hard float version."
47 mv "${WORKDIR}/${MY_P}-$(rust_abi)" "${S}" || die
51 local std=$(grep 'std' ./components)
52 local components="rustc,cargo,${std}"
53 use doc && components="${components},rust-docs"
54 use clippy && components="${components},clippy-preview"
55 use rustfmt && components="${components},rustfmt-preview"
57 --components="${components}" \
59 --prefix="${ED}/opt/${P}" \
60 --mandir="${ED}/opt/${P}/man" \
64 local rustc=rustc-bin-${PV}
65 local rustdoc=rustdoc-bin-${PV}
66 local rustgdb=rust-gdb-bin-${PV}
67 local rustgdbgui=rust-gdbgui-bin-${PV}
68 local rustlldb=rust-lldb-bin-${PV}
70 mv "${ED}/opt/${P}/bin/rustc" "${ED}/opt/${P}/bin/${rustc}" || die
71 mv "${ED}/opt/${P}/bin/rustdoc" "${ED}/opt/${P}/bin/${rustdoc}" || die
72 mv "${ED}/opt/${P}/bin/rust-gdb" "${ED}/opt/${P}/bin/${rustgdb}" || die
73 mv "${ED}/opt/${P}/bin/rust-gdbgui" "${ED}/opt/${P}/bin/${rustgdbgui}" || die
74 mv "${ED}/opt/${P}/bin/rust-lldb" "${ED}/opt/${P}/bin/${rustlldb}" || die
76 dosym "${rustc}" "/opt/${P}/bin/rustc"
77 dosym "${rustdoc}" "/opt/${P}/bin/rustdoc"
78 dosym "${rustgdb}" "/opt/${P}/bin/rust-gdb"
79 dosym "${rustgdbgui}" "/opt/${P}/bin/rust-gdbgui"
80 dosym "${rustlldb}" "/opt/${P}/bin/rust-lldb"
82 dosym "../../opt/${P}/bin/${rustc}" "/usr/bin/${rustc}"
83 dosym "../../opt/${P}/bin/${rustdoc}" "/usr/bin/${rustdoc}"
84 dosym "../../opt/${P}/bin/${rustgdb}" "/usr/bin/${rustgdb}"
85 dosym "../../opt/${P}/bin/${rustgdbgui}" "/usr/bin/${rustgdbgui}"
86 dosym "../../opt/${P}/bin/${rustlldb}" "/usr/bin/${rustlldb}"
88 local cargo=cargo-bin-${PV}
89 mv "${ED}/opt/${P}/bin/cargo" "${ED}/opt/${P}/bin/${cargo}" || die
90 dosym "${cargo}" "/opt/${P}/bin/cargo"
91 dosym "../../opt/${P}/bin/${cargo}" "/usr/bin/${cargo}"
94 local clippy_driver=clippy-driver-bin-${PV}
95 local cargo_clippy=cargo-clippy-bin-${PV}
96 mv "${ED}/opt/${P}/bin/clippy-driver" "${ED}/opt/${P}/bin/${clippy_driver}" || die
97 mv "${ED}/opt/${P}/bin/cargo-clippy" "${ED}/opt/${P}/bin/${cargo_clippy}" || die
98 dosym "${clippy_driver}" "/opt/${P}/bin/clippy-driver"
99 dosym "${cargo_clippy}" "/opt/${P}/bin/cargo-clippy"
100 dosym "../../opt/${P}/bin/${clippy_driver}" "/usr/bin/${clippy_driver}"
101 dosym "../../opt/${P}/bin/${cargo_clippy}" "/usr/bin/${cargo_clippy}"
104 local rustfmt=rustfmt-bin-${PV}
105 local cargo_fmt=cargo-fmt-bin-${PV}
106 mv "${ED}/opt/${P}/bin/rustfmt" "${ED}/opt/${P}/bin/${rustfmt}" || die
107 mv "${ED}/opt/${P}/bin/cargo-fmt" "${ED}/opt/${P}/bin/${cargo_fmt}" || die
108 dosym "${rustfmt}" "/opt/${P}/bin/rustfmt"
109 dosym "${cargo_fmt}" "/opt/${P}/bin/cargo-fmt"
110 dosym "../../opt/${P}/bin/${rustfmt}" "/usr/bin/${rustfmt}"
111 dosym "../../opt/${P}/bin/${cargo_fmt}" "/usr/bin/${cargo_fmt}"
114 cat <<-EOF > "${T}"/50${P}
115 LDPATH="/opt/${P}/lib"
116 MANPATH="/opt/${P}/man"
120 # note: eselect-rust adds EROOT to all paths below
121 cat <<-EOF > "${T}/provider-${P}"
127 echo /usr/bin/cargo >> "${T}/provider-${P}"
129 echo /usr/bin/clippy-driver >> "${T}/provider-${P}"
130 echo /usr/bin/cargo-clippy >> "${T}/provider-${P}"
133 echo /usr/bin/rustfmt >> "${T}/provider-${P}"
134 echo /usr/bin/cargo-fmt >> "${T}/provider-${P}"
137 insinto /etc/env.d/rust
138 doins "${T}/provider-${P}"
142 eselect rust update --if-unset
144 elog "Rust installs a helper script for calling GDB now,"
145 elog "for your convenience it is installed under /usr/bin/rust-gdb-bin-${PV},"
147 if has_version app-editors/emacs; then
148 elog "install app-emacs/rust-mode to get emacs support for rust."
151 if has_version app-editors/gvim || has_version app-editors/vim; then
152 elog "install app-vim/rust-vim to get vim support for rust."
155 if use elibc_musl; then
156 ewarn "${PN} on *-musl targets is configured with crt-static"
158 ewarn "you will need to set RUSTFLAGS=\"-C target-feature=-crt-static\" in make.conf"
159 ewarn "to use it with portage, otherwise you may see failures like"
160 ewarn "error: cannot produce proc-macro for serde_derive v1.0.98 as the target "
161 ewarn "x86_64-unknown-linux-musl does not support these crate types"