Skip to content

Commit

Permalink
Add a git version check to the init scripts and make them work outsid…
Browse files Browse the repository at this point in the history
…e of the repo root. (ucb-bar#459)

* Fixes ucb-bar#453

- Update scripts/init-submodules-no-riscv-tools.sh to also work if you're in scripts/

- Provide a git version check to ensure the init scripts will work (>= 1.7.8)

- Update the documentation to be more explicit that the init script is also for updating.

* Update scripts/init-submodules-no-riscv-tools-nolog.sh

Co-Authored-By: Albert Ou <[email protected]>
  • Loading branch information
jwright6323 and a0u authored Mar 5, 2020
1 parent 9f7247b commit 1e26cb1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/Chipyard-Basics/Initial-Repo-Setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ After cloning this repo, you will need to initialize all of the submodules.
cd chipyard
./scripts/init-submodules-no-riscv-tools.sh
When updating Chipyard to a new version, you will also want to rerun this script to update the submodules.
Using git directly will try to initialize all submodules; this is not recommended unless you expressly desire this behavior.

.. _build-toolchains:

Building a Toolchain
Expand Down
14 changes: 13 additions & 1 deletion scripts/init-submodules-no-riscv-tools-nolog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@
set -e
set -o pipefail

# 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.7.8"
if [ "$MINGIT" != "$(echo -e "$MINGIT\n$MYGIT" | sort -V | head -n1)" ]; then
echo "This script requires git version $MINGIT or greater. Exiting."
false
fi

RDIR=$(git rev-parse --show-toplevel)

# Ignore toolchain submodules
Expand Down Expand Up @@ -61,4 +74,3 @@ if [ ! -f $RDIR/software/firemarshal/marshal-config.yaml ]; then
echo "firesim-dir: '../../sims/firesim/'" > $RDIR/software/firemarshal/marshal-config.yaml
fi
echo "PATH=\$( realpath \$(dirname "\${BASH_SOURCE[0]:-\${\(%\):-%x}}") )/software/firemarshal:\$PATH" >> $RDIR/env.sh

3 changes: 3 additions & 0 deletions scripts/init-submodules-no-riscv-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
set -e
set -o pipefail

RDIR=$(git rev-parse --show-toplevel)
cd "$RDIR"

./scripts/init-submodules-no-riscv-tools-nolog.sh "$@" 2>&1 | tee init-submodules-no-riscv-tools.log

0 comments on commit 1e26cb1

Please sign in to comment.