Skip to content

Commit 1829a24

Browse files
committed
dev-lang/rust-bin: Add from Gentoo
It's from Gentoo commit 9d912d90da153773ba9f0a36d36e4c53a1edd900.
1 parent c9b6aed commit 1829a24

18 files changed

+4229
-0
lines changed

sdk_container/src/third_party/portage-stable/dev-lang/rust-bin/Manifest

Lines changed: 278 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
3+
<pkgmetadata>
4+
<maintainer type="person" proxied="yes">
5+
<email>randy@electronsweatshop.com</email>
6+
<name>Randy Barlow</name>
7+
</maintainer>
8+
<maintainer type="person" proxied="yes">
9+
<email>navi@vlhl.dev</email>
10+
<name>Anna Figueiredo Gomes</name>
11+
</maintainer>
12+
<maintainer type="person" proxied="yes">
13+
<email>matoro_gentoo@matoro.tk</email>
14+
<name>Matoro Mahri</name>
15+
</maintainer>
16+
<maintainer type="project">
17+
<email>rust@gentoo.org</email>
18+
<name>Rust Project</name>
19+
</maintainer>
20+
<use>
21+
<flag name="clippy">Install clippy, Rust code linter</flag>
22+
<flag name="profiler">Build the profiler runtime and rust-demangler tool (needed for '-C profile-generate' or '-C instrument-coverage' codegen opts)</flag>
23+
<flag name="rustfmt">Install rustfmt, Rust code formatter</flag>
24+
<flag name="rust-analyzer">Install rust-analyzer, A Rust compiler front-end for IDEs (language server)</flag>
25+
<flag name="rust-src">Install rust-src, needed by developer tools and for build-std (cross)</flag>
26+
</use>
27+
<upstream>
28+
<remote-id type="github">rust-lang/rust</remote-id>
29+
</upstream>
30+
</pkgmetadata>
Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
# Copyright 1999-2024 Gentoo Authors
2+
# Distributed under the terms of the GNU General Public License v2
3+
4+
EAPI=8
5+
6+
LLVM_COMPAT=( 16 )
7+
LLVM_OPTIONAL="yes"
8+
9+
inherit llvm-r1 multilib prefix rust-toolchain toolchain-funcs verify-sig multilib-minimal
10+
11+
MY_P="rust-${PV}"
12+
# curl -L static.rust-lang.org/dist/channel-rust-${PV}.toml 2>/dev/null | grep "xz_url.*rust-src"
13+
MY_SRC_URI="${RUST_TOOLCHAIN_BASEURL%/}/2023-08-03/rust-src-${PV}.tar.xz"
14+
GENTOO_BIN_BASEURI="https://dev.gentoo.org/~sam/distfiles/${CATEGORY}/${PN}" # omit leading slash
15+
16+
DESCRIPTION="Language empowering everyone to build reliable and efficient software"
17+
HOMEPAGE="https://www.rust-lang.org/"
18+
SRC_URI="$(rust_all_arch_uris ${MY_P})
19+
rust-src? ( ${MY_SRC_URI} )
20+
"
21+
# Keep this separate to allow easy commenting out if not yet built
22+
SRC_URI+=" sparc? ( ${GENTOO_BIN_BASEURI}/${MY_P}-sparc64-unknown-linux-gnu.tar.xz -> ${MY_P}-sparc64-unknown-linux-gnu.sam.tar.xz ) "
23+
24+
LICENSE="|| ( MIT Apache-2.0 ) BSD BSD-1 BSD-2 BSD-4 UoI-NCSA"
25+
SLOT="${PV}"
26+
KEYWORDS="amd64 arm arm64 ~loong ~mips ppc ppc64 ~riscv ~s390 sparc x86"
27+
IUSE="big-endian clippy cpu_flags_x86_sse2 doc prefix rust-analyzer rust-src rustfmt"
28+
29+
RDEPEND="
30+
>=app-eselect/eselect-rust-20190311
31+
dev-libs/openssl
32+
sys-apps/lsb-release
33+
sys-devel/gcc:*
34+
!dev-lang/rust:stable
35+
!dev-lang/rust-bin:stable
36+
"
37+
BDEPEND="
38+
prefix? ( dev-util/patchelf )
39+
verify-sig? ( sec-keys/openpgp-keys-rust )
40+
"
41+
42+
REQUIRED_USE="x86? ( cpu_flags_x86_sse2 )"
43+
44+
# stripping rust may break it (at least on x86_64)
45+
# https://github.com/rust-lang/rust/issues/112286
46+
RESTRICT="strip"
47+
48+
QA_PREBUILT="
49+
opt/${P}/bin/.*
50+
opt/${P}/lib/.*.so
51+
opt/${P}/libexec/.*
52+
opt/${P}/lib/rustlib/.*/bin/.*
53+
opt/${P}/lib/rustlib/.*/lib/.*
54+
"
55+
56+
# An rmeta file is custom binary format that contains the metadata for the crate.
57+
# rmeta files do not support linking, since they do not contain compiled object files.
58+
# so we can safely silence the warning for this QA check.
59+
QA_EXECSTACK="opt/${P}/lib/rustlib/*/lib*.rlib:lib.rmeta"
60+
61+
VERIFY_SIG_OPENPGP_KEY_PATH="/usr/share/openpgp-keys/rust.asc"
62+
63+
pkg_pretend() {
64+
if [[ "$(tc-is-softfloat)" != "no" ]] && [[ ${CHOST} == armv7* ]]; then
65+
die "${CHOST} is not supported by upstream Rust. You must use a hard float version."
66+
fi
67+
}
68+
69+
src_unpack() {
70+
# sadly rust-src tarball does not have corresponding .asc file
71+
# so do partial verification
72+
if use verify-sig; then
73+
for f in ${A}; do
74+
if [[ -f ${DISTDIR}/${f}.asc ]]; then
75+
verify-sig_verify_detached "${DISTDIR}/${f}" "${DISTDIR}/${f}.asc"
76+
fi
77+
done
78+
fi
79+
80+
default_src_unpack
81+
82+
mv "${WORKDIR}/${MY_P}-$(rust_abi)" "${S}" || die
83+
}
84+
85+
patchelf_for_bin() {
86+
local filetype=$(file -b ${1})
87+
if [[ ${filetype} == *ELF*interpreter* ]]; then
88+
einfo "${1}'s interpreter changed"
89+
patchelf ${1} --set-interpreter ${2} || die
90+
elif [[ ${filetype} == *script* ]]; then
91+
hprefixify ${1}
92+
fi
93+
}
94+
95+
multilib_src_install() {
96+
if multilib_is_native_abi; then
97+
98+
# start native abi install
99+
pushd "${S}" >/dev/null || die
100+
local analysis std
101+
analysis="$(grep 'analysis' ./components)"
102+
std="$(grep 'std' ./components)"
103+
local components="rustc,cargo,${std}"
104+
use doc && components="${components},rust-docs"
105+
use clippy && components="${components},clippy-preview"
106+
use rustfmt && components="${components},rustfmt-preview"
107+
use rust-analyzer && components="${components},rust-analyzer-preview,${analysis}"
108+
# Rust component 'rust-src' is extracted from separate archive
109+
if use rust-src; then
110+
einfo "Combining rust and rust-src installers"
111+
mv -v "${WORKDIR}/rust-src-${PV}/rust-src" "${S}" || die
112+
echo rust-src >> ./components || die
113+
components="${components},rust-src"
114+
fi
115+
./install.sh \
116+
--components="${components}" \
117+
--disable-verify \
118+
--prefix="${ED}/opt/${P}" \
119+
--mandir="${ED}/opt/${P}/man" \
120+
--disable-ldconfig \
121+
|| die
122+
123+
if use prefix; then
124+
local interpreter=$(patchelf --print-interpreter "${EPREFIX}/bin/bash")
125+
ebegin "Changing interpreter to ${interpreter} for Gentoo prefix at ${ED}/opt/${P}/bin"
126+
find "${ED}/opt/${P}/bin" -type f -print0 | \
127+
while IFS= read -r -d '' filename; do
128+
patchelf_for_bin ${filename} ${interpreter} \; || die
129+
done
130+
eend $?
131+
fi
132+
133+
local symlinks=(
134+
cargo
135+
rustc
136+
rustdoc
137+
rust-gdb
138+
rust-gdbgui
139+
rust-lldb
140+
)
141+
142+
use clippy && symlinks+=( clippy-driver cargo-clippy )
143+
use rustfmt && symlinks+=( rustfmt cargo-fmt )
144+
use rust-analyzer && symlinks+=( rust-analyzer )
145+
146+
einfo "installing eselect-rust symlinks and paths"
147+
local i
148+
for i in "${symlinks[@]}"; do
149+
# we need realpath on /usr/bin/* symlink return version-appended binary path.
150+
# so /usr/bin/rustc should point to /opt/rust-bin-<ver>/bin/rustc-<ver>
151+
local ver_i="${i}-bin-${PV}"
152+
ln -v "${ED}/opt/${P}/bin/${i}" "${ED}/opt/${P}/bin/${ver_i}" || die
153+
dosym "../../opt/${P}/bin/${ver_i}" "/usr/bin/${ver_i}"
154+
done
155+
156+
# symlinks to switch components to active rust in eselect
157+
dosym "../../../opt/${P}/lib" "/usr/lib/rust/lib-bin-${PV}"
158+
dosym "../../../opt/${P}/man" "/usr/lib/rust/man-bin-${PV}"
159+
dosym "../../opt/${P}/lib/rustlib" "/usr/lib/rustlib-bin-${PV}"
160+
dosym "../../../opt/${P}/share/doc/rust" "/usr/share/doc/${P}"
161+
162+
# make all capital underscored variable
163+
local CARGO_TRIPLET="$(rust_abi)"
164+
CARGO_TRIPLET="${CARGO_TRIPLET//-/_}"
165+
CARGO_TRIPLET="${CARGO_TRIPLET^^}"
166+
cat <<-_EOF_ > "${T}/50${P}"
167+
LDPATH="${EPREFIX}/usr/lib/rust/lib-bin-${PV}"
168+
MANPATH="${EPREFIX}/usr/lib/rust/man-bin-${PV}"
169+
$(usev elibc_musl "CARGO_TARGET_${CARGO_TRIPLET}_RUSTFLAGS=\"-C target-feature=-crt-static\"")
170+
_EOF_
171+
doenvd "${T}/50${P}"
172+
173+
# note: eselect-rust adds EROOT to all paths below
174+
cat <<-_EOF_ > "${T}/provider-${P}"
175+
/usr/bin/cargo
176+
/usr/bin/rustdoc
177+
/usr/bin/rust-gdb
178+
/usr/bin/rust-gdbgui
179+
/usr/bin/rust-lldb
180+
/usr/lib/rustlib
181+
/usr/lib/rust/lib
182+
/usr/lib/rust/man
183+
/usr/share/doc/rust
184+
_EOF_
185+
186+
if use clippy; then
187+
echo /usr/bin/clippy-driver >> "${T}/provider-${P}"
188+
echo /usr/bin/cargo-clippy >> "${T}/provider-${P}"
189+
fi
190+
if use rustfmt; then
191+
echo /usr/bin/rustfmt >> "${T}/provider-${P}"
192+
echo /usr/bin/cargo-fmt >> "${T}/provider-${P}"
193+
fi
194+
if use rust-analyzer; then
195+
echo /usr/bin/rust-analyzer >> "${T}/provider-${P}"
196+
fi
197+
198+
insinto /etc/env.d/rust
199+
doins "${T}/provider-${P}"
200+
popd >/dev/null || die
201+
#end native abi install
202+
203+
else
204+
local rust_target
205+
rust_target="$(rust_abi $(get_abi_CHOST ${v##*.}))"
206+
dodir "/opt/${P}/lib/rustlib"
207+
cp -vr "${WORKDIR}/rust-${PV}-${rust_target}/rust-std-${rust_target}/lib/rustlib/${rust_target}"\
208+
"${ED}/opt/${P}/lib/rustlib" || die
209+
fi
210+
211+
# BUG: installs x86_64 binary on other arches
212+
rm -f "${ED}/opt/${P}/lib/rustlib/"*/bin/rust-llvm-dwp || die
213+
}
214+
215+
pkg_postinst() {
216+
eselect rust update
217+
218+
if has_version dev-debug/gdb || has_version dev-debug/lldb; then
219+
elog "Rust installs helper scripts for calling GDB and LLDB,"
220+
elog "for convenience they are installed under /usr/bin/rust-{gdb,lldb}-${PV}."
221+
fi
222+
223+
if has_version app-editors/emacs; then
224+
elog "install app-emacs/rust-mode to get emacs support for rust."
225+
fi
226+
227+
if has_version app-editors/gvim || has_version app-editors/vim; then
228+
elog "install app-vim/rust-vim to get vim support for rust."
229+
fi
230+
}
231+
232+
pkg_postrm() {
233+
eselect rust cleanup
234+
}

0 commit comments

Comments
 (0)