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 multilib-minimal
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 rustfmt"
20 RDEPEND=">=app-eselect/eselect-rust-20190311"
22 REQUIRED_USE="x86? ( cpu_flags_x86_sse2 )"
27 opt/${P}/lib/rustlib/*/bin/*
28 opt/${P}/lib/rustlib/*/lib/*.so
29 opt/${P}/lib/rustlib/*/lib/*.rlib*
33 if [[ "$(tc-is-softfloat)" != "no" ]] && [[ ${CHOST} == armv7* ]]; then
34 die "${CHOST} is not supported by upstream Rust. You must use a hard float version."
40 mv "${WORKDIR}/${MY_P}-$(rust_abi)" "${S}" || die
43 multilib_src_install() {
44 if multilib_is_native_abi; then
46 # start native abi install
47 pushd "${S}" >/dev/null || die
49 std="$(grep 'std' ./components)"
50 local components="rustc,cargo,${std}"
51 use doc && components="${components},rust-docs"
52 use clippy && components="${components},clippy-preview"
53 use rustfmt && components="${components},rustfmt-preview"
55 --components="${components}" \
57 --prefix="${ED}/opt/${P}" \
58 --mandir="${ED}/opt/${P}/man" \
62 local rustc=rustc-bin-${PV}
63 local rustdoc=rustdoc-bin-${PV}
64 local rustgdb=rust-gdb-bin-${PV}
65 local rustgdbgui=rust-gdbgui-bin-${PV}
66 local rustlldb=rust-lldb-bin-${PV}
68 mv "${ED}/opt/${P}/bin/rustc" "${ED}/opt/${P}/bin/${rustc}" || die
69 mv "${ED}/opt/${P}/bin/rustdoc" "${ED}/opt/${P}/bin/${rustdoc}" || die
70 mv "${ED}/opt/${P}/bin/rust-gdb" "${ED}/opt/${P}/bin/${rustgdb}" || die
71 mv "${ED}/opt/${P}/bin/rust-gdbgui" "${ED}/opt/${P}/bin/${rustgdbgui}" || die
72 mv "${ED}/opt/${P}/bin/rust-lldb" "${ED}/opt/${P}/bin/${rustlldb}" || die
74 dosym "${rustc}" "/opt/${P}/bin/rustc"
75 dosym "${rustdoc}" "/opt/${P}/bin/rustdoc"
76 dosym "${rustgdb}" "/opt/${P}/bin/rust-gdb"
77 dosym "${rustgdbgui}" "/opt/${P}/bin/rust-gdbgui"
78 dosym "${rustlldb}" "/opt/${P}/bin/rust-lldb"
80 dosym "../../opt/${P}/bin/${rustc}" "/usr/bin/${rustc}"
81 dosym "../../opt/${P}/bin/${rustdoc}" "/usr/bin/${rustdoc}"
82 dosym "../../opt/${P}/bin/${rustgdb}" "/usr/bin/${rustgdb}"
83 dosym "../../opt/${P}/bin/${rustgdbgui}" "/usr/bin/${rustgdbgui}"
84 dosym "../../opt/${P}/bin/${rustlldb}" "/usr/bin/${rustlldb}"
86 local cargo=cargo-bin-${PV}
87 mv "${ED}/opt/${P}/bin/cargo" "${ED}/opt/${P}/bin/${cargo}" || die
88 dosym "${cargo}" "/opt/${P}/bin/cargo"
89 dosym "../../opt/${P}/bin/${cargo}" "/usr/bin/${cargo}"
92 local clippy_driver=clippy-driver-bin-${PV}
93 local cargo_clippy=cargo-clippy-bin-${PV}
94 mv "${ED}/opt/${P}/bin/clippy-driver" "${ED}/opt/${P}/bin/${clippy_driver}" || die
95 mv "${ED}/opt/${P}/bin/cargo-clippy" "${ED}/opt/${P}/bin/${cargo_clippy}" || die
96 dosym "${clippy_driver}" "/opt/${P}/bin/clippy-driver"
97 dosym "${cargo_clippy}" "/opt/${P}/bin/cargo-clippy"
98 dosym "../../opt/${P}/bin/${clippy_driver}" "/usr/bin/${clippy_driver}"
99 dosym "../../opt/${P}/bin/${cargo_clippy}" "/usr/bin/${cargo_clippy}"
102 local rustfmt=rustfmt-bin-${PV}
103 local cargo_fmt=cargo-fmt-bin-${PV}
104 mv "${ED}/opt/${P}/bin/rustfmt" "${ED}/opt/${P}/bin/${rustfmt}" || die
105 mv "${ED}/opt/${P}/bin/cargo-fmt" "${ED}/opt/${P}/bin/${cargo_fmt}" || die
106 dosym "${rustfmt}" "/opt/${P}/bin/rustfmt"
107 dosym "${cargo_fmt}" "/opt/${P}/bin/cargo-fmt"
108 dosym "../../opt/${P}/bin/${rustfmt}" "/usr/bin/${rustfmt}"
109 dosym "../../opt/${P}/bin/${cargo_fmt}" "/usr/bin/${cargo_fmt}"
112 cat <<-EOF > "${T}"/50${P}
113 LDPATH="/opt/${P}/lib"
114 MANPATH="/opt/${P}/man"
118 # note: eselect-rust adds EROOT to all paths below
119 cat <<-EOF > "${T}/provider-${P}"
125 echo /usr/bin/cargo >> "${T}/provider-${P}"
127 echo /usr/bin/clippy-driver >> "${T}/provider-${P}"
128 echo /usr/bin/cargo-clippy >> "${T}/provider-${P}"
131 echo /usr/bin/rustfmt >> "${T}/provider-${P}"
132 echo /usr/bin/cargo-fmt >> "${T}/provider-${P}"
135 insinto /etc/env.d/rust
136 doins "${T}/provider-${P}"
137 popd >/dev/null || die
138 #end native abi install
142 rust_target="$(rust_abi $(get_abi_CHOST ${v##*.}))"
143 dodir "/opt/${P}/lib/rustlib"
144 cp -vr "${WORKDIR}/rust-${PV}-${rust_target}/rust-std-${rust_target}/lib/rustlib/${rust_target}"\
145 "${ED}/opt/${P}/lib/rustlib" || die
150 eselect rust update --if-unset
152 elog "Rust installs a helper script for calling GDB now,"
153 elog "for your convenience it is installed under /usr/bin/rust-gdb-bin-${PV},"
155 if has_version app-editors/emacs; then
156 elog "install app-emacs/rust-mode to get emacs support for rust."
159 if has_version app-editors/gvim || has_version app-editors/vim; then
160 elog "install app-vim/rust-vim to get vim support for rust."
163 if use elibc_musl; then
164 ewarn "${PN} on *-musl targets is configured with crt-static"
166 ewarn "you will need to set RUSTFLAGS=\"-C target-feature=-crt-static\" in make.conf"
167 ewarn "to use it with portage, otherwise you may see failures like"
168 ewarn "error: cannot produce proc-macro for serde_derive as the target "
169 ewarn "x86_64-unknown-linux-musl does not support these crate types"