2021-08-18 08:49:53 +00:00
GO = go
2020-09-30 09:28:36 +00:00
GOBIN = $( CURDIR) /build/bin
2021-08-18 08:49:53 +00:00
GOTEST = GODEBUG = cgocheck = 0 $( GO) test ./... -p 2
2015-11-20 14:06:35 +00:00
2020-10-30 08:43:24 +00:00
GIT_COMMIT ?= $( shell git rev-list -1 HEAD)
2021-04-11 04:23:50 +00:00
GIT_BRANCH ?= $( shell git rev-parse --abbrev-ref HEAD)
2021-09-11 08:12:11 +00:00
GIT_TAG ?= $( shell git describe --tags ` git rev-list --tags= "v*" --max-count= 1` )
2022-01-23 03:05:31 +00:00
CGO_CFLAGS := $( shell $( GO) env CGO_CFLAGS) # don't loose default
2022-01-31 09:59:49 +00:00
CGO_CFLAGS += -DMDBX_FORCE_ASSERTIONS= 1 # Enable MDBX's asserts by default in 'devel' branch and disable in 'stable'
2022-01-23 03:05:31 +00:00
CGO_CFLAGS := CGO_CFLAGS = " $( CGO_CFLAGS) "
DBG_CGO_CFLAGS += -DMDBX_DEBUG= 1
GOBUILD = $( CGO_CFLAGS) $( GO) build -trimpath -ldflags " -X github.com/ledgerwatch/erigon/params.GitCommit= ${ GIT_COMMIT } -X github.com/ledgerwatch/erigon/params.GitBranch= ${ GIT_BRANCH } -X github.com/ledgerwatch/erigon/params.GitTag= ${ GIT_TAG } "
GO_DBG_BUILD = $( DBG_CGO_CFLAGS) $( GO) build -trimpath -tags= debug -ldflags " -X github.com/ledgerwatch/erigon/params.GitCommit= ${ GIT_COMMIT } -X github.com/ledgerwatch/erigon/params.GitBranch= ${ GIT_BRANCH } -X github.com/ledgerwatch/erigon/params.GitTag= ${ GIT_TAG } " -gcflags= all = "-N -l" # see delve docs
2020-09-06 11:35:32 +00:00
2021-08-18 08:49:53 +00:00
GO_MAJOR_VERSION = $( shell $( GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1)
GO_MINOR_VERSION = $( shell $( GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)
2021-04-19 10:54:56 +00:00
2022-02-24 15:10:46 +00:00
default : all
2020-08-21 12:38:11 +00:00
2021-04-19 10:54:56 +00:00
go-version :
@if [ $( GO_MINOR_VERSION) -lt 16 ] ; then \
echo "minimum required Golang version is 1.16" ; \
exit 1 ; \
fi
2020-08-21 12:38:11 +00:00
docker :
2021-07-27 02:39:21 +00:00
DOCKER_BUILDKIT = 1 docker build -t erigon:latest --build-arg git_commit = '${GIT_COMMIT}' --build-arg git_branch = '${GIT_BRANCH}' --build-arg git_tag = '${GIT_TAG}' .
2020-08-21 12:38:11 +00:00
2021-07-19 13:40:09 +00:00
xdg_data_home := ~/.local/share
i f d e f X D G _ D A T A _ H O M E
xdg_data_home = $( XDG_DATA_HOME)
e n d i f
2020-08-21 12:38:11 +00:00
docker-compose :
2021-07-19 13:40:09 +00:00
mkdir -p $( xdg_data_home) /erigon $( xdg_data_home) /erigon-grafana $( xdg_data_home) /erigon-prometheus; \
docker-compose up
2019-05-27 13:51:49 +00:00
2021-04-29 14:29:58 +00:00
# debug build allows see C stack traces, run it with GOTRACEBACK=crash. You don't need debug build for C pit for profiling. To profile C code use SETCGOTRCKEBACK=1
2021-06-19 20:30:12 +00:00
dbg :
2021-04-29 14:29:58 +00:00
$( GO_DBG_BUILD) -o $( GOBIN) / ./cmd/...
2022-02-24 15:10:46 +00:00
%.cmd : git -submodules
@# Note: $* is replaced by the command name
@echo " Building $* "
2022-03-04 00:47:09 +00:00
@cd ./cmd/$* && $( GOBUILD) -o $( GOBIN) /$*
2022-02-24 15:10:46 +00:00
@echo " Run \" $( GOBIN) / $* \" to launch $* . "
2021-05-31 10:20:56 +00:00
geth : erigon
2015-04-18 21:21:45 +00:00
2022-02-24 15:10:46 +00:00
erigon : go -version erigon .cmd
2022-02-22 18:17:50 +00:00
@rm -f $( GOBIN) /tg # Remove old binary to prevent confusion where users still use it because of the scripts
2021-05-08 08:45:40 +00:00
2022-02-24 15:10:46 +00:00
COMMANDS += cons
COMMANDS += devnettest
COMMANDS += downloader
COMMANDS += evm
COMMANDS += hack
COMMANDS += integration
COMMANDS += pics
COMMANDS += rpcdaemon
COMMANDS += rpctest
COMMANDS += sentry
COMMANDS += state
COMMANDS += txpool
# build each command using %.cmd rule
$(COMMANDS) : %: %.cmd
all : erigon $( COMMANDS )
2021-11-23 16:44:46 +00:00
2021-11-15 03:14:19 +00:00
db-tools :
2021-06-19 20:30:12 +00:00
@echo "Building db-tools"
2021-12-15 09:07:57 +00:00
# hub.docker.com setup incorrect gitpath for git modules. Just remove it and re-init submodule.
rm -rf libmdbx
2022-01-19 07:54:56 +00:00
git submodule update --init --recursive --force libmdbx
2021-12-15 09:07:57 +00:00
2021-06-27 02:53:49 +00:00
cd libmdbx && MDBX_BUILD_TIMESTAMP = unknown make tools
2021-06-19 20:30:12 +00:00
cp libmdbx/mdbx_chk $( GOBIN)
cp libmdbx/mdbx_copy $( GOBIN)
cp libmdbx/mdbx_dump $( GOBIN)
cp libmdbx/mdbx_drop $( GOBIN)
cp libmdbx/mdbx_load $( GOBIN)
cp libmdbx/mdbx_stat $( GOBIN)
2021-06-11 13:31:37 +00:00
@echo " Run \" $( GOBIN) /mdbx_stat -h\" to get info about mdbx db file. "
2020-10-08 07:11:36 +00:00
2021-06-18 03:35:11 +00:00
test :
2021-06-15 12:41:38 +00:00
$( GOTEST) --timeout 30m
2020-06-12 09:31:21 +00:00
2021-04-27 07:48:59 +00:00
lint :
2021-06-04 12:26:15 +00:00
@./build/bin/golangci-lint run --config ./.golangci.yml
2019-05-27 13:51:49 +00:00
2021-06-18 03:35:11 +00:00
lintci :
2021-03-29 23:17:19 +00:00
@echo "--> Running linter for code"
2021-06-04 12:26:15 +00:00
@./build/bin/golangci-lint run --config ./.golangci.yml
2019-11-05 08:12:49 +00:00
2019-05-27 13:51:49 +00:00
lintci-deps :
2019-11-06 12:34:35 +00:00
rm -f ./build/bin/golangci-lint
2021-10-12 05:04:04 +00:00
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./build/bin v1.42.1
2018-04-17 22:53:50 +00:00
2016-05-25 12:07:57 +00:00
clean :
2021-12-22 04:18:35 +00:00
go clean -cache
2020-10-28 03:18:10 +00:00
rm -fr build/*
2021-06-19 20:30:12 +00:00
cd libmdbx/ && make clean
2016-05-25 12:07:57 +00:00
2017-02-26 22:52:10 +00:00
# The devtools target installs tools required for 'go generate'.
# You need to put $GOBIN (or $GOPATH/bin) in your PATH to use 'go generate'.
devtools :
2020-10-02 03:56:13 +00:00
# Notice! If you adding new binary - add it also to cmd/hack/binary-deps/main.go file
$( GOBUILD) -o $( GOBIN) /go-bindata github.com/kevinburke/go-bindata/go-bindata
$( GOBUILD) -o $( GOBIN) /gencodec github.com/fjl/gencodec
$( GOBUILD) -o $( GOBIN) /codecgen github.com/ugorji/go/codec/codecgen
$( GOBUILD) -o $( GOBIN) /abigen ./cmd/abigen
PATH = $( GOBIN) :$( PATH) go generate ./common
PATH = $( GOBIN) :$( PATH) go generate ./core/types
2021-06-25 18:13:40 +00:00
PATH = $( GOBIN) :$( PATH) go generate ./consensus/aura/...
2018-01-08 12:15:57 +00:00
@type "npm" 2> /dev/null || echo 'Please install node.js and npm'
@type "solc" 2> /dev/null || echo 'Please install solc'
@type "protoc" 2> /dev/null || echo 'Please install protoc'
2017-02-26 22:52:10 +00:00
2019-05-27 13:51:49 +00:00
bindings :
2020-10-02 03:56:13 +00:00
PATH = $( GOBIN) :$( PATH) go generate ./tests/contracts/
PATH = $( GOBIN) :$( PATH) go generate ./core/state/contracts/
2020-09-03 07:51:19 +00:00
2020-04-29 10:51:07 +00:00
prometheus :
2020-08-01 15:05:48 +00:00
docker-compose up prometheus grafana
2020-06-05 16:46:34 +00:00
2021-02-28 04:11:28 +00:00
2020-06-05 16:46:34 +00:00
escape :
2020-06-15 16:39:34 +00:00
cd $( path) && go test -gcflags "-m -m" -run none -bench= BenchmarkJumpdest* -benchmem -memprofile mem.out
2022-01-19 07:54:56 +00:00
git-submodules :
2022-02-22 18:17:50 +00:00
@echo "Updating git submodules"
@# Dockerhub using ./hooks/post-checkout to set submodules, so this line will fail on Dockerhub
@git submodule update --quiet --init --recursive --force || true