Alan Green | 9b7a93d | 2021-03-11 14:24:52 +1100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Alan Green | 7c5639e | 2021-05-05 17:10:41 +1000 | [diff] [blame] | 3 | # Copyright 2021 The Chromium OS Authors. All rights reserved. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | |
Alan Green | 9b7a93d | 2021-03-11 14:24:52 +1100 | [diff] [blame] | 7 | if [ "${BASH_SOURCE-}" = "$0" ]; then |
| 8 | echo -e "This script should be sourced, not run:\nsource $0" >&2 |
| 9 | exit 1 |
| 10 | fi |
| 11 | |
| 12 | # Exports environment variables needed by parts of this project. |
| 13 | |
| 14 | # The following environment variables should already be set to appropriate |
| 15 | # values: |
| 16 | # RADIANT_DIR (e.g. $HOME/lscc/radiant/2.2/bin/lin64) |
| 17 | # |
| 18 | # If RADIANT_DIR isn't set, then only simulation can be used. |
| 19 | |
Alan Green | 397c934 | 2021-05-06 07:11:48 +1000 | [diff] [blame] | 20 | HPS_ROOT=$(realpath "$(dirname "${BASH_SOURCE[0]}")") |
Alan Green | 9b7a93d | 2021-03-11 14:24:52 +1100 | [diff] [blame] | 21 | |
| 22 | RUSTC="$(which rustc)" |
| 23 | # handle the case where rustc is not yet installed |
Alan Green | 397c934 | 2021-05-06 07:11:48 +1000 | [diff] [blame] | 24 | if [ -z "${RUSTC}" ]; then |
Alan Green | 9b7a93d | 2021-03-11 14:24:52 +1100 | [diff] [blame] | 25 | echo "rustc not found" |
| 26 | RUST_DIR="" |
| 27 | else |
| 28 | RUST_DIR=$(dirname "${RUSTC}") |
| 29 | fi |
Alan Green | 397c934 | 2021-05-06 07:11:48 +1000 | [diff] [blame] | 30 | export HOSTPATH="${HPS_ROOT}/build/host" |
Alan Green | 9b7a93d | 2021-03-11 14:24:52 +1100 | [diff] [blame] | 31 | |
Dan Callaghan | f1183a1 | 2022-02-08 10:37:49 +1100 | [diff] [blame] | 32 | export RUST_VERSION=1.58.1 |
Alan Green | 9b7a93d | 2021-03-11 14:24:52 +1100 | [diff] [blame] | 33 | |
| 34 | # We completely overwrite any existing PATH. This ensures that we're not getting |
| 35 | # things from unexpected places. |
Alan Green | 397c934 | 2021-05-06 07:11:48 +1000 | [diff] [blame] | 36 | PATH="/usr/sbin:/usr/bin:/sbin:/bin" |
Dan Callaghan | 96bfde9 | 2021-09-07 03:44:54 +0000 | [diff] [blame] | 37 | PATH="${HPS_ROOT}/third_party/gn/out:${PATH}" |
Alan Green | 54b38e7 | 2021-08-20 14:01:45 +1000 | [diff] [blame] | 38 | PATH="${HPS_ROOT}/third_party/installed/bin:${PATH}" |
| 39 | PATH="${RUST_DIR}:${PATH}" |
| 40 | PATH="${HOSTPATH}:${PATH}" |
Alan Green | 967106d | 2022-01-24 09:01:19 +1100 | [diff] [blame] | 41 | PATH="${HPS_ROOT}/scripts:${PATH}" |
Alan Green | 397c934 | 2021-05-06 07:11:48 +1000 | [diff] [blame] | 42 | export PATH |
Alan Green | 9b7a93d | 2021-03-11 14:24:52 +1100 | [diff] [blame] | 43 | |
Alan Green | 397c934 | 2021-05-06 07:11:48 +1000 | [diff] [blame] | 44 | # RADIANT_DIR is optionally defined |
| 45 | if [ -d "${RADIANT_DIR:-}" ]; then |
| 46 | export PATH="${PATH}:${RADIANT_DIR}" |
Alan Green | 9b7a93d | 2021-03-11 14:24:52 +1100 | [diff] [blame] | 47 | fi |
| 48 | |
| 49 | # This speeds up recompilation of verilator generated code quit a bit. |
| 50 | export OBJCACHE=ccache |
| 51 | export CC="ccache gcc" |
| 52 | |
| 53 | # We deliberately clear anything that may have already been in PYTHONPATH to |
| 54 | # prevent accidentally pulling in anything outside this project. |
Alan Green | 1a92e5c | 2022-01-13 16:25:17 +1100 | [diff] [blame] | 55 | # For chromite |
| 56 | PYTHONPATH="${HPS_ROOT}/../../.." |
| 57 | # For pylint_quotes and other packages |
| 58 | PYTHONPATH="${PYTHONPATH}:${HPS_ROOT}/../../../chromite/third_party" |
Alan Green | 8c7d34b | 2021-05-05 15:12:54 +1000 | [diff] [blame] | 59 | PYTHONPATH="${PYTHONPATH}:${HPS_ROOT}/python" |
Alan Green | 9b7a93d | 2021-03-11 14:24:52 +1100 | [diff] [blame] | 60 | for i in "${HPS_ROOT}/third_party/python"/*; do |
| 61 | PYTHONPATH="${PYTHONPATH}:${i}" |
| 62 | done |
| 63 | export PYTHONPATH |
| 64 | |
Alan Green | 397c934 | 2021-05-06 07:11:48 +1000 | [diff] [blame] | 65 | # List of directories with Rust source |
| 66 | export HPS_RUST_DIRS=( |
David Lattimore | 28a3381 | 2021-11-17 09:26:31 +1100 | [diff] [blame] | 67 | rust |
David Lattimore | 417ea75 | 2021-11-17 10:26:52 +1100 | [diff] [blame] | 68 | rust/factory_tester |
| 69 | rust/mcu |
David Lattimore | 28a3381 | 2021-11-17 09:26:31 +1100 | [diff] [blame] | 70 | rust/riscv |
David Lattimore | d544c7b | 2021-04-07 08:36:34 +1000 | [diff] [blame] | 71 | ) |
Alan Green | e3b7a59 | 2022-01-17 10:08:46 +1100 | [diff] [blame] | 72 | |
| 73 | # Finds "non standard" llvm-objcopy. This is used outside the chroot and |
| 74 | # finds the objcopy installed by scripts/setup |
| 75 | if which llvm-objcopy-13 > /dev/null; then |
Alan Green | 4094448 | 2022-01-27 06:42:48 +1100 | [diff] [blame] | 76 | export OBJCOPY=llvm-objcopy-13 |
Alan Green | e3b7a59 | 2022-01-17 10:08:46 +1100 | [diff] [blame] | 77 | fi |