dev-cpp/pangomm: stable 2.42.1 for hppa, bug #717144
[gentoo.git] / dev-lang / rust-bin / rust-bin-1.42.0.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
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 libressl rustfmt"
18
19 DEPEND=""
20 RDEPEND="
21         >=app-eselect/eselect-rust-20190311
22         sys-libs/zlib
23         !libressl? ( dev-libs/openssl:0= )
24         libressl? ( dev-libs/libressl:0= )
25         net-libs/libssh2
26         net-misc/curl[ssl]
27 "
28
29 REQUIRED_USE="x86? ( cpu_flags_x86_sse2 )"
30
31 QA_PREBUILT="
32         opt/${P}/bin/*-${PV}
33         opt/${P}/lib/*.so
34         opt/${P}/lib/rustlib/*/bin/*
35         opt/${P}/lib/rustlib/*/lib/*.so
36         opt/${P}/lib/rustlib/*/lib/*.rlib*
37 "
38
39 pkg_pretend() {
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."
42         fi
43 }
44
45 src_unpack() {
46         default
47         mv "${WORKDIR}/${MY_P}-$(rust_abi)" "${S}" || die
48 }
49
50 src_install() {
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"
56         ./install.sh \
57                 --components="${components}" \
58                 --disable-verify \
59                 --prefix="${ED}/opt/${P}" \
60                 --mandir="${ED}/opt/${P}/man" \
61                 --disable-ldconfig \
62                 || die
63
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}
69
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
75
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"
81
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}"
87
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}"
92
93         if use clippy; then
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}"
102         fi
103         if use rustfmt; then
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}"
112         fi
113
114         cat <<-EOF > "${T}"/50${P}
115         LDPATH="/opt/${P}/lib"
116         MANPATH="/opt/${P}/man"
117         EOF
118         doenvd "${T}"/50${P}
119
120         # note: eselect-rust adds EROOT to all paths below
121         cat <<-EOF > "${T}/provider-${P}"
122         /usr/bin/rustdoc
123         /usr/bin/rust-gdb
124         /usr/bin/rust-gdbgui
125         /usr/bin/rust-lldb
126         EOF
127         echo /usr/bin/cargo >> "${T}/provider-${P}"
128         if use clippy; then
129                 echo /usr/bin/clippy-driver >> "${T}/provider-${P}"
130                 echo /usr/bin/cargo-clippy >> "${T}/provider-${P}"
131         fi
132         if use rustfmt; then
133                 echo /usr/bin/rustfmt >> "${T}/provider-${P}"
134                 echo /usr/bin/cargo-fmt >> "${T}/provider-${P}"
135         fi
136
137         insinto /etc/env.d/rust
138         doins "${T}/provider-${P}"
139 }
140
141 pkg_postinst() {
142         eselect rust update --if-unset
143
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},"
146
147         if has_version app-editors/emacs; then
148                 elog "install app-emacs/rust-mode to get emacs support for rust."
149         fi
150
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."
153         fi
154
155         if use elibc_musl; then
156                 ewarn "${PN} on *-musl targets is configured with crt-static"
157                 ewarn ""
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"
162         fi
163 }
164
165 pkg_postrm() {
166         eselect rust cleanup
167 }