blob: a4640f21c46cc593689e4ad0e4c0520c6e03c7c2 [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
David Lattimorebcc2d842021-03-19 14:28:26 +110027# Note, LLVM-12 was merged into rust on 2021-03-04. Debian doesn't yet have
28# lld-12, so while we're using lld to link, we need to stick to rustc versions
29# that use LLVM-11
30RUST_VERSION=nightly-2021-03-03
Alan Green9b7a93d2021-03-11 14:24:52 +110031
32# We completely overwrite any existing PATH. This ensures that we're not getting
33# things from unexpected places.
34export PATH=/usr/sbin:/usr/bin:/sbin:/bin:$HPS_ROOT/third_party/gn/out:$RUST_DIR
35
36if [ -a "$RADIANT_DIR" ]; then
37 export PATH=$PATH:$RADIANT_DIR
38fi
39
40# This speeds up recompilation of verilator generated code quit a bit.
41export OBJCACHE=ccache
42export CC="ccache gcc"
43
44# We deliberately clear anything that may have already been in PYTHONPATH to
45# prevent accidentally pulling in anything outside this project.
46PYTHONPATH="${HPS_ROOT}/python"
47for i in "${HPS_ROOT}/third_party/python"/*; do
48 PYTHONPATH="${PYTHONPATH}:${i}"
49done
50export PYTHONPATH
51
52# Explicitly set the RISCV toolchain path.
53export USER_BIN_DIR=$(realpath ~)/bin
54export RISCV_DIR=${USER_BIN_DIR}/riscv64-unknown-elf-gcc-8.3.0-2020.04.1-x86_64-linux-ubuntu14/bin
55export PATH=${RISCV_DIR}:$PATH