Cleanup setup scripts and ensure they don't kill your shell

This commit is contained in:
Jordan Carlin 2025-04-30 20:01:13 -07:00
parent 0dfd106ce5
commit 5437606914
No known key found for this signature in database
2 changed files with 43 additions and 35 deletions

View file

@ -2,6 +2,7 @@
# setup.sh
# David_Harris@hmc.edu and kekim@hmc.edu 1 December 2021
# jcarlin@hmc.edu 2025
# Set up tools for cvw
# optionally have .bashrc or .bash_profile source this file with
@ -11,6 +12,11 @@
# SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1
# Colors for terminal output
WARNING_COLOR='\033[93m'
FAIL_COLOR='\033[91m'
ENDC='\033[0m' # Reset to default color
echo "Executing Wally setup.sh"
# Path to RISC-V Tools
@ -21,14 +27,15 @@ elif [ -d ~/riscv ]; then
else
# set the $RISCV directory here and remove the subsequent two lines
# export RISCV=
echo "\$RISCV directory not found. Checked /opt/riscv and ~/riscv. Edit setup.sh to point to your custom \$RISCV directory."
exit 1
echo -e "${FAIL_COLOR}\$RISCV directory not found. Checked /opt/riscv and ~/riscv. Edit setup.sh to point to your custom \$RISCV directory.${ENDC}"
return 1
fi
echo \$RISCV set to "${RISCV}"
# Path to Wally repository
WALLY=$(dirname "${BASH_SOURCE[0]:-$0}")
export WALLY=$(cd "$WALLY" && pwd)
WALLY=$(cd "$WALLY" && pwd)
export WALLY
echo \$WALLY set to "${WALLY}"
# utility functions in Wally repository
export PATH=$WALLY/bin:$PATH
@ -37,7 +44,7 @@ export PATH=$WALLY/bin:$PATH
if [ -e "${WALLY}"/addins/cvw-arch-verif/setup.sh ]; then
source "${WALLY}"/addins/cvw-arch-verif/setup.sh
else
echo "setup.sh not found in \$WALLY/addins/cvw-arch-verif directory. Make sure you cloned the submodules."
echo -e "${WARNING_COLOR}setup.sh not found in \$WALLY/addins/cvw-arch-verif directory. Make sure you cloned the submodules.${ENDC}"
fi
# Verilator needs a larger core file size to simulate CORE-V Wally
@ -47,15 +54,15 @@ ulimit -c 300000
if [ -e "${RISCV}"/site-setup.sh ]; then
source "${RISCV}"/site-setup.sh
else
echo "site-setup.sh not found in \$RISCV directory. Rerun wally-toolchain-install.sh to automatically download it."
exit 1
echo -e "${ERROR_COLOR}site-setup.sh not found in \$RISCV directory. Rerun wally-toolchain-install.sh to automatically download it.${ENDC}"
return 1
fi
if [ ! -e "${WALLY}/.git/hooks/pre-commit" ]; then
pushd "${WALLY}" || exit 1
pushd "${WALLY}" || return 1
echo "Installing pre-commit hooks"
pre-commit install
popd || exit
popd || return
fi
echo "setup done"

View file

@ -2,20 +2,27 @@
# site-setup.sh
# David_Harris@hmc.edu and kekim@hmc.edu 1 December 2021
# jcarlin@hmc.edu 2025
# System Admin should install this into $RISCV/site-setup.sh
# $RISCV is typically /opt/riscv
# It is automatically placed in the $RISCV directory by wally-toolchain-install.sh
# $RISCV is typically /opt/riscv or ~/riscv
# System Admin must update the licenses and paths for localization.
# SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1
# Colors for terminal output
FAIL_COLOR='\033[91m'
ENDC='\033[0m' # Reset to default color
# license servers and commercial CAD tool paths
# Must edit these based on your local environment.
export MGLS_LICENSE_FILE=27002@zircon.eng.hmc.edu # Change this to your Siemens license server for Questa
export SNPSLMD_LICENSE_FILE=27020@zircon.eng.hmc.edu # Change this to your Synopsys license server
export IMPERASD_LICENSE_FILE=27020@zircon.eng.hmc.edu # Change this to your Imperas license server
export QUESTA_HOME=/cad/mentor/questa_sim-2023.4/questasim # Change this for your path to Questa, excluding bin
export BREKER_LICENSE_FILE=1819@zircon.eng.hmc.edu # Change this to your Breker license server
export QUESTA_HOME=/cad/mentor/QUESTA # Change this for your path to Questa, excluding bin
export DC_HOME=/cad/synopsys/SYN # Change this for your path to Synopsys DC, excluding bin
export VCS_HOME=/cad/synopsys/vcs/U-2023.03-SP2-4 # Change this for your path to Synopsys VCS, excluding bin
export BREKER_HOME=/cad/breker/trek5-2.1.11-GCC6_el7 # Change this for your path to Breker Trek
export VCS_HOME=/cad/synopsys/VCS # Change this for your path to Synopsys VCS, excluding bin
export BREKER_HOME=/cad/breker/TREK # Change this for your path to Breker Trek
# Tools
# Questa and Synopsys
@ -31,10 +38,6 @@ export SYN_MW=/home/jstine/MW
export SYN_memory=/home/jstine/WallyMem/rv64gc/
#export osumemory=/import/yukari1/pdk/TSMC/WallyMem/rv64gc/
# Environmental variables for CTG (https://github.com/riscv-software-src/riscv-ctg)
export RISCVCTG=/home/harris/repos/riscv-ctg
# GCC
if [ -z "$LD_LIBRARY_PATH" ]; then
export LD_LIBRARY_PATH=$RISCV/riscv64-unknown-elf/lib
@ -50,36 +53,34 @@ export PATH=$PATH:$RISCV/bin
if [ -e "$RISCV"/riscv-python/bin/activate ]; then
source "$RISCV"/riscv-python/bin/activate
else
echo "Python virtual environment not found. Rerun wally-toolchain-install.sh to automatically create it."
exit 1
echo -e "${FAIL_COLOR}Python virtual environment not found. Rerun wally-toolchain-install.sh to automatically create it.${ENDC}"
return 1
fi
# Environment variables needed for RISCV-DV
export RISCV_GCC=$(which riscv64-unknown-elf-gcc) # Copy this as it is
export RISCV_OBJCOPY=$(which riscv64-unknown-elf-objcopy) # Copy this as it is
export SPIKE_PATH=$RISCV/bin # Copy this as it is
# Imperas OVPsim; put this in if you are using it
#export PATH=$RISCV/imperas-riscv-tests/riscv-ovpsim-plus/bin/Linux64:$PATH
#export LD_LIBRARY_PATH=$RISCV/imperas_riscv_tests/riscv-ovpsim-plus/bin/Linux64:$LD_LIBRARY_PATH
export RISCV_GCC=$(which riscv64-unknown-elf-gcc)
export RISCV_OBJCOPY=$(which riscv64-unknown-elf-objcopy)
export SPIKE_PATH=$RISCV/bin
# Imperas DV setup
export IDV=$RISCV/ImperasDV-OpenHW
if [ -e "$IDV" ]; then
# echo "Imperas exists"
export IMPERAS_HOME=$IDV
export IMPERAS_HOME=$RISCV/ImperasDV-OpenHW
if [ -e "$IMPERAS_HOME" ]; then
export IMPERAS_PERSONALITY=CPUMAN_DV_ASYNC
export ROOTDIR=~/
source "${IMPERAS_HOME}"/bin/setup.sh
setupImperas "${IMPERAS_HOME}"
export PATH=$IDV/scripts/cvw:$PATH
source "${IMPERAS_HOME}"/bin/setup.sh &> /dev/null || {
echo -e "${FAIL_COLOR}ImperasDV setup failed${ENDC}"
return 1
}
setupImperas "${IMPERAS_HOME}" &> /dev/null || {
echo -e "${FAIL_COLOR}setupImperas failed${ENDC}"
return 1
}
fi
# Use newer gcc version for older distros
if [ -e /opt/rh/gcc-toolset-13/enable ]; then
source /opt/rh/gcc-toolset-13/enable # Red Hat Family
elif [ -e $RISCV/gcc-13 ]; then
elif [ -e "$RISCV"/gcc-13 ]; then
export PATH=$RISCV/gcc-13/bin:$PATH # SUSE Family
elif [ -e $RISCV/gcc-10 ]; then
elif [ -e "$RISCV"/gcc-10 ]; then
export PATH=$RISCV/gcc-10/bin:$PATH # Ubuntu 20.04 LTS
fi