blob: 5941885965da4725fba8213cc0873f90dbcea0a2 [file] [log] [blame]
#!/bin/bash
# Copyright 2021 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
if [ "${BASH_SOURCE-}" = "$0" ]; then
echo -e "This script should be sourced, not run:\nsource $0" >&2
exit 1
fi
# Exports environment variables needed by parts of this project.
# The following environment variables should already be set to appropriate
# values:
# RADIANT_DIR (e.g. $HOME/lscc/radiant/2.2/bin/lin64)
#
# If RADIANT_DIR isn't set, then only simulation can be used.
HPS_ROOT=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
RUSTC="$(which rustc)"
# handle the case where rustc is not yet installed
if [ -z "${RUSTC}" ]; then
echo "rustc not found"
RUST_DIR=""
else
RUST_DIR=$(dirname "${RUSTC}")
fi
export HOSTPATH="${HPS_ROOT}/build/host"
export RUST_VERSION=1.58.1
# Nightly is only used for running our tests with MIRI. None of our code
# actually needs nightly.
export RUST_NIGHTLY_VERSION=nightly-2022-01-20
# We completely overwrite any existing PATH. This ensures that we're not getting
# things from unexpected places.
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
PATH="${HPS_ROOT}/third_party/gn/out:${PATH}"
PATH="${HPS_ROOT}/third_party/installed/bin:${PATH}"
PATH="${RUST_DIR}:${PATH}"
PATH="${HOSTPATH}:${PATH}"
PATH="${HPS_ROOT}/scripts:${PATH}"
export PATH
# RADIANT_DIR is optionally defined
if [ -d "${RADIANT_DIR:-}" ]; then
export PATH="${PATH}:${RADIANT_DIR}"
fi
# This speeds up recompilation of verilator generated code quit a bit.
export OBJCACHE=ccache
export CC="ccache gcc"
# We deliberately clear anything that may have already been in PYTHONPATH to
# prevent accidentally pulling in anything outside this project.
# For chromite
PYTHONPATH="${HPS_ROOT}/../../.."
# For pylint_quotes and other packages
PYTHONPATH="${PYTHONPATH}:${HPS_ROOT}/../../../chromite/third_party"
PYTHONPATH="${PYTHONPATH}:${HPS_ROOT}/python"
for i in "${HPS_ROOT}/third_party/python"/*; do
PYTHONPATH="${PYTHONPATH}:${i}"
done
export PYTHONPATH
# List of directories with Rust source
export HPS_RUST_DIRS=(
rust
rust/factory_tester
rust/mcu
rust/riscv
)
# Finds "non standard" llvm-objcopy. This is used outside the chroot and
# finds the objcopy installed by scripts/setup
if which llvm-objcopy-13 > /dev/null; then
export OBJCOPY=llvm-objcopy-13
fi