forked from firesim/FireMarshal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-setup.sh
executable file
·102 lines (83 loc) · 2.85 KB
/
build-setup.sh
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/env bash
# exit script if any command fails
set -e
set -o pipefail
RDIR=$(git rev-parse --show-toplevel)
usage() {
echo "Usage: ${0} [OPTIONS]"
echo ""
echo "Helper script to initialize repository that wraps other scripts."
echo "Sets up conda environment, initializes submodules, and installs toolchain collateral."
echo ""
echo "Options"
echo " --help -h : Display this message"
echo " --unpinned-deps -ud : Use unpinned conda environment"
echo " --clean : remove old conda environment"
echo " --skip-conda : Skip conda env creation"
echo " --skip-repositories : Skip building extra RISC-V toolchain collateral (Spike, PK, tests, libgloos)"
exit "$1"
}
USE_PINNED_DEPS=true
SKIP_CONDA=false
SKIP_REPOSITORIES=false
CLEAN=false
RISCV_TOOLS="$(dirname $(readlink -f $0))/../../.conda-env/riscv-tools"
if [ ! -e "${RISCV_TOOLS}" ]; then
echo "Chipyard/FireSim must be fully setup before FireMarshal!" >&2
exit 1
fi
RISCV_TOOLS=$(readlink -f "${RISCV_TOOLS}")
# getopts does not support long options, and is inflexible
while [ "$1" != "" ];
do
case $1 in
-h | --help )
usage 3 ;;
-ud | --unpinned-deps )
USE_PINNED_DEPS=false ;;
--skip-conda)
SKIP_CONDA=true ;;
--skip-repositories)
SKIP_REPOSITORIES=true ;;
--clean)
CLEAN=true ;;
* )
echo "invalid option $1" >&2
usage 1 ;;
esac
shift
done
if [ "$SKIP_CONDA" = false ]; then
# note: lock file must end in .conda-lock.yml - see https://github.com/conda-incubator/conda-lock/issues/154
CONDA_REQS=$RDIR/conda-reqs
if [ "$CLEAN" = "true" ]; then
rm -vRf $RDIR/.conda-env
fi
if [ "$USE_PINNED_DEPS" = false ]; then
conda-lock -f $CONDA_REQS/firemarshal.yaml --lockfile $CONDA_REQS/firemarshal.conda-lock.yml
fi
conda-lock install -p $RDIR/.conda-env $CONDA_REQS/firemarshal.conda-lock.yml
source $RDIR/.conda-env/etc/profile.d/conda.sh
conda activate $RDIR/.conda-env
fi
if [ "$SKIP_REPOSITORIES" = false ]; then
if [ "$CLEAN" = "true" ]; then
git submodule deinit --force --all
fi
git submodule update --init
fi
cat << EOT > env.sh
# file auto-generated by $0
export RISCV=${RISCV_TOOLS}
# Cleanup
conda deactivate
export PATH=\$(echo -n "\${PATH}" | tr ':' '\n' | grep -Fv '/.conda-env' | grep -Fv '/chipyard/bin' | tr '\n' ':' | head -c -1)
# Populate environment
conda activate ${RDIR}/.conda-env
export PATH="\${RISCV}/bin:\${PATH}"
# Safety checks
if [ \$(ulimit -n) -lt 2048 ]; then
echo "CRITICAL: your limits configuration does not allow to open more than \$(ulimit -n) files. This could cause certain builds to fail."
fi
echo "WARNING: Source the Chipyard/FireSim environment when done with FireMarhal!"
EOT