Files
evm/scripts/build.sh
T
Ceyhun OnurandGitHub 1b6ddf5720 bump avalanchego to v1.10.14 (#971)
* bump avalanchego to v1.10.14

* fix versions in readme

* bump min golang version

* bump anr
2023-10-26 12:42:12 -04:00

54 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
go_version_minimum="1.20.10"
go_version() {
go version | sed -nE -e 's/[^0-9.]+([0-9.]+).+/\1/p'
}
version_lt() {
# Return true if $1 is a lower version than than $2,
local ver1=$1
local ver2=$2
# Reverse sort the versions, if the 1st item != ver1 then ver1 < ver2
if [[ $(echo -e -n "$ver1\n$ver2\n" | sort -rV | head -n1) != "$ver1" ]]; then
return 0
else
return 1
fi
}
if version_lt "$(go_version)" "$go_version_minimum"; then
echo "SubnetEVM requires Go >= $go_version_minimum, Go $(go_version) found." >&2
exit 1
fi
# Root directory
SUBNET_EVM_PATH=$(
cd "$(dirname "${BASH_SOURCE[0]}")"
cd .. && pwd
)
# Load the versions
source "$SUBNET_EVM_PATH"/scripts/versions.sh
# Load the constants
source "$SUBNET_EVM_PATH"/scripts/constants.sh
if [[ $# -eq 1 ]]; then
BINARY_PATH=$1
elif [[ $# -eq 0 ]]; then
BINARY_PATH="$GOPATH/src/github.com/ava-labs/avalanchego/build/plugins/srEXiWaHuhNyGwPUi444Tu47ZEDwxTWrbQiuD7FmgSAQ6X7Dy"
else
echo "Invalid arguments to build subnet-evm. Requires zero (default location) or one argument to specify binary location."
exit 1
fi
# Build Subnet EVM, which is run as a subprocess
echo "Building Subnet EVM @ GitCommit: $SUBNET_EVM_COMMIT at $BINARY_PATH"
go build -ldflags "-X github.com/ava-labs/subnet-evm/plugin/evm.GitCommit=$SUBNET_EVM_COMMIT $STATIC_LD_FLAGS" -o "$BINARY_PATH" "plugin/"*.go