Skip to content

Commit

Permalink
chore: update abigen build script and go version src in ci
Browse files Browse the repository at this point in the history
  • Loading branch information
RayXpub committed Feb 17, 2025
1 parent 6272fc5 commit d3dfce0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 29 deletions.
6 changes: 2 additions & 4 deletions core/gethwrappers/abigen.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"go/token"
"os"
"os/exec"
"path/filepath"
"regexp"
"strings"

Expand Down Expand Up @@ -40,8 +39,7 @@ type AbigenArgs struct {
// Check whether native abigen is installed, and has correct version
func Abigen(a AbigenArgs) {
var versionResponse bytes.Buffer
abigenExecutablePath := filepath.Join(GetProjectRoot(), "tools/bin/abigen")
abigenVersionCheck := exec.Command(abigenExecutablePath, "--version")
abigenVersionCheck := exec.Command("abigen", "--version")
abigenVersionCheck.Stdout = &versionResponse
if err := abigenVersionCheck.Run(); err != nil {
Exit("no native abigen; you must install it (`make abigen` in the "+
Expand All @@ -64,7 +62,7 @@ func Abigen(a AbigenArgs) {
if a.Bin != "-" {
args = append(args, "-bin", a.Bin)
}
buildCommand := exec.Command(abigenExecutablePath, args...)
buildCommand := exec.Command("abigen", args...)
var buildResponse bytes.Buffer
buildCommand.Stderr = &buildResponse
if err := buildCommand.Run(); err != nil {
Expand Down
29 changes: 4 additions & 25 deletions tools/bin/build_abigen
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,19 @@
# Checks that the correct abigen is installed in this directory, and installs it
# if not.

set -e
set -euo pipefail

# Version of abigen to install. Must be run within chainlink project
GETH_VERSION=$(go list -json -m github.com/ethereum/go-ethereum | jq -r .Version)
GETH_REPO_URL="https://github.com/ethereum/go-ethereum"

function realpath { echo $(cd $(dirname $1); pwd)/$(basename $1); }
THIS_DIR="$(realpath "$(dirname $0)")"

NATIVE_ABIGEN_VERSION=v"$(
"$THIS_DIR/abigen" --version 2> /dev/null | \
grep -E -o '([0-9]+\.[0-9]+\.[0-9]+)'
abigen --version 2>/dev/null |
grep -E -o '([0-9]+\.[0-9]+\.[0-9]+)'
)" || true

if [ "$NATIVE_ABIGEN_VERSION" == "$GETH_VERSION" ]; then
echo "Correct abigen version already installed."
exit 0
fi

function cleanup() {
rm -rf "$TMPDIR"
}

trap cleanup EXIT

TMPDIR="$(mktemp -d)"

pushd "$TMPDIR"

git clone --depth=1 --single-branch --branch "$GETH_VERSION" "$GETH_REPO_URL"
cd go-ethereum/cmd/abigen
go build
rm -f "$THIS_DIR/abigen" # necessary on MacOS for code signing
cp ./abigen "$THIS_DIR"

popd

go install github.com/ethereum/go-ethereum/cmd/abigen@$GETH_VERSION

0 comments on commit d3dfce0

Please sign in to comment.