blob: 92c685af0929b7e07fa5636c0eb504b570660b09 [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"
Michael Benfield5fab1f22022-11-14 05:30:11 +000027 local tools="${obj}-tools/x86_64-unknown-linux-gnu/release"
28 dobin "${obj}/bin/rustc"
Michael Benfieldb6b20332022-09-15 23:54:36 +000029 dobin "${tools}/cargo" "${obj}/bin/rust-toolchain-version"
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"
Michael Benfield5fab1f22022-11-14 05:30:11 +000034 dobin "${obj}/bin/rustdoc"
Michael Benfieldab6a03d2022-05-26 18:29:30 +000035 fi
George Burgess IV2961b6f2022-03-30 00:08:04 -070036 dobin src/etc/rust-gdb src/etc/rust-lldb
37 insinto "/usr/$(get_libdir)"
38 doins -r "${obj}/lib/"*
39 doins -r "${obj}/lib64/"*
40
Bob Haarmanb5128bf2022-04-11 11:27:38 -070041 insinto "/usr/lib/rustlib/src/rust/"
42 doins -r "${S}/library"
43
George Burgess IV2961b6f2022-03-30 00:08:04 -070044 # Install miscellaneous LLVM tools.
45 #
46 # These tools are already provided in the SDK, but they're built with
47 # the version of LLVM built by sys-devel/llvm. Rust uses an independent
48 # version of LLVM, so the use of these tools is sometimes necessary to
49 # produce artifacts that work with `rustc` and such.
50 #
51 # Our long-term plan is to have Rust using the same version of LLVM as
52 # sys-devel/llvm. When that happens, all of the below will be removed, with
53 # the expectation that users will migrate to the LLVM tools on `$PATH`.
54 local llvm_tools="${CROS_RUSTC_BUILD_DIR}/x86_64-unknown-linux-gnu/llvm/bin"
55 exeinto "/usr/libexec/rust"
56 doexe "${llvm_tools}/llvm-profdata"
57}