Alan Green | 9b7a93d | 2021-03-11 14:24:52 +1100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | if [ "${BASH_SOURCE-}" = "$0" ]; then |
| 4 | echo -e "This script should be sourced, not run:\nsource $0" >&2 |
| 5 | exit 1 |
| 6 | fi |
| 7 | |
| 8 | # Exports environment variables needed by parts of this project. |
| 9 | |
| 10 | # The following environment variables should already be set to appropriate |
| 11 | # values: |
| 12 | # RADIANT_DIR (e.g. $HOME/lscc/radiant/2.2/bin/lin64) |
| 13 | # |
| 14 | # If RADIANT_DIR isn't set, then only simulation can be used. |
| 15 | |
| 16 | HPS_ROOT=$(dirname $(realpath ${BASH_SOURCE[0]})) |
| 17 | |
| 18 | RUSTC="$(which rustc)" |
| 19 | # handle the case where rustc is not yet installed |
| 20 | if [ -z "$RUSTC" ]; then |
| 21 | echo "rustc not found" |
| 22 | RUST_DIR="" |
| 23 | else |
| 24 | RUST_DIR=$(dirname "${RUSTC}") |
| 25 | fi |
Andrew McRae | cc55b88 | 2021-04-15 10:27:39 +1000 | [diff] [blame^] | 26 | export HOSTPATH=${HPS_ROOT}/build/host |
Alan Green | 9b7a93d | 2021-03-11 14:24:52 +1100 | [diff] [blame] | 27 | |
David Lattimore | bcc2d84 | 2021-03-19 14:28:26 +1100 | [diff] [blame] | 28 | # Note, LLVM-12 was merged into rust on 2021-03-04. Debian doesn't yet have |
| 29 | # lld-12, so while we're using lld to link, we need to stick to rustc versions |
| 30 | # that use LLVM-11 |
| 31 | RUST_VERSION=nightly-2021-03-03 |
Alan Green | 9b7a93d | 2021-03-11 14:24:52 +1100 | [diff] [blame] | 32 | |
| 33 | # We completely overwrite any existing PATH. This ensures that we're not getting |
| 34 | # things from unexpected places. |
Andrew McRae | cc55b88 | 2021-04-15 10:27:39 +1000 | [diff] [blame^] | 35 | export PATH=/usr/sbin:/usr/bin:/sbin:/bin:$HPS_ROOT/third_party/gn/out:$RUST_DIR:$HOSTPATH |
Alan Green | 9b7a93d | 2021-03-11 14:24:52 +1100 | [diff] [blame] | 36 | |
| 37 | if [ -a "$RADIANT_DIR" ]; then |
| 38 | export PATH=$PATH:$RADIANT_DIR |
| 39 | fi |
| 40 | |
| 41 | # This speeds up recompilation of verilator generated code quit a bit. |
| 42 | export OBJCACHE=ccache |
| 43 | export CC="ccache gcc" |
| 44 | |
| 45 | # We deliberately clear anything that may have already been in PYTHONPATH to |
| 46 | # prevent accidentally pulling in anything outside this project. |
| 47 | PYTHONPATH="${HPS_ROOT}/python" |
| 48 | for i in "${HPS_ROOT}/third_party/python"/*; do |
| 49 | PYTHONPATH="${PYTHONPATH}:${i}" |
| 50 | done |
| 51 | export PYTHONPATH |
| 52 | |
| 53 | # Explicitly set the RISCV toolchain path. |
| 54 | export USER_BIN_DIR=$(realpath ~)/bin |
| 55 | export RISCV_DIR=${USER_BIN_DIR}/riscv64-unknown-elf-gcc-8.3.0-2020.04.1-x86_64-linux-ubuntu14/bin |
| 56 | export PATH=${RISCV_DIR}:$PATH |
David Lattimore | d544c7b | 2021-04-07 08:36:34 +1000 | [diff] [blame] | 57 | |
| 58 | HPS_RUST_DIRS=( |
| 59 | mcu_rom/application |
| 60 | mcu_rom/i2c_peripheral |
| 61 | mcu_rom/mcu_common |
| 62 | mcu_rom/stage0 |
| 63 | mcu_rom/stage1 |
| 64 | utils/hps-util |
| 65 | utils/sign-rom |
| 66 | ) |