github.com/cgcardona/r-subnet-evm@v0.1.5/scripts/build.sh (about) 1 #!/usr/bin/env bash 2 3 set -o errexit 4 set -o nounset 5 set -o pipefail 6 7 go_version_minimum="1.19.6" 8 9 go_version() { 10 go version | sed -nE -e 's/[^0-9.]+([0-9.]+).+/\1/p' 11 } 12 13 version_lt() { 14 # Return true if $1 is a lower version than than $2, 15 local ver1=$1 16 local ver2=$2 17 # Reverse sort the versions, if the 1st item != ver1 then ver1 < ver2 18 if [[ $(echo -e -n "$ver1\n$ver2\n" | sort -rV | head -n1) != "$ver1" ]]; then 19 return 0 20 else 21 return 1 22 fi 23 } 24 25 if version_lt "$(go_version)" "$go_version_minimum"; then 26 echo "SubnetEVM requires Go >= $go_version_minimum, Go $(go_version) found." >&2 27 exit 1 28 fi 29 30 # Root directory 31 SUBNET_EVM_PATH=$( 32 cd "$(dirname "${BASH_SOURCE[0]}")" 33 cd .. && pwd 34 ) 35 36 # Load the versions 37 source "$SUBNET_EVM_PATH"/scripts/versions.sh 38 39 # Load the constants 40 source "$SUBNET_EVM_PATH"/scripts/constants.sh 41 42 if [[ $# -eq 1 ]]; then 43 BINARY_PATH=$1 44 elif [[ $# -eq 0 ]]; then 45 BINARY_PATH="$GOPATH/src/github.com/ava-labs/avalanchego/build/plugins/srEXiWaHuhNyGwPUi444Tu47ZEDwxTWrbQiuD7FmgSAQ6X7Dy" 46 else 47 echo "Invalid arguments to build subnet-evm. Requires zero (default location) or one argument to specify binary location." 48 exit 1 49 fi 50 51 # Build Subnet EVM, which is run as a subprocess 52 echo "Building Subnet EVM Version: $SUBNET_EVM_VERSION at $BINARY_PATH" 53 go build -ldflags "-X github.com/cgcardona/r-subnet-evm/plugin/evm.GitCommit=$SUBNET_EVM_COMMIT -X github.com/cgcardona/r-subnet-evm/plugin/evm.Version=$SUBNET_EVM_VERSION $STATIC_LD_FLAGS" -o "$BINARY_PATH" "plugin/"*.go