blob: c49f9643396a95ab169e8dfc43091d09caa2ce11 [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
Andrew McRaecc55b882021-04-15 10:27:39 +100026export HOSTPATH=${HPS_ROOT}/build/host
Alan Green9b7a93d2021-03-11 14:24:52 +110027
David Lattimorebcc2d842021-03-19 14:28:26 +110028# 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
31RUST_VERSION=nightly-2021-03-03
Alan Green9b7a93d2021-03-11 14:24:52 +110032
33# We completely overwrite any existing PATH. This ensures that we're not getting
34# things from unexpected places.
Andrew McRaecc55b882021-04-15 10:27:39 +100035export PATH=/usr/sbin:/usr/bin:/sbin:/bin:$HPS_ROOT/third_party/gn/out:$RUST_DIR:$HOSTPATH
Alan Green9b7a93d2021-03-11 14:24:52 +110036
37if [ -a "$RADIANT_DIR" ]; then
38 export PATH=$PATH:$RADIANT_DIR
39fi
40
41# This speeds up recompilation of verilator generated code quit a bit.
42export OBJCACHE=ccache
43export 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.
47PYTHONPATH="${HPS_ROOT}/python"
48for i in "${HPS_ROOT}/third_party/python"/*; do
49 PYTHONPATH="${PYTHONPATH}:${i}"
50done
51export PYTHONPATH
52
53# Explicitly set the RISCV toolchain path.
54export USER_BIN_DIR=$(realpath ~)/bin
55export RISCV_DIR=${USER_BIN_DIR}/riscv64-unknown-elf-gcc-8.3.0-2020.04.1-x86_64-linux-ubuntu14/bin
56export PATH=${RISCV_DIR}:$PATH
David Lattimored544c7b2021-04-07 08:36:34 +100057
58HPS_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)