1 |
commit: 10c62b78362a3feecd71ab6ea474e848bc8a6950 |
2 |
Author: Dirkjan Ochtman <djc <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Jul 13 19:58:40 2018 +0000 |
4 |
Commit: Dirkjan Ochtman <djc <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Jul 13 20:06:54 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=10c62b78 |
7 |
|
8 |
dev-lang/rust: add USE flags to install cargo, rls and rustfmt |
9 |
|
10 |
Reduce verbosity of builds to get sane output. |
11 |
|
12 |
Package-Manager: Portage-2.3.40, Repoman-2.3.9 |
13 |
|
14 |
dev-lang/rust/metadata.xml | 3 + |
15 |
dev-lang/rust/rust-1.27.1-r1.ebuild | 261 ++++++++++++++++++++++++++++++++++++ |
16 |
2 files changed, 264 insertions(+) |
17 |
|
18 |
diff --git a/dev-lang/rust/metadata.xml b/dev-lang/rust/metadata.xml |
19 |
index c03ce153031..88d11733609 100644 |
20 |
--- a/dev-lang/rust/metadata.xml |
21 |
+++ b/dev-lang/rust/metadata.xml |
22 |
@@ -8,8 +8,11 @@ |
23 |
<use> |
24 |
<flag name="extended">Build and install rls, rustfmt and cargo |
25 |
alongside the compiler and stdlib</flag> |
26 |
+ <flag name="cargo">Install cargo component</flag> |
27 |
<flag name="jemalloc">Use <pkg>dev-libs/jemalloc</pkg> as the |
28 |
standard memory allocator</flag> |
29 |
+ <flag name="rls">Install rls component</flag> |
30 |
+ <flag name="rustfmt">Install rustfmt component</flag> |
31 |
<flag name="wasm">Build support for the wasm32-unknown-unknown |
32 |
target</flag> |
33 |
</use> |
34 |
|
35 |
diff --git a/dev-lang/rust/rust-1.27.1-r1.ebuild b/dev-lang/rust/rust-1.27.1-r1.ebuild |
36 |
new file mode 100644 |
37 |
index 00000000000..2ce91ade5ab |
38 |
--- /dev/null |
39 |
+++ b/dev-lang/rust/rust-1.27.1-r1.ebuild |
40 |
@@ -0,0 +1,261 @@ |
41 |
+# Copyright 1999-2018 Gentoo Foundation |
42 |
+# Distributed under the terms of the GNU General Public License v2 |
43 |
+ |
44 |
+EAPI=6 |
45 |
+ |
46 |
+PYTHON_COMPAT=( python2_7 python3_{5,6} pypy ) |
47 |
+ |
48 |
+inherit multiprocessing multilib-build python-any-r1 toolchain-funcs versionator |
49 |
+ |
50 |
+if [[ ${PV} = *beta* ]]; then |
51 |
+ betaver=${PV//*beta} |
52 |
+ BETA_SNAPSHOT="${betaver:0:4}-${betaver:4:2}-${betaver:6:2}" |
53 |
+ MY_P="rustc-beta" |
54 |
+ SLOT="beta/${PV}" |
55 |
+ SRC="${BETA_SNAPSHOT}/rustc-beta-src.tar.xz" |
56 |
+ KEYWORDS="" |
57 |
+else |
58 |
+ ABI_VER="$(get_version_component_range 1-2)" |
59 |
+ SLOT="stable/${ABI_VER}" |
60 |
+ MY_P="rustc-${PV}" |
61 |
+ SRC="${MY_P}-src.tar.xz" |
62 |
+ KEYWORDS="~amd64 ~arm64 ~x86" |
63 |
+fi |
64 |
+ |
65 |
+CHOST_amd64=x86_64-unknown-linux-gnu |
66 |
+CHOST_x86=i686-unknown-linux-gnu |
67 |
+CHOST_arm64=aarch64-unknown-linux-gnu |
68 |
+ |
69 |
+RUST_STAGE0_VERSION="1.$(($(get_version_component_range 2) - 1)).2" |
70 |
+RUST_STAGE0_amd64="rust-${RUST_STAGE0_VERSION}-${CHOST_amd64}" |
71 |
+RUST_STAGE0_x86="rust-${RUST_STAGE0_VERSION}-${CHOST_x86}" |
72 |
+RUST_STAGE0_arm64="rust-${RUST_STAGE0_VERSION}-${CHOST_arm64}" |
73 |
+ |
74 |
+# there is no cargo 0.28 tag, so use 0.27 |
75 |
+#CARGO_DEPEND_VERSION="0.$(($(version_get_comp 2) + 1)).0" |
76 |
+CARGO_DEPEND_VERSION="0.$(($(get_version_component_range 2))).0" |
77 |
+ |
78 |
+DESCRIPTION="Systems programming language from Mozilla" |
79 |
+HOMEPAGE="https://www.rust-lang.org/" |
80 |
+ |
81 |
+SRC_URI="https://static.rust-lang.org/dist/${SRC} -> rustc-${PV}-src.tar.xz |
82 |
+ amd64? ( https://static.rust-lang.org/dist/${RUST_STAGE0_amd64}.tar.xz ) |
83 |
+ x86? ( https://static.rust-lang.org/dist/${RUST_STAGE0_x86}.tar.xz ) |
84 |
+ arm64? ( https://static.rust-lang.org/dist/${RUST_STAGE0_arm64}.tar.xz ) |
85 |
+" |
86 |
+ |
87 |
+ALL_LLVM_TARGETS=( AArch64 AMDGPU ARM BPF Hexagon Lanai Mips MSP430 |
88 |
+ NVPTX PowerPC Sparc SystemZ X86 XCore ) |
89 |
+ALL_LLVM_TARGETS=( "${ALL_LLVM_TARGETS[@]/#/llvm_targets_}" ) |
90 |
+LLVM_TARGET_USEDEPS=${ALL_LLVM_TARGETS[@]/%/?} |
91 |
+ |
92 |
+LICENSE="|| ( MIT Apache-2.0 ) BSD-1 BSD-2 BSD-4 UoI-NCSA" |
93 |
+ |
94 |
+IUSE="cargo debug doc +jemalloc rls rustfmt wasm ${ALL_LLVM_TARGETS[*]}" |
95 |
+ |
96 |
+RDEPEND=">=app-eselect/eselect-rust-0.3_pre20150425 |
97 |
+ jemalloc? ( dev-libs/jemalloc )" |
98 |
+DEPEND="${RDEPEND} |
99 |
+ ${PYTHON_DEPS} |
100 |
+ || ( |
101 |
+ >=sys-devel/gcc-4.7 |
102 |
+ >=sys-devel/clang-3.5 |
103 |
+ ) |
104 |
+ cargo? ( !dev-util/cargo ) |
105 |
+ rustfmt? ( !dev-util/rustfmt ) |
106 |
+ dev-util/cmake |
107 |
+" |
108 |
+PDEPEND="!cargo? ( >=dev-util/cargo-${CARGO_DEPEND_VERSION} )" |
109 |
+ |
110 |
+REQUIRED_USE="|| ( ${ALL_LLVM_TARGETS[*]} )" |
111 |
+ |
112 |
+S="${WORKDIR}/${MY_P}-src" |
113 |
+ |
114 |
+toml_usex() { |
115 |
+ usex "$1" true false |
116 |
+} |
117 |
+ |
118 |
+src_prepare() { |
119 |
+ local rust_stage0_root="${WORKDIR}"/rust-stage0 |
120 |
+ |
121 |
+ local rust_stage0_name="RUST_STAGE0_${ARCH}" |
122 |
+ local rust_stage0="${!rust_stage0_name}" |
123 |
+ |
124 |
+ "${WORKDIR}/${rust_stage0}"/install.sh --disable-ldconfig --destdir="${rust_stage0_root}" --prefix=/ || die |
125 |
+ |
126 |
+ default |
127 |
+} |
128 |
+ |
129 |
+src_configure() { |
130 |
+ local rust_target="" rust_targets="" rust_target_name arch_cflags |
131 |
+ |
132 |
+ # Collect rust target names to compile standard libs for all ABIs. |
133 |
+ for v in $(multilib_get_enabled_abi_pairs); do |
134 |
+ rust_target_name="CHOST_${v##*.}" |
135 |
+ rust_targets="${rust_targets},\"${!rust_target_name}\"" |
136 |
+ done |
137 |
+ if use wasm; then |
138 |
+ rust_targets="${rust_targets},\"wasm32-unknown-unknown\"" |
139 |
+ fi |
140 |
+ rust_targets="${rust_targets#,}" |
141 |
+ |
142 |
+ local extended="false" tools="" |
143 |
+ if use cargo; then |
144 |
+ extended="true" |
145 |
+ tools="\"cargo\"," |
146 |
+ fi |
147 |
+ if use rls; then |
148 |
+ extended="true" |
149 |
+ tools="\"rls\",$tools" |
150 |
+ fi |
151 |
+ if use rustfmt; then |
152 |
+ extended="true" |
153 |
+ tools="\"rustfmt\",$tools" |
154 |
+ fi |
155 |
+ |
156 |
+ local rust_stage0_root="${WORKDIR}"/rust-stage0 |
157 |
+ |
158 |
+ rust_target_name="CHOST_${ARCH}" |
159 |
+ rust_target="${!rust_target_name}" |
160 |
+ |
161 |
+ cat <<- EOF > "${S}"/config.toml |
162 |
+ [llvm] |
163 |
+ optimize = $(toml_usex !debug) |
164 |
+ release-debuginfo = $(toml_usex debug) |
165 |
+ assertions = $(toml_usex debug) |
166 |
+ targets = "${LLVM_TARGETS// /;}" |
167 |
+ [build] |
168 |
+ build = "${rust_target}" |
169 |
+ host = ["${rust_target}"] |
170 |
+ target = [${rust_targets}] |
171 |
+ cargo = "${rust_stage0_root}/bin/cargo" |
172 |
+ rustc = "${rust_stage0_root}/bin/rustc" |
173 |
+ docs = $(toml_usex doc) |
174 |
+ submodules = false |
175 |
+ python = "${EPYTHON}" |
176 |
+ locked-deps = true |
177 |
+ vendor = true |
178 |
+ extended = ${extended} |
179 |
+ tools = [${tools}] |
180 |
+ [install] |
181 |
+ prefix = "${EPREFIX}/usr" |
182 |
+ libdir = "$(get_libdir)" |
183 |
+ docdir = "share/doc/${P}" |
184 |
+ mandir = "share/${P}/man" |
185 |
+ [rust] |
186 |
+ optimize = $(toml_usex !debug) |
187 |
+ debuginfo = $(toml_usex debug) |
188 |
+ debug-assertions = $(toml_usex debug) |
189 |
+ use-jemalloc = $(toml_usex jemalloc) |
190 |
+ default-linker = "$(tc-getCC)" |
191 |
+ rpath = false |
192 |
+ lld = $(toml_usex wasm) |
193 |
+ EOF |
194 |
+ |
195 |
+ for v in $(multilib_get_enabled_abi_pairs); do |
196 |
+ rust_target=$(get_abi_CHOST ${v##*.}) |
197 |
+ arch_cflags="$(get_abi_CFLAGS ${v##*.})" |
198 |
+ |
199 |
+ cat <<- EOF >> "${S}"/config.env |
200 |
+ CFLAGS_${rust_target}=${arch_cflags} |
201 |
+ EOF |
202 |
+ |
203 |
+ cat <<- EOF >> "${S}"/config.toml |
204 |
+ [target.${rust_target}] |
205 |
+ cc = "$(tc-getBUILD_CC)" |
206 |
+ cxx = "$(tc-getBUILD_CXX)" |
207 |
+ linker = "$(tc-getCC)" |
208 |
+ ar = "$(tc-getAR)" |
209 |
+ EOF |
210 |
+ done |
211 |
+ |
212 |
+ if use wasm; then |
213 |
+ cat <<- EOF >> "${S}"/config.toml |
214 |
+ [target.wasm32-unknown-unknown] |
215 |
+ linker = "lld" |
216 |
+ EOF |
217 |
+ fi |
218 |
+} |
219 |
+ |
220 |
+src_compile() { |
221 |
+ env $(cat "${S}"/config.env)\ |
222 |
+ ./x.py build --config="${S}"/config.toml -j$(makeopts_jobs) \ |
223 |
+ --exclude src/tools/miri || die # https://github.com/rust-lang/rust/issues/52305 |
224 |
+} |
225 |
+ |
226 |
+src_install() { |
227 |
+ local rust_target abi_libdir |
228 |
+ |
229 |
+ env DESTDIR="${D}" ./x.py install || die |
230 |
+ |
231 |
+ mv "${D}/usr/bin/rustc" "${D}/usr/bin/rustc-${PV}" || die |
232 |
+ mv "${D}/usr/bin/rustdoc" "${D}/usr/bin/rustdoc-${PV}" || die |
233 |
+ mv "${D}/usr/bin/rust-gdb" "${D}/usr/bin/rust-gdb-${PV}" || die |
234 |
+ mv "${D}/usr/bin/rust-lldb" "${D}/usr/bin/rust-lldb-${PV}" || die |
235 |
+ if use cargo; then |
236 |
+ mv "${D}/usr/bin/cargo" "${D}/usr/bin/cargo-${PV}" || die |
237 |
+ fi |
238 |
+ if use rls; then |
239 |
+ mv "${D}/usr/bin/rls" "${D}/usr/bin/rls-${PV}" || die |
240 |
+ fi |
241 |
+ if use rustfmt; then |
242 |
+ mv "${D}/usr/bin/rustfmt" "${D}/usr/bin/rustfmt-${PV}" || die |
243 |
+ mv "${D}/usr/bin/cargo-fmt" "${D}/usr/bin/cargo-fmt-${PV}" || die |
244 |
+ fi |
245 |
+ |
246 |
+ # Copy shared library versions of standard libraries for all targets |
247 |
+ # into the system's abi-dependent lib directories because the rust |
248 |
+ # installer only does so for the native ABI. |
249 |
+ for v in $(multilib_get_enabled_abi_pairs); do |
250 |
+ if [ ${v##*.} = ${DEFAULT_ABI} ]; then |
251 |
+ continue |
252 |
+ fi |
253 |
+ abi_libdir=$(get_abi_LIBDIR ${v##*.}) |
254 |
+ rust_target=$(get_abi_CHOST ${v##*.}) |
255 |
+ mkdir -p "${D}/usr/${abi_libdir}" |
256 |
+ cp "${D}/usr/$(get_libdir)/rustlib/${rust_target}/lib"/*.so \ |
257 |
+ "${D}/usr/${abi_libdir}" || die |
258 |
+ done |
259 |
+ |
260 |
+ dodoc COPYRIGHT |
261 |
+ |
262 |
+ # FIXME: |
263 |
+ # Really not sure if that env is needed, specailly LDPATH |
264 |
+ cat <<-EOF > "${T}"/50${P} |
265 |
+ LDPATH="/usr/$(get_libdir)/${P}" |
266 |
+ MANPATH="/usr/share/${P}/man" |
267 |
+ EOF |
268 |
+ doenvd "${T}"/50${P} |
269 |
+ |
270 |
+ cat <<-EOF > "${T}/provider-${P}" |
271 |
+ /usr/bin/rustdoc |
272 |
+ /usr/bin/rust-gdb |
273 |
+ /usr/bin/rust-lldb |
274 |
+ EOF |
275 |
+ dodir /etc/env.d/rust |
276 |
+ insinto /etc/env.d/rust |
277 |
+ doins "${T}/provider-${P}" |
278 |
+} |
279 |
+ |
280 |
+pkg_postinst() { |
281 |
+ eselect rust update --if-unset |
282 |
+ |
283 |
+ elog "Rust installs a helper script for calling GDB and LLDB," |
284 |
+ elog "for your convenience it is installed under /usr/bin/rust-{gdb,lldb}-${PV}." |
285 |
+ |
286 |
+ if has_version app-editors/emacs || has_version app-editors/emacs-vcs; then |
287 |
+ elog "install app-emacs/rust-mode to get emacs support for rust." |
288 |
+ fi |
289 |
+ |
290 |
+ if has_version app-editors/gvim || has_version app-editors/vim; then |
291 |
+ elog "install app-vim/rust-vim to get vim support for rust." |
292 |
+ fi |
293 |
+ |
294 |
+ if has_version 'app-shells/zsh'; then |
295 |
+ elog "install app-shells/rust-zshcomp to get zsh completion for rust." |
296 |
+ fi |
297 |
+} |
298 |
+ |
299 |
+pkg_postrm() { |
300 |
+ eselect rust unset --if-invalid |
301 |
+} |