blob: 58d083931d018927e6c3d0b9037bc870fd998ca8 [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
24)
25
Bob Haarmanb5128bf2022-04-11 11:27:38 -070026# shellcheck disable=SC2034
27PYTHON_COMPAT=( python3_{6..9} )
George Burgess IV2961b6f2022-03-30 00:08:04 -070028
Bob Haarmanb5128bf2022-04-11 11:27:38 -070029inherit cros-rustc
George Burgess IV2961b6f2022-03-30 00:08:04 -070030
31# Use PVR to require simultaneous uprevs of both rust-host and rust, since
32# they're logically talking about the same sources.
Bob Haarmanb5128bf2022-04-11 11:27:38 -070033BDEPEND="=dev-lang/rust-host-${PVR}"
34RDEPEND="=dev-lang/rust-host-${PVR}"
George Burgess IV2961b6f2022-03-30 00:08:04 -070035KEYWORDS="*"
36
37# NOTE: since CROS_RUSTC_BUILD_DIR is a local cache, the cases below can't
38# always presume that it exists.
39
40src_unpack() {
41 if cros-rustc_has_existing_checkout; then
42 einfo "Skipping unpack; checkout already exists"
43 else
44 ewarn "No existing cros-rustc checkout found. Did you" \
45 "remember to emerge dev-lang/rust-host?"
46 cros-rustc_src_unpack
Daniel Verkampd6c44282019-03-21 10:38:30 -070047 fi
48}
49
50src_prepare() {
George Burgess IV2961b6f2022-03-30 00:08:04 -070051 if cros-rustc_has_existing_checkout; then
52 einfo "Skipping src_prepare; checkout already exists"
53 # `src_prepare` requires this to be called before exiting. The
54 # actual use of user patches with this ebuild is not supported.
55 eapply_user
56 else
57 cros-rustc_src_prepare
Daniel Verkampd6c44282019-03-21 10:38:30 -070058 fi
Daniel Verkampd6c44282019-03-21 10:38:30 -070059}
60
61src_compile() {
George Burgess IV2961b6f2022-03-30 00:08:04 -070062 local keep_stages=()
63 if cros-rustc_has_existing_stage1_build; then
64 einfo "Stage1 build exists; instructing x.py to use it"
65 keep_stages=("--keep-stage=0" "--keep-stage=1")
66 fi
67 cros-rustc_src_compile "${keep_stages[@]}" library/std
Daniel Verkampd6c44282019-03-21 10:38:30 -070068}
69
70src_install() {
Bob Haarmanb5128bf2022-04-11 11:27:38 -070071 # shellcheck disable=SC2154 # Defined in cros-rustc.eclass
George Burgess IV2961b6f2022-03-30 00:08:04 -070072 local obj="${CROS_RUSTC_BUILD_DIR}/x86_64-unknown-linux-gnu/stage2"
George Burgess IV2961b6f2022-03-30 00:08:04 -070073 for triple in "${RUSTC_TARGET_TRIPLES[@]}" "${RUSTC_BARE_TARGET_TRIPLES[@]}"; do
74 insinto "/usr/$(get_libdir)/rustlib/${triple}"
75 doins -r "${obj}/lib64/rustlib/${triple}/"*
76 done
Daniel Verkampd6c44282019-03-21 10:38:30 -070077}