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 |
| 26 | |
| 27 | |
| 28 | # We completely overwrite any existing PATH. This ensures that we're not getting |
| 29 | # things from unexpected places. |
| 30 | export PATH=/usr/sbin:/usr/bin:/sbin:/bin:$HPS_ROOT/third_party/gn/out:$RUST_DIR |
| 31 | |
| 32 | if [ -a "$RADIANT_DIR" ]; then |
| 33 | export PATH=$PATH:$RADIANT_DIR |
| 34 | fi |
| 35 | |
| 36 | # This speeds up recompilation of verilator generated code quit a bit. |
| 37 | export OBJCACHE=ccache |
| 38 | export CC="ccache gcc" |
| 39 | |
| 40 | # We deliberately clear anything that may have already been in PYTHONPATH to |
| 41 | # prevent accidentally pulling in anything outside this project. |
| 42 | PYTHONPATH="${HPS_ROOT}/python" |
| 43 | for i in "${HPS_ROOT}/third_party/python"/*; do |
| 44 | PYTHONPATH="${PYTHONPATH}:${i}" |
| 45 | done |
| 46 | export PYTHONPATH |
| 47 | |
| 48 | # Explicitly set the RISCV toolchain path. |
| 49 | export USER_BIN_DIR=$(realpath ~)/bin |
| 50 | export RISCV_DIR=${USER_BIN_DIR}/riscv64-unknown-elf-gcc-8.3.0-2020.04.1-x86_64-linux-ubuntu14/bin |
| 51 | export PATH=${RISCV_DIR}:$PATH |