dev-cpp/pangomm: stable 2.42.1 for hppa, bug #717144
[gentoo.git] / dev-lang / rust-bin / rust-bin-1.43.1.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 inherit bash-completion-r1 rust-toolchain toolchain-funcs multilib-minimal
7
8 MY_P="rust-${PV}"
9
10 DESCRIPTION="Systems programming language from Mozilla"
11 HOMEPAGE="https://www.rust-lang.org/"
12 SRC_URI="$(rust_all_arch_uris ${MY_P})"
13
14 LICENSE="|| ( MIT Apache-2.0 ) BSD-1 BSD-2 BSD-4 UoI-NCSA"
15 SLOT="stable"
16 KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~x86"
17 IUSE="clippy cpu_flags_x86_sse2 doc rustfmt"
18
19 DEPEND=""
20 RDEPEND=">=app-eselect/eselect-rust-20190311"
21
22 REQUIRED_USE="x86? ( cpu_flags_x86_sse2 )"
23
24 QA_PREBUILT="
25         opt/${P}/bin/*-${PV}
26         opt/${P}/lib/*.so
27         opt/${P}/lib/rustlib/*/bin/*
28         opt/${P}/lib/rustlib/*/lib/*.so
29         opt/${P}/lib/rustlib/*/lib/*.rlib*
30 "
31
32 pkg_pretend() {
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."
35         fi
36 }
37
38 src_unpack() {
39         default
40         mv "${WORKDIR}/${MY_P}-$(rust_abi)" "${S}" || die
41 }
42
43 multilib_src_install() {
44         if multilib_is_native_abi; then
45
46         # start native abi install
47         pushd "${S}" >/dev/null || die
48         local std
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"
54         ./install.sh \
55                 --components="${components}" \
56                 --disable-verify \
57                 --prefix="${ED}/opt/${P}" \
58                 --mandir="${ED}/opt/${P}/man" \
59                 --disable-ldconfig \
60                 || die
61
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}
67
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
73
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"
79
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}"
85
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}"
90
91         if use clippy; then
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}"
100         fi
101         if use rustfmt; then
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}"
110         fi
111
112         cat <<-EOF > "${T}"/50${P}
113         LDPATH="/opt/${P}/lib"
114         MANPATH="/opt/${P}/man"
115         EOF
116         doenvd "${T}"/50${P}
117
118         # note: eselect-rust adds EROOT to all paths below
119         cat <<-EOF > "${T}/provider-${P}"
120         /usr/bin/rustdoc
121         /usr/bin/rust-gdb
122         /usr/bin/rust-gdbgui
123         /usr/bin/rust-lldb
124         EOF
125         echo /usr/bin/cargo >> "${T}/provider-${P}"
126         if use clippy; then
127                 echo /usr/bin/clippy-driver >> "${T}/provider-${P}"
128                 echo /usr/bin/cargo-clippy >> "${T}/provider-${P}"
129         fi
130         if use rustfmt; then
131                 echo /usr/bin/rustfmt >> "${T}/provider-${P}"
132                 echo /usr/bin/cargo-fmt >> "${T}/provider-${P}"
133         fi
134
135         insinto /etc/env.d/rust
136         doins "${T}/provider-${P}"
137         popd >/dev/null || die
138         #end native abi install
139
140         else
141                 local rust_target
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
146         fi
147 }
148
149 pkg_postinst() {
150         eselect rust update --if-unset
151
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},"
154
155         if has_version app-editors/emacs; then
156                 elog "install app-emacs/rust-mode to get emacs support for rust."
157         fi
158
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."
161         fi
162
163         if use elibc_musl; then
164                 ewarn "${PN} on *-musl targets is configured with crt-static"
165                 ewarn ""
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"
170         fi
171 }
172
173 pkg_postrm() {
174         eselect rust cleanup
175 }