blob: df7fb915aad74a7d81466e932a1d435d4847b3b2 [file] [log] [blame]
Daniel Verkampd6c44282019-03-21 10:38:30 -07001# Copyright 1999-2018 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2
3
Bob Haarman5c2443f2020-10-20 19:47:27 +00004EAPI=7
Daniel Verkampd6c44282019-03-21 10:38:30 -07005
George Burgess IVf3647162021-08-01 09:36:04 +00006# This is the list of target triples as they appear in the cros_sdk. If this
7# list gets changed, ensure that each of these values has a corresponding
8# compiler/rustc_target/src/spec file created below and a line referring to it
9# in 0001-add-cros-targets.patch.
Bob Haarmanb5128bf2022-04-11 11:27:38 -070010# shellcheck disable=SC2034 # Used by cros-rustc.eclass
Daniel Verkampd6c44282019-03-21 10:38:30 -070011RUSTC_TARGET_TRIPLES=(
Daniel Verkampd6c44282019-03-21 10:38:30 -070012 x86_64-cros-linux-gnu
13 armv7a-cros-linux-gnueabihf
14 aarch64-cros-linux-gnu
15)
16
George Burgess IV2961b6f2022-03-30 00:08:04 -070017# In this context BARE means the OS part of the triple is none and gcc is used
18# for C/C++ and linking.
Bob Haarmanb5128bf2022-04-11 11:27:38 -070019# shellcheck disable=SC2034 # Used by cros-rustc.eclass
Zach Reizner68bdbad2019-09-27 16:54:23 -070020RUSTC_BARE_TARGET_TRIPLES=(
21 thumbv6m-none-eabi # Cortex-M0, M0+, M1
22 thumbv7m-none-eabi # Cortex-M3
23 thumbv7em-none-eabihf # Cortex-M4F, M7F, FPU, hardfloat
Nicholas Bishopa52c3572022-08-03 13:41:29 -040024
25 # These UEFI targets are used by and supported for ChromeOS flex;
26 # contact chromeos-flex-eng@google.com with any questions. Please
27 # add chromeos-toolchain@google.com if you would like to use any of
28 # these triples for your project.
29 i686-unknown-uefi
30 x86_64-unknown-uefi
Zach Reizner68bdbad2019-09-27 16:54:23 -070031)
32
Bob Haarmanb5128bf2022-04-11 11:27:38 -070033# shellcheck disable=SC2034
34PYTHON_COMPAT=( python3_{6..9} )
George Burgess IV2961b6f2022-03-30 00:08:04 -070035
Bob Haarmanb5128bf2022-04-11 11:27:38 -070036inherit cros-rustc
George Burgess IV2961b6f2022-03-30 00:08:04 -070037
38# Use PVR to require simultaneous uprevs of both rust-host and rust, since
39# they're logically talking about the same sources.
Bob Haarmanb5128bf2022-04-11 11:27:38 -070040BDEPEND="=dev-lang/rust-host-${PVR}"
41RDEPEND="=dev-lang/rust-host-${PVR}"
George Burgess IV2961b6f2022-03-30 00:08:04 -070042KEYWORDS="*"
43
44# NOTE: since CROS_RUSTC_BUILD_DIR is a local cache, the cases below can't
45# always presume that it exists.
46
47src_unpack() {
48 if cros-rustc_has_existing_checkout; then
49 einfo "Skipping unpack; checkout already exists"
50 else
51 ewarn "No existing cros-rustc checkout found. Did you" \
52 "remember to emerge dev-lang/rust-host?"
53 cros-rustc_src_unpack
Daniel Verkampd6c44282019-03-21 10:38:30 -070054 fi
55}
56
57src_prepare() {
George Burgess IV2961b6f2022-03-30 00:08:04 -070058 if cros-rustc_has_existing_checkout; then
59 einfo "Skipping src_prepare; checkout already exists"
60 # `src_prepare` requires this to be called before exiting. The
61 # actual use of user patches with this ebuild is not supported.
62 eapply_user
63 else
64 cros-rustc_src_prepare
Daniel Verkampd6c44282019-03-21 10:38:30 -070065 fi
Daniel Verkampd6c44282019-03-21 10:38:30 -070066}
67
68src_compile() {
George Burgess IV2961b6f2022-03-30 00:08:04 -070069 local keep_stages=()
70 if cros-rustc_has_existing_stage1_build; then
71 einfo "Stage1 build exists; instructing x.py to use it"
72 keep_stages=("--keep-stage=0" "--keep-stage=1")
73 fi
74 cros-rustc_src_compile "${keep_stages[@]}" library/std
Daniel Verkampd6c44282019-03-21 10:38:30 -070075}
76
77src_install() {
Bob Haarmanb5128bf2022-04-11 11:27:38 -070078 # shellcheck disable=SC2154 # Defined in cros-rustc.eclass
George Burgess IV2961b6f2022-03-30 00:08:04 -070079 local obj="${CROS_RUSTC_BUILD_DIR}/x86_64-unknown-linux-gnu/stage2"
George Burgess IV2961b6f2022-03-30 00:08:04 -070080 for triple in "${RUSTC_TARGET_TRIPLES[@]}" "${RUSTC_BARE_TARGET_TRIPLES[@]}"; do
81 insinto "/usr/$(get_libdir)/rustlib/${triple}"
82 doins -r "${obj}/lib64/rustlib/${triple}/"*
83 done
Daniel Verkampd6c44282019-03-21 10:38:30 -070084}