Skip to content

Commit

Permalink
More fixes to check-dependencies.bash
Browse files Browse the repository at this point in the history
  • Loading branch information
graydon committed Aug 30, 2024
1 parent 92fa9a4 commit 9ca3df2
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions scripts/check-dependencies.bash
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ fi

CURL="curl -sL --fail-with-body"

PROTOS=$($SED -n ':pkg; /"soroban-env-host"/ {n; /version/ { s/[^0-9]*\([0-9]\+\).*/\1/ p; b pkg;}}' Cargo.toml | tr '\n' ' ')
# PROTOS is in ascending order so the last iteration of the PROTOS-based loops
# will end up with the highest protocol value used for recording any state
# variables.
PROTOS=$($SED -n ':pkg; /"soroban-env-host"/ {n; /version/ { s/[^0-9]*\([0-9]\+\).*/\1/ p; b pkg;}}' Cargo.toml | sort -n | tr '\n' ' ')
if [ -z "$PROTOS" ]; then
echo "Cannot find soroban-env-host dependencies in Cargo.toml"
exit 1
Expand Down Expand Up @@ -52,25 +55,28 @@ function stellar_xdr_version_from_rust_dep_tree {
echo $LINE | $SED -n 's/.*stellar-xdr \(v\)\{0,1\}\([^ ]*\).*/\2/p'
}

if CARGO_OUTPUT=$(cargo tree --depth 0 -p stellar-xdr 2>&1); then
RS_STELLAR_XDR_REVISION=$(echo "$CARGO_OUTPUT" | stellar_xdr_version_from_rust_dep_tree)
if [ ${#RS_STELLAR_XDR_REVISION} -eq 40 ]; then
# revision is a git hash
STELLAR_XDR_REVISION_FROM_RUST=$($CURL https://raw.githubusercontent.com/stellar/rs-stellar-xdr/${RS_STELLAR_XDR_REVISION}/xdr/curr-version)
for PROTO in $PROTOS
do
if CARGO_OUTPUT=$(cargo tree --depth 0 -p stellar-xdr@$PROTO 2>&1); then
RS_STELLAR_XDR_REVISION=$(echo "$CARGO_OUTPUT" | stellar_xdr_version_from_rust_dep_tree)
if [ ${#RS_STELLAR_XDR_REVISION} -eq 40 ]; then
# revision is a git hash
STELLAR_XDR_REVISION_FROM_RUST=$($CURL https://raw.githubusercontent.com/stellar/rs-stellar-xdr/${RS_STELLAR_XDR_REVISION}/xdr/curr-version)
else
# revision is a crate version
CARGO_SRC_BASE_DIR=$(realpath ${CARGO_HOME:-$HOME/.cargo}/registry/src/index*)
STELLAR_XDR_REVISION_FROM_RUST=$(cat "${CARGO_SRC_BASE_DIR}/stellar-xdr-${RS_STELLAR_XDR_REVISION}/xdr/curr-version")
fi
else
# revision is a crate version
CARGO_SRC_BASE_DIR=$(realpath ${CARGO_HOME:-$HOME/.cargo}/registry/src/index*)
STELLAR_XDR_REVISION_FROM_RUST=$(cat "${CARGO_SRC_BASE_DIR}/stellar-xdr-${RS_STELLAR_XDR_REVISION}/xdr/curr-version")
echo "The project depends on multiple versions of the Rust rs-stellar-xdr@$PROTO library"
echo "Make sure a single version of stellar-xdr@$PROTO is used"
echo
echo
echo
echo "Full error:"
echo $CARGO_OUTPUT
fi
else
echo "The project depends on multiple versions of the Rust rs-stellar-xdr library"
echo "Make sure a single version of stellar-xdr is used"
echo
echo
echo
echo "Full error:"
echo $CARGO_OUTPUT
fi
done

# Now, lets compare the Rust and Go XDR revisions
# TODO: The sed extraction below won't work for version tags
Expand Down Expand Up @@ -120,5 +126,3 @@ for P in $PROTOCOL_VERSIONS; do
fi
done



0 comments on commit 9ca3df2

Please sign in to comment.