Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
romac committed Jun 19, 2023
1 parent 9e87819 commit ad769cc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions scripts/sync-protobuf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ set -eou pipefail
CACHE_PATH="${XDG_CACHE_HOME:-$HOME/.cache}"
COSMOS_SDK_GIT="${COSMOS_SDK_GIT:-$CACHE_PATH/cosmos/cosmos-sdk.git}"
IBC_GO_GIT="${IBC_GO_GIT:-$CACHE_PATH/ibc-go.git}"
COSMOS_ICS_GIT="${COSMOS_ICS_GIT:-$CACHE_PATH/cosmos/interchain-security.git}"
ICS_GIT="${ICS_GIT:-$CACHE_PATH/cosmos/interchain-security.git}"

COSMOS_SDK_COMMIT="$(cat src/COSMOS_SDK_COMMIT)"
IBC_GO_COMMIT="$(cat src/IBC_GO_COMMIT)"
COSMOS_ICS_COMMIT="$(cat src/COSMOS_ICS_COMMIT)"
ICS_COMMIT="$(cat src/ICS_COMMIT)"

echo "COSMOS_SDK_COMMIT: $COSMOS_SDK_COMMIT"
echo "IBC_GO_COMMIT: $IBC_GO_COMMIT"
echo "COSMOS_ICS_COMMIT: $COSMOS_ICS_COMMIT"
echo "ICS_COMMIT: $ICS_COMMIT"

# Use either --ics-commit flag for commit ID,
# or --ics-tag for git tag. Because we can't modify
# proto-compiler to have smart detection on that.

if [[ "$COSMOS_ICS_COMMIT" =~ ^[a-zA-Z0-9]{40}$ ]]
if [[ "$ICS_COMMIT" =~ ^[a-zA-Z0-9]{40}$ ]]
then
ICS_COMMIT_OPTION="--ics-commit"
else
Expand All @@ -50,12 +50,12 @@ fi
# bare git repositories so that no local modification
# can be done there.

if [[ ! -e "$COSMOS_ICS_GIT" ]]
if [[ ! -e "$ICS_GIT" ]]
then
echo "Cloning interchain-security source code to as bare git repository to $COSMOS_ICS_GIT"
git clone --mirror https://github.com/cosmos/interchain-security.git "$COSMOS_ICS_GIT"
echo "Cloning interchain-security source code to as bare git repository to $ICS_GIT"
git clone --mirror https://github.com/cosmos/interchain-security.git "$ICS_GIT"
else
echo "Using existing interchain-security bare git repository at $COSMOS_ICS_GIT"
echo "Using existing interchain-security bare git repository at $ICS_GIT"
fi

# Use either --sdk-commit flag for commit ID,
Expand Down Expand Up @@ -91,7 +91,7 @@ fi

# Update the repositories using git fetch. This is so that
# we keep local copies of the repositories up to sync first.
pushd "$COSMOS_ICS_GIT"
pushd "$ICS_GIT"
git fetch
popd

Expand All @@ -107,16 +107,16 @@ popd
# actual source files from the bare git repositories.
# This is so that we do not accidentally use an unclean
# local copy of the source files to generate the protobuf.
COSMOS_ICS_DIR=$(mktemp -d /tmp/interchain-security-XXXXXXXX)
ICS_DIR=$(mktemp -d /tmp/interchain-security-XXXXXXXX)

pushd "$COSMOS_ICS_DIR"
git clone "$COSMOS_ICS_GIT" .
git checkout "$COSMOS_ICS_COMMIT"
pushd "$ICS_DIR"
git clone "$ICS_GIT" .
git checkout "$ICS_COMMIT"

# We have to name the commit as a branch because
# proto-compiler uses the branch name as the commit
# output. Otherwise it will just output HEAD
git checkout -b "$COSMOS_ICS_COMMIT"
git checkout -b "$ICS_COMMIT"

cd proto
buf mod update
Expand Down Expand Up @@ -188,12 +188,12 @@ cargo build --locked
# and once for no-std version with --build-tonic set to false

cargo run --locked -- compile \
--ics "$COSMOS_ICS_DIR/proto-include" \
--ics "$ICS_DIR/proto-include" \
--sdk "$COSMOS_SDK_DIR/proto-include" \
--ibc "$IBC_GO_DIR/proto-include" \
--out ../../src/prost

# Remove the temporary checkouts of the repositories
rm -rf "$COSMOS_ICS_DIR"
rm -rf "$ICS_DIR"
rm -rf "$COSMOS_SDK_DIR"
rm -rf "$IBC_GO_DIR"
File renamed without changes.

0 comments on commit ad769cc

Please sign in to comment.