forked from ppg69fuwb/riscv-lab
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.2 KiB
51 lines
1.2 KiB
#!/bin/bash
|
|
|
|
# usage: addenv env_name path
|
|
function addenv() {
|
|
sed -i -e "/^export $1=.*/d" ~/.bashrc
|
|
echo "export $1=`readlink -e $2`" >> ~/.bashrc
|
|
echo "By default this script will add environment variables into ~/.bashrc."
|
|
echo "After that, please run 'source ~/.bashrc' to let these variables take effect."
|
|
echo "If you use shell other than bash, please add these environment variables manually."
|
|
}
|
|
|
|
# usage: init repo branch directory trace [env]
|
|
# trace = true|false
|
|
function init() {
|
|
if [ -d $3 ]; then
|
|
echo "$3 is already initialized, skipping..."
|
|
return
|
|
fi
|
|
|
|
while [ ! -d $3 ]; do
|
|
git clone -b $2 git@github.com:$1.git $3
|
|
done
|
|
log="$1 `cd $3 && git log --oneline --no-abbrev-commit -n1`"$'\n'
|
|
|
|
if [ $4 == "true" ] ; then
|
|
rm -rf $3/.git
|
|
git add -A $3
|
|
git commit -am "$1 $2 initialized"$'\n\n'"$log"
|
|
else
|
|
sed -i -e "/^\/$3/d" .gitignore
|
|
echo "/$3" >> .gitignore
|
|
git add -A .gitignore
|
|
git commit --no-verify --allow-empty -am "$1 $2 initialized without tracing"$'\n\n'"$log"
|
|
fi
|
|
|
|
if [ $5 ] ; then
|
|
addenv $5 $3
|
|
fi
|
|
}
|
|
|
|
case $1 in
|
|
difftest)
|
|
git submodule update --init --recursive
|
|
addenv RVDIFF_HOME difftest
|
|
;;
|
|
*)
|
|
echo "Invalid input..."
|
|
exit
|
|
;;
|
|
esac
|