Misc. updates to bash scripts

This commit is contained in:
Abraham Gonzalez
2022-09-21 22:45:13 -07:00
parent 85f16d3342
commit c5447b168c
5 changed files with 136 additions and 100 deletions

View File

@@ -4,27 +4,34 @@
set -e
set -o pipefail
SKIP_VALIDATE=false
RDIR=$(git rev-parse --show-toplevel)
# get helpful utilities
source $RDIR/scripts/utils.sh
common_setup
function usage
{
echo "Usage: $0 [--skip-validate]"
echo "Usage: $0 [--batch]"
echo "Initialize Chipyard submodules and setup initial env.sh script."
echo ""
echo " --skip-validate Skip prompt checking for tagged release"
echo " --batch Skip prompt checking for tagged release"
}
BATCH=false
while test $# -gt 0
do
case "$1" in
--skip-validate)
SKIP_VALIDATE=true;
--batch)
BATCH=true;
;;
-h | -H | --help)
-h | -H | --help | help)
usage
exit 1
;;
*) echo "ERROR: bad argument $1"
*)
echo "ERROR: bad argument $1"
usage
exit 2
;;
@@ -32,47 +39,36 @@ do
shift
done
# Check that git version is at least 1.7.8
MYGIT=$(git --version)
MYGIT=${MYGIT#'git version '} # Strip prefix
case ${MYGIT} in
[1-9]*) ;;
*) echo 'warning: unknown git version' ;;
esac
MINGIT="1.8.5"
if [ "$MINGIT" != "$(echo -e "$MINGIT\n$MYGIT" | sort -V | head -n1)" ]; then
echo "This script requires git version $MINGIT or greater. Exiting."
false
fi
# before doing anything verify that you are on a release branch/tag
save_bash_options
set +e
tag=$(git describe --exact-match --tags)
tag_ret_code=$?
set -e
if [ $tag_ret_code -ne 0 ]; then
if [ "$SKIP_VALIDATE" = false ]; then
read -p "WARNING: You are not on an official release of Chipyard."$'\n'"Type \"y\" to continue if this is intended, otherwise see https://chipyard.readthedocs.io/en/stable/Chipyard-Basics/Initial-Repo-Setup.html#setting-up-the-chipyard-repo: " validate
[[ $validate == [yY] ]] || exit 3
echo "Setting up non-official Chipyard release"
git_tag=$(git describe --exact-match --tags)
git_tag_rc=$?
restore_bash_options
if [ "$git_tag_rc" -ne 0 ]; then
if [ "$BATCH" == false ]; then
while true; do
read -p "WARNING: You are not on an official release of Chipyard."$'\n'"Type \"y\" to continue if this is intended or \"n\" if not: " validate
case "$validate" in
y | Y)
echo "Continuing on to setting up non-official Chipyard release repository"
break
;;
n | N)
error "See https://chipyard.readthedocs.io/en/stable/Chipyard-Basics/Initial-Repo-Setup.html#setting-up-the-chipyard-repo for setting up an official release of Chipyard. "
exit 3
;;
*)
error "Invalid response. Please type \"y\" or \"n\""
;;
esac
done
fi
else
echo "Setting up official Chipyard release: $tag"
echo "Setting up official Chipyard release: $git_tag"
fi
# On macOS, use GNU readlink from 'coreutils' package in Homebrew/MacPorts
if [ "$(uname -s)" = "Darwin" ] ; then
READLINK=greadlink
else
READLINK=readlink
fi
# If BASH_SOURCE is undefined we may be running under zsh, in that case
# provide a zsh-compatible alternative
DIR="$(dirname "$($READLINK -f "${BASH_SOURCE[0]:-${(%):-%x}}")")"
CHIPYARD_DIR="$(dirname "$DIR")"
cd "$CHIPYARD_DIR"
cd "$RDIR"
(
# Blocklist of submodules to initially skip:
@@ -106,29 +102,28 @@ cd "$CHIPYARD_DIR"
_unskip() { git config --local --unset-all "submodule.${1}.update" || : ; }
trap 'git_submodule_exclude _unskip' EXIT INT TERM
set -x
git_submodule_exclude _skip
git submodule update --init --recursive #--jobs 8
set +x
(
set -x
git_submodule_exclude _skip
git submodule update --init --recursive #--jobs 8
)
)
set -x
(
# Non-recursive clone to exclude riscv-linux
git submodule update --init generators/sha3
# Non-recursive clone to exclude riscv-linux
git submodule update --init generators/sha3
# Non-recursive clone to exclude gemmini-software
git submodule update --init generators/gemmini
git -C generators/gemmini/ submodule update --init --recursive software/gemmini-rocc-tests
# Non-recursive clone to exclude gemmini-software
git submodule update --init generators/gemmini
git -C generators/gemmini/ submodule update --init --recursive software/gemmini-rocc-tests
# Minimal non-recursive clone to initialize sbt dependencies
git submodule update --init sims/firesim
git config --local submodule.sims/firesim.update none
# Minimal non-recursive clone to initialize sbt dependencies
git submodule update --init sims/firesim
git config --local submodule.sims/firesim.update none
# Only shallow clone needed for basic SW tests
git submodule update --init software/firemarshal
set +x
# Only shallow clone needed for basic SW tests
git submodule update --init software/firemarshal
)
# Configure firemarshal to know where our firesim installation is
if [ ! -f ./software/firemarshal/marshal-config.yaml ]; then