-
Notifications
You must be signed in to change notification settings - Fork 0
/
environment
39 lines (34 loc) · 1.18 KB
/
environment
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# Exports environment variables needed by parts of this project.
# PYTHONPATH
# PATH
if [ "${BASH_SOURCE-}" = "$0" ]; then
echo -e "This script should be sourced, not run:\nsource $0" >&2
exit 1
fi
# Using ccache speeds up verilator simulation when not much has changed.
if which ccache >/dev/null; then
export OBJCACHE="ccache"
export CC="ccache gcc"
fi
CFU_ROOT=$(dirname $(realpath ${BASH_SOURCE[0]}))
# We deliberately clear anything that may have already been in PYTHONPATH to
# prevent accidentally pulling in anything outside this project.
PYTHONPATH="${CFU_ROOT}/python:${CFU_ROOT}/soc/board_specific_workflows"
for i in "${CFU_ROOT}/third_party/python/"*; do
# Avoid adding files such as README.md to our path
# - ValentyUsb is special-cased: it has a src/ directory
# that is *not* for Python
if [ -d "$i/src" ] && [[ "$i" != *"valentyusb"* ]]; then
PYTHONPATH="${PYTHONPATH}:${i}/src"
elif [ -d "$i" ]; then
PYTHONPATH="${PYTHONPATH}:${i}"
fi
done
export PYTHONPATH
pathadd() {
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
export PATH="${1}${PATH:+":$PATH"}"
fi
}
pathadd "${CFU_ROOT}/scripts"