Merge pull request #1614 from JL102/script-trycatch

Added useful "Build script exited at step X" errors for each step in build-setup.sh
This commit is contained in:
Jerry Zhao
2023-10-09 09:30:11 -07:00
committed by GitHub

View File

@@ -109,8 +109,31 @@ if [ $TOOLCHAIN_TYPE == "esp-tools" ]; then
done
fi
#######################################
###### BEGIN STEP-BY-STEP SETUP #######
#######################################
# In order to run code on error, we must handle errors manually
set +e;
function begin_step
{
thisStepNum=$1;
thisStepDesc=$2;
echo " ========== BEGINNING STEP $thisStepNum: $thisStepDesc =========="
}
function exit_if_last_command_failed
{
local exitcode=$?;
if [ $exitcode -ne 0 ]; then
die "Build script failed with exit code $exitcode at step $thisStepNum: $thisStepDesc" $exitcode;
fi
}
# setup and install conda environment
if run_step "1"; then
begin_step "1" "Conda environment setup"
# note: lock file must end in .conda-lock.yml - see https://github.com/conda-incubator/conda-lock/issues/154
CONDA_REQS=$CYDIR/conda-reqs
CONDA_LOCK_REQS=$CONDA_REQS/conda-lock-reqs
@@ -120,13 +143,15 @@ if run_step "1"; then
if [ "$USE_UNPINNED_DEPS" = true ]; then
# auto-gen the lockfiles
$CYDIR/scripts/generate-conda-lockfiles.sh
exit_if_last_command_failed
fi
# use conda-lock to create env
conda-lock install --conda $(which conda) -p $CYDIR/.conda-env $LOCKFILE
conda-lock install --conda $(which conda) -p $CYDIR/.conda-env $LOCKFILE &&
source $CYDIR/.conda-env/etc/profile.d/conda.sh
source $CYDIR/.conda-env/etc/profile.d/conda.sh &&
conda activate $CYDIR/.conda-env
exit_if_last_command_failed
fi
if [ -z "$FORCE_FLAG" ]; then
@@ -138,11 +163,14 @@ fi
# initialize all submodules (without the toolchain submodules)
if run_step "2"; then
begin_step "2" "Initializing Chipyard submodules"
$CYDIR/scripts/init-submodules-no-riscv-tools.sh $FORCE_FLAG
exit_if_last_command_failed
fi
# build extra toolchain collateral (i.e. spike, pk, riscv-tests, libgloss)
if run_step "3"; then
begin_step "3" "Building toolchain collateral"
if run_step "1"; then
PREFIX=$CONDA_PREFIX/$TOOLCHAIN_TYPE
else
@@ -153,57 +181,73 @@ if run_step "3"; then
PREFIX=$RISCV
fi
$CYDIR/scripts/build-toolchain-extra.sh $TOOLCHAIN_TYPE -p $PREFIX
exit_if_last_command_failed
fi
# run ctags for code navigation
if run_step "4"; then
begin_step "4" "Running ctags for code navigation"
$CYDIR/scripts/gen-tags.sh
exit_if_last_command_failed
fi
# precompile chipyard scala sources
if run_step "5"; then
pushd $CYDIR/sims/verilator
make launch-sbt SBT_COMMAND=";project chipyard; compile"
make launch-sbt SBT_COMMAND=";project tapeout; compile"
begin_step "5" "Pre-compiling Chipyard Scala sources"
pushd $CYDIR/sims/verilator &&
make launch-sbt SBT_COMMAND=";project chipyard; compile" &&
make launch-sbt SBT_COMMAND=";project tapeout; compile" &&
popd
exit_if_last_command_failed
fi
# setup firesim
if run_step "6"; then
$CYDIR/scripts/firesim-setup.sh
begin_step "6" "Setting up FireSim"
$CYDIR/scripts/firesim-setup.sh &&
$CYDIR/sims/firesim/gen-tags.sh
exit_if_last_command_failed
# precompile firesim scala sources
if run_step "7"; then
pushd $CYDIR/sims/firesim
begin_step "7" "Pre-compiling Firesim Scala sources"
pushd $CYDIR/sims/firesim &&
(
set -e # Subshells un-set "set -e" so it must be re enabled
echo $CYDIR
source sourceme-manager.sh --skip-ssh-setup
pushd sim
make sbt SBT_COMMAND="project {file:$CYDIR}firechip; compile" TARGET_PROJECT=firesim
popd
)
exit_if_last_command_failed
popd
fi
fi
# setup firemarshal
if run_step "8"; then
pushd $CYDIR/software/firemarshal
begin_step "8" "Setting up FireMarshal"
pushd $CYDIR/software/firemarshal &&
./init-submodules.sh
exit_if_last_command_failed
# precompile firemarshal buildroot sources
if run_step "9"; then
source $CYDIR/scripts/fix-open-files.sh
./marshal $VERBOSE_FLAG build br-base.json
begin_step "9" "Pre-compiling FireMarshal buildroot sources"
source $CYDIR/scripts/fix-open-files.sh &&
./marshal $VERBOSE_FLAG build br-base.json &&
./marshal $VERBOSE_FLAG clean br-base.json
exit_if_last_command_failed
fi
popd
fi
# do misc. cleanup for a "clean" git status
if run_step "10"; then
begin_step "10" "Cleaning up repository"
$CYDIR/scripts/repo-clean.sh
exit_if_last_command_failed
fi
cat <<EOT >> env.sh