blob: 2106d941bc97f68339bdbf9a4a353b3c375431cb [file] [log] [blame]
Mike Frysinger51a0a6b2022-09-09 09:21:07 -04001# Copyright 2022 The ChromiumOS Authors
George Burgess IV2961b6f2022-03-30 00:08:04 -07002# Distributed under the terms of the GNU General Public License v2
3
4EAPI=7
5
Bob Haarmanb5128bf2022-04-11 11:27:38 -07006# shellcheck disable=SC2034 # Used by cros-rustc.eclass
George Burgess IV2961b6f2022-03-30 00:08:04 -07007RUSTC_TARGET_TRIPLES=(
8 x86_64-pc-linux-gnu
9)
Bob Haarmanb5128bf2022-04-11 11:27:38 -070010# shellcheck disable=SC2034 # Used by cros-rustc.eclass
George Burgess IV2961b6f2022-03-30 00:08:04 -070011RUSTC_BARE_TARGET_TRIPLES=()
12
Bob Haarmanb5128bf2022-04-11 11:27:38 -070013# shellcheck disable=SC2034
14PYTHON_COMPAT=( python3_{6..9} )
George Burgess IV2961b6f2022-03-30 00:08:04 -070015inherit cros-rustc
16
George Burgess IV2961b6f2022-03-30 00:08:04 -070017KEYWORDS="*"
18
Michael Benfielde2e2bed2022-08-13 17:49:04 +000019BDEPEND="sys-devel/llvm"
Bob Haarmanb5128bf2022-04-11 11:27:38 -070020# dev-lang/rust-1.59.0 introduced the split between dev-lang/rust and
George Burgess IV2961b6f2022-03-30 00:08:04 -070021# dev-lang/rust-host; note that here to work around file collisions.
Bob Haarmanb5128bf2022-04-11 11:27:38 -070022RDEPEND="!<dev-lang/rust-1.59.0"
George Burgess IV2961b6f2022-03-30 00:08:04 -070023
24src_install() {
Bob Haarmanb5128bf2022-04-11 11:27:38 -070025 # shellcheck disable=SC2154 # defined in cros-rustc.eclass
George Burgess IV2961b6f2022-03-30 00:08:04 -070026 local obj="${CROS_RUSTC_BUILD_DIR}/x86_64-unknown-linux-gnu/stage2"
27 local tools="${obj}-tools/x86_64-unknown-linux-gnu/release/"
28 dobin "${obj}/bin/rustc" "${obj}/bin/rustdoc"
29 dobin "${tools}/cargo"
Michael Benfieldab6a03d2022-05-26 18:29:30 +000030 if ! use rust_profile_frontend_generate && ! use rust_profile_llvm_generate; then
31 # These won't be built for an instrumented build.
32 dobin "${tools}/rustfmt" "${tools}/cargo-fmt"
33 dobin "${tools}/clippy-driver" "${tools}/cargo-clippy"
34 fi
George Burgess IV2961b6f2022-03-30 00:08:04 -070035 dobin src/etc/rust-gdb src/etc/rust-lldb
36 insinto "/usr/$(get_libdir)"
37 doins -r "${obj}/lib/"*
38 doins -r "${obj}/lib64/"*
39
Bob Haarmanb5128bf2022-04-11 11:27:38 -070040 insinto "/usr/lib/rustlib/src/rust/"
41 doins -r "${S}/library"
42
George Burgess IV2961b6f2022-03-30 00:08:04 -070043 # Install miscellaneous LLVM tools.
44 #
45 # These tools are already provided in the SDK, but they're built with
46 # the version of LLVM built by sys-devel/llvm. Rust uses an independent
47 # version of LLVM, so the use of these tools is sometimes necessary to
48 # produce artifacts that work with `rustc` and such.
49 #
50 # Our long-term plan is to have Rust using the same version of LLVM as
51 # sys-devel/llvm. When that happens, all of the below will be removed, with
52 # the expectation that users will migrate to the LLVM tools on `$PATH`.
53 local llvm_tools="${CROS_RUSTC_BUILD_DIR}/x86_64-unknown-linux-gnu/llvm/bin"
54 exeinto "/usr/libexec/rust"
55 doexe "${llvm_tools}/llvm-profdata"
56}