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 |
Nicholas Bishop | a52c357 | 2022-08-03 13:41:29 -0400 | [diff] [blame] | 24 | |
| 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 Reizner | 68bdbad | 2019-09-27 16:54:23 -0700 | [diff] [blame] | 31 | ) |
| 32 | |
Bob Haarman | b5128bf | 2022-04-11 11:27:38 -0700 | [diff] [blame] | 33 | # shellcheck disable=SC2034 |
| 34 | PYTHON_COMPAT=( python3_{6..9} ) |
George Burgess IV | 2961b6f | 2022-03-30 00:08:04 -0700 | [diff] [blame] | 35 | |
Bob Haarman | b5128bf | 2022-04-11 11:27:38 -0700 | [diff] [blame] | 36 | inherit cros-rustc |
George Burgess IV | 2961b6f | 2022-03-30 00:08:04 -0700 | [diff] [blame] | 37 | |
| 38 | # Use PVR to require simultaneous uprevs of both rust-host and rust, since |
| 39 | # they're logically talking about the same sources. |
Michael Benfield | e2e2bed | 2022-08-13 17:49:04 +0000 | [diff] [blame] | 40 | BDEPEND="=dev-lang/rust-host-${PVR} sys-devel/llvm" |
Bob Haarman | b5128bf | 2022-04-11 11:27:38 -0700 | [diff] [blame] | 41 | RDEPEND="=dev-lang/rust-host-${PVR}" |
George Burgess IV | 2961b6f | 2022-03-30 00:08:04 -0700 | [diff] [blame] | 42 | KEYWORDS="*" |
| 43 | |
| 44 | # NOTE: since CROS_RUSTC_BUILD_DIR is a local cache, the cases below can't |
| 45 | # always presume that it exists. |
| 46 | |
| 47 | src_unpack() { |
George Burgess IV | 5ffe748 | 2022-06-22 17:24:31 -0700 | [diff] [blame] | 48 | if [[ -n "${CROS_RUSTC_BUILD_RAW_SOURCES}" ]]; then |
| 49 | if ! cros-rustc_has_existing_checkout; then |
| 50 | eerror "No existing checkout detected; build rust-host first." |
| 51 | die |
| 52 | fi |
| 53 | # Unpacking consists only of ensuring symlink validity in this |
| 54 | # case. |
| 55 | cros-rustc_src_unpack |
| 56 | elif cros-rustc_has_existing_checkout; then |
George Burgess IV | 2961b6f | 2022-03-30 00:08:04 -0700 | [diff] [blame] | 57 | einfo "Skipping unpack; checkout already exists" |
George Burgess IV | ddd0dc1 | 2022-09-24 12:38:13 -0700 | [diff] [blame] | 58 | cros-rustc_setup_portage_dirs |
George Burgess IV | 2961b6f | 2022-03-30 00:08:04 -0700 | [diff] [blame] | 59 | else |
| 60 | ewarn "No existing cros-rustc checkout found. Did you" \ |
| 61 | "remember to emerge dev-lang/rust-host?" |
| 62 | cros-rustc_src_unpack |
Daniel Verkamp | d6c4428 | 2019-03-21 10:38:30 -0700 | [diff] [blame] | 63 | fi |
| 64 | } |
| 65 | |
| 66 | src_prepare() { |
George Burgess IV | 2961b6f | 2022-03-30 00:08:04 -0700 | [diff] [blame] | 67 | if cros-rustc_has_existing_checkout; then |
| 68 | einfo "Skipping src_prepare; checkout already exists" |
| 69 | # `src_prepare` requires this to be called before exiting. The |
| 70 | # actual use of user patches with this ebuild is not supported. |
| 71 | eapply_user |
| 72 | else |
| 73 | cros-rustc_src_prepare |
Daniel Verkamp | d6c4428 | 2019-03-21 10:38:30 -0700 | [diff] [blame] | 74 | fi |
Daniel Verkamp | d6c4428 | 2019-03-21 10:38:30 -0700 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | src_compile() { |
George Burgess IV | 2961b6f | 2022-03-30 00:08:04 -0700 | [diff] [blame] | 78 | local keep_stages=() |
| 79 | if cros-rustc_has_existing_stage1_build; then |
| 80 | einfo "Stage1 build exists; instructing x.py to use it" |
| 81 | keep_stages=("--keep-stage=0" "--keep-stage=1") |
| 82 | fi |
Michael Benfield | 5fab1f2 | 2022-11-14 05:30:11 +0000 | [diff] [blame] | 83 | cros-rustc_src_compile "${keep_stages[@]}" library |
Daniel Verkamp | d6c4428 | 2019-03-21 10:38:30 -0700 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | src_install() { |
Bob Haarman | b5128bf | 2022-04-11 11:27:38 -0700 | [diff] [blame] | 87 | # shellcheck disable=SC2154 # Defined in cros-rustc.eclass |
George Burgess IV | 2961b6f | 2022-03-30 00:08:04 -0700 | [diff] [blame] | 88 | 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] | 89 | for triple in "${RUSTC_TARGET_TRIPLES[@]}" "${RUSTC_BARE_TARGET_TRIPLES[@]}"; do |
| 90 | insinto "/usr/$(get_libdir)/rustlib/${triple}" |
| 91 | doins -r "${obj}/lib64/rustlib/${triple}/"* |
| 92 | done |
Daniel Verkamp | d6c4428 | 2019-03-21 10:38:30 -0700 | [diff] [blame] | 93 | } |