blob: 4741a28dfb83737d38057913e10756dc37524c2b [file] [log] [blame]
Alan Green9b7a93d2021-03-11 14:24:52 +11001#!/bin/bash
2
Alan Green7c5639e2021-05-05 17:10:41 +10003# Copyright 2021 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
Alan Green9b7a93d2021-03-11 14:24:52 +11007if [ "${BASH_SOURCE-}" = "$0" ]; then
8 echo -e "This script should be sourced, not run:\nsource $0" >&2
9 exit 1
10fi
11
12# Exports environment variables needed by parts of this project.
13
14# The following environment variables should already be set to appropriate
15# values:
16# RADIANT_DIR (e.g. $HOME/lscc/radiant/2.2/bin/lin64)
17#
18# If RADIANT_DIR isn't set, then only simulation can be used.
19
Alan Green397c9342021-05-06 07:11:48 +100020HPS_ROOT=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
Alan Green9b7a93d2021-03-11 14:24:52 +110021
22RUSTC="$(which rustc)"
23# handle the case where rustc is not yet installed
Alan Green397c9342021-05-06 07:11:48 +100024if [ -z "${RUSTC}" ]; then
Alan Green9b7a93d2021-03-11 14:24:52 +110025 echo "rustc not found"
26 RUST_DIR=""
27else
28 RUST_DIR=$(dirname "${RUSTC}")
29fi
Alan Green397c9342021-05-06 07:11:48 +100030export HOSTPATH="${HPS_ROOT}/build/host"
Alan Green9b7a93d2021-03-11 14:24:52 +110031
David Lattimore420174f2021-05-25 11:16:34 +100032export RUST_VERSION=stable
Alan Green9b7a93d2021-03-11 14:24:52 +110033
34# We completely overwrite any existing PATH. This ensures that we're not getting
35# things from unexpected places.
Alan Green397c9342021-05-06 07:11:48 +100036PATH="/usr/sbin:/usr/bin:/sbin:/bin"
Dan Callaghan207e2b22021-08-12 17:45:02 +100037PATH="${PATH}:${HPS_ROOT}/third_party/gn/out"
38PATH="${PATH}:${HPS_ROOT}/third_party/installed/bin"
39PATH="${PATH}:${RUST_DIR}"
40PATH="${PATH}:${HOSTPATH}"
Alan Green397c9342021-05-06 07:11:48 +100041export PATH
Alan Green9b7a93d2021-03-11 14:24:52 +110042
Alan Green397c9342021-05-06 07:11:48 +100043# RADIANT_DIR is optionally defined
44if [ -d "${RADIANT_DIR:-}" ]; then
45 export PATH="${PATH}:${RADIANT_DIR}"
Alan Green9b7a93d2021-03-11 14:24:52 +110046fi
47
48# This speeds up recompilation of verilator generated code quit a bit.
49export OBJCACHE=ccache
50export CC="ccache gcc"
51
52# We deliberately clear anything that may have already been in PYTHONPATH to
53# prevent accidentally pulling in anything outside this project.
Alan Green8c7d34b2021-05-05 15:12:54 +100054PYTHONPATH="${HPS_ROOT}/../../.." # For chromite
55PYTHONPATH="${PYTHONPATH}:${HPS_ROOT}/python"
Alan Green9b7a93d2021-03-11 14:24:52 +110056for i in "${HPS_ROOT}/third_party/python"/*; do
57 PYTHONPATH="${PYTHONPATH}:${i}"
58done
59export PYTHONPATH
60
61# Explicitly set the RISCV toolchain path.
Alan Green397c9342021-05-06 07:11:48 +100062USER_BIN_DIR=$(realpath ~)/bin
63export USER_BIN_DIR
64RISCV_VER=riscv64-unknown-elf-gcc-8.3.0-2020.04.1-x86_64-linux-ubuntu14
65export RISCV_DIR="${USER_BIN_DIR}/${RISCV_VER}/bin"
66export PATH="${RISCV_DIR}:${PATH}"
David Lattimored544c7b2021-04-07 08:36:34 +100067
Alan Green397c9342021-05-06 07:11:48 +100068# List of directories with Rust source
69export HPS_RUST_DIRS=(
David Lattimore5c8f1fe2021-04-22 15:53:04 +100070 mcu_rom
David Lattimore941f6b42021-04-26 15:53:01 +100071 mcu_rom/stm32g0_application
David Lattimored544c7b2021-04-07 08:36:34 +100072 mcu_rom/stage0
73 mcu_rom/stage1
David Lattimoredaf78592021-04-14 17:17:41 +100074 mcu_rom/stm32g0_i2c_peripheral
David Lattimored544c7b2021-04-07 08:36:34 +100075)