blob: d3700bedb326cf54fafacbcc377ab6ff693dfebb [file] [log] [blame]
Alan Green9b7a93d2021-03-11 14:24:52 +11001#!/bin/bash
2
3if [ "${BASH_SOURCE-}" = "$0" ]; then
4 echo -e "This script should be sourced, not run:\nsource $0" >&2
5 exit 1
6fi
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
16HPS_ROOT=$(dirname $(realpath ${BASH_SOURCE[0]}))
17
18RUSTC="$(which rustc)"
19# handle the case where rustc is not yet installed
20if [ -z "$RUSTC" ]; then
21 echo "rustc not found"
22 RUST_DIR=""
23else
24 RUST_DIR=$(dirname "${RUSTC}")
25fi
26
27
28# We completely overwrite any existing PATH. This ensures that we're not getting
29# things from unexpected places.
30export PATH=/usr/sbin:/usr/bin:/sbin:/bin:$HPS_ROOT/third_party/gn/out:$RUST_DIR
31
32if [ -a "$RADIANT_DIR" ]; then
33 export PATH=$PATH:$RADIANT_DIR
34fi
35
36# This speeds up recompilation of verilator generated code quit a bit.
37export OBJCACHE=ccache
38export 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.
42PYTHONPATH="${HPS_ROOT}/python"
43for i in "${HPS_ROOT}/third_party/python"/*; do
44 PYTHONPATH="${PYTHONPATH}:${i}"
45done
46export PYTHONPATH
47
48# Explicitly set the RISCV toolchain path.
49export USER_BIN_DIR=$(realpath ~)/bin
50export RISCV_DIR=${USER_BIN_DIR}/riscv64-unknown-elf-gcc-8.3.0-2020.04.1-x86_64-linux-ubuntu14/bin
51export PATH=${RISCV_DIR}:$PATH