Daniel Verkamp | d6c4428 | 2019-03-21 10:38:30 -0700 | [diff] [blame] | 1 | # Copyright 1999-2018 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | |
Bob Haarman | 5c2443f | 2020-10-20 19:47:27 +0000 | [diff] [blame] | 4 | EAPI=7 |
Daniel Verkamp | d6c4428 | 2019-03-21 10:38:30 -0700 | [diff] [blame] | 5 | |
George Burgess IV | f364716 | 2021-08-01 09:36:04 +0000 | [diff] [blame] | 6 | # 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 Haarman | b5128bf | 2022-04-11 11:27:38 -0700 | [diff] [blame] | 10 | # shellcheck disable=SC2034 # Used by cros-rustc.eclass |
Daniel Verkamp | d6c4428 | 2019-03-21 10:38:30 -0700 | [diff] [blame] | 11 | RUSTC_TARGET_TRIPLES=( |
Daniel Verkamp | d6c4428 | 2019-03-21 10:38:30 -0700 | [diff] [blame] | 12 | x86_64-cros-linux-gnu |
| 13 | armv7a-cros-linux-gnueabihf |
| 14 | aarch64-cros-linux-gnu |
| 15 | ) |
| 16 | |
George Burgess IV | 2961b6f | 2022-03-30 00:08:04 -0700 | [diff] [blame] | 17 | # In this context BARE means the OS part of the triple is none and gcc is used |
| 18 | # for C/C++ and linking. |
Bob Haarman | b5128bf | 2022-04-11 11:27:38 -0700 | [diff] [blame] | 19 | # shellcheck disable=SC2034 # Used by cros-rustc.eclass |
Zach Reizner | 68bdbad | 2019-09-27 16:54:23 -0700 | [diff] [blame] | 20 | RUSTC_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 Haarman | b5128bf | 2022-04-11 11:27:38 -0700 | [diff] [blame] | 26 | # shellcheck disable=SC2034 |
| 27 | PYTHON_COMPAT=( python3_{6..9} ) |
George Burgess IV | 2961b6f | 2022-03-30 00:08:04 -0700 | [diff] [blame] | 28 | |
Bob Haarman | b5128bf | 2022-04-11 11:27:38 -0700 | [diff] [blame] | 29 | inherit cros-rustc |
George Burgess IV | 2961b6f | 2022-03-30 00:08:04 -0700 | [diff] [blame] | 30 | |
| 31 | # Use PVR to require simultaneous uprevs of both rust-host and rust, since |
| 32 | # they're logically talking about the same sources. |
Bob Haarman | b5128bf | 2022-04-11 11:27:38 -0700 | [diff] [blame] | 33 | BDEPEND="=dev-lang/rust-host-${PVR}" |
| 34 | RDEPEND="=dev-lang/rust-host-${PVR}" |
George Burgess IV | 2961b6f | 2022-03-30 00:08:04 -0700 | [diff] [blame] | 35 | KEYWORDS="*" |
| 36 | |
| 37 | # NOTE: since CROS_RUSTC_BUILD_DIR is a local cache, the cases below can't |
| 38 | # always presume that it exists. |
| 39 | |
| 40 | src_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 Verkamp | d6c4428 | 2019-03-21 10:38:30 -0700 | [diff] [blame] | 47 | fi |
| 48 | } |
| 49 | |
| 50 | src_prepare() { |
George Burgess IV | 2961b6f | 2022-03-30 00:08:04 -0700 | [diff] [blame] | 51 | 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 Verkamp | d6c4428 | 2019-03-21 10:38:30 -0700 | [diff] [blame] | 58 | fi |
Daniel Verkamp | d6c4428 | 2019-03-21 10:38:30 -0700 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | src_compile() { |
George Burgess IV | 2961b6f | 2022-03-30 00:08:04 -0700 | [diff] [blame] | 62 | 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 Verkamp | d6c4428 | 2019-03-21 10:38:30 -0700 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | src_install() { |
Bob Haarman | b5128bf | 2022-04-11 11:27:38 -0700 | [diff] [blame] | 71 | # shellcheck disable=SC2154 # Defined in cros-rustc.eclass |
George Burgess IV | 2961b6f | 2022-03-30 00:08:04 -0700 | [diff] [blame] | 72 | local obj="${CROS_RUSTC_BUILD_DIR}/x86_64-unknown-linux-gnu/stage2" |
George Burgess IV | 2961b6f | 2022-03-30 00:08:04 -0700 | [diff] [blame] | 73 | 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 Verkamp | d6c4428 | 2019-03-21 10:38:30 -0700 | [diff] [blame] | 77 | } |