From 9ca3df2fdf2b0847e4f78d03163c6a1e3d76bc67 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Fri, 30 Aug 2024 00:19:43 -0700 Subject: [PATCH] More fixes to check-dependencies.bash --- scripts/check-dependencies.bash | 44 ++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/scripts/check-dependencies.bash b/scripts/check-dependencies.bash index 975da85a..aa6a9b3a 100755 --- a/scripts/check-dependencies.bash +++ b/scripts/check-dependencies.bash @@ -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 @@ -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 @@ -120,5 +126,3 @@ for P in $PROTOCOL_VERSIONS; do fi done - -