blob: 6b0b2709f9936bea1073bff23c4c788ec3f57fee [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
Alan Green9b7a93d2021-03-11 14:24:52 +110032# We completely overwrite any existing PATH. This ensures that we're not getting
33# things from unexpected places.
Alan Green397c9342021-05-06 07:11:48 +100034PATH="/usr/sbin:/usr/bin:/sbin:/bin"
Dan Callaghan96bfde92021-09-07 03:44:54 +000035PATH="${HPS_ROOT}/third_party/gn/out:${PATH}"
Alan Green54b38e72021-08-20 14:01:45 +100036PATH="${HPS_ROOT}/third_party/installed/bin:${PATH}"
37PATH="${RUST_DIR}:${PATH}"
38PATH="${HOSTPATH}:${PATH}"
Dan Callaghanf1261f22022-05-27 15:01:52 +100039PATH="/opt/hps-sdk/bin:${PATH}"
Alan Green967106d2022-01-24 09:01:19 +110040PATH="${HPS_ROOT}/scripts:${PATH}"
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 Green1a92e5c2022-01-13 16:25:17 +110054# For chromite
55PYTHONPATH="${HPS_ROOT}/../../.."
56# For pylint_quotes and other packages
57PYTHONPATH="${PYTHONPATH}:${HPS_ROOT}/../../../chromite/third_party"
Alan Green8c7d34b2021-05-05 15:12:54 +100058PYTHONPATH="${PYTHONPATH}:${HPS_ROOT}/python"
Alan Green9b7a93d2021-03-11 14:24:52 +110059for i in "${HPS_ROOT}/third_party/python"/*; do
60 PYTHONPATH="${PYTHONPATH}:${i}"
61done
62export PYTHONPATH
63
Alan Green397c9342021-05-06 07:11:48 +100064# List of directories with Rust source
65export HPS_RUST_DIRS=(
David Lattimore28a33812021-11-17 09:26:31 +110066 rust
David Lattimore417ea752021-11-17 10:26:52 +110067 rust/factory_tester
68 rust/mcu
David Lattimore28a33812021-11-17 09:26:31 +110069 rust/riscv
David Lattimored544c7b2021-04-07 08:36:34 +100070)
Alan Greene3b7a592022-01-17 10:08:46 +110071
72# Finds "non standard" llvm-objcopy. This is used outside the chroot and
73# finds the objcopy installed by scripts/setup
74if which llvm-objcopy-13 > /dev/null; then
Alan Green40944482022-01-27 06:42:48 +110075 export OBJCOPY=llvm-objcopy-13
Alan Greene3b7a592022-01-17 10:08:46 +110076fi