Skip to content

Commit

Permalink
fix(agd): check xsnap was rebuilt
Browse files Browse the repository at this point in the history
  • Loading branch information
mhofman committed Jul 1, 2024
1 parent 467435a commit a22772e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
2 changes: 2 additions & 0 deletions packages/xsnap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"build:env": "node src/build.js --show-env > build.env",
"build:from-env": "{ cat build.env; echo node src/build.js; } | xargs env",
"build": "yarn build:bin && yarn build:env",
"check-version": "xsnap_version=$(./scripts/get_xsnap_version.sh); if test \"${npm_package_version}\" != \"${xsnap_version}\"; then echo \"xsnap version mismatch; expected '${npm_package_version}', got '${xsnap_version}'\"; exit 1; fi",
"postinstall": "npm run build:from-env",
"clean": "rm -rf xsnap-native/xsnap/build",
"lint": "run-s --continue-on-error lint:*",
Expand Down Expand Up @@ -56,6 +57,7 @@
"moddable/xs/makefiles",
"moddable/xs/platforms/*.h",
"moddable/xs/sources",
"scripts",
"src",
"xsnap-native/xsnap/makefiles",
"xsnap-native/xsnap/sources"
Expand Down
14 changes: 14 additions & 0 deletions packages/xsnap/scripts/get_xsnap_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

set -ueo pipefail

# the xsnap binary lives in a platform-specific directory
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) platform=lin ;;
Darwin*) platform=mac ;;
*) platform=win ;;
esac

# extract the xsnap package version from the long version printed by xsnap-worker
"./xsnap-native/xsnap/build/bin/${platform}/release/xsnap-worker" -v | sed -e 's/^xsnap \([^ ]*\) (XS [^)]*)$/\1/g'
3 changes: 1 addition & 2 deletions repoconfig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ NODEJS_VERSION=v16
GOLANG_VERSION=1.20.3
GOLANG_DIR=golang/cosmos
GOLANG_DAEMON=$GOLANG_DIR/build/agd
XSNAP_VERSION=agoric-upgrade-10

# Args are major, minor and patch version numbers
golang_version_check() {
{
[ "$1" -eq 1 ] && [ "$2" -eq 20 ] && [ "$3" -ge 2 ] && return 0
[ "$1" -eq 1 ] && [ "$2" -ge 21 ] && return 0
[ "$1" -ge 2 ] && return 0
} 2>/dev/null
} 2> /dev/null
echo 1>&2 "need go version 1.20.2+, 1.21+, or 2+"
return 1
}
15 changes: 3 additions & 12 deletions scripts/agd-builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -219,21 +219,12 @@ $do_not_build || (
echo "At least $src is newer than gyp bindings"
(cd "$GOLANG_DIR" && lazy_yarn build:gyp)
}

# check the built xsnap version against the package version it should be using
(cd "${thisdir}/../packages/xsnap" && npm run -s check-version) || exit 1
fi
)

# the xsnap binary lives in a platform-specific directory
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) platform=lin ;;
Darwin*) platform=mac ;;
*) platform=win ;;
esac

# check the xsnap version against our baked-in notion of what version we should be using
xsnap_version=$("${thisdir}/../packages/xsnap/xsnap-native/xsnap/build/bin/${platform}/release/xsnap-worker" -n)
[[ "${xsnap_version}" == "${XSNAP_VERSION}" ]] || fatal "xsnap version mismatch; expected ${XSNAP_VERSION}, got ${xsnap_version}"

if $only_build; then
echo "Build complete." 1>&2
exit 0
Expand Down

0 comments on commit a22772e

Please sign in to comment.