mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-29 07:07:16 +00:00
54cf932652
Dockerfile requires some --build-arg options. Fix "docker" target to pass them. Fix GIT_TAG to reflect the most recent tag related to HEAD, instead of an unrelated most recent tag. Use it as the image VERSION. Image tags need to be passed explicitly if needed: DOCKER_FLAGS='-t erigon:latest' make docker
152 lines
4.8 KiB
Makefile
152 lines
4.8 KiB
Makefile
GO = go
|
|
GOBIN = $(CURDIR)/build/bin
|
|
|
|
GIT_COMMIT ?= $(shell git rev-list -1 HEAD)
|
|
GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
|
|
GIT_TAG ?= $(shell git describe --tags --dirty)
|
|
|
|
CGO_CFLAGS := $(shell $(GO) env CGO_CFLAGS) # don't loose default
|
|
CGO_CFLAGS += -DMDBX_FORCE_ASSERTIONS=1 # Enable MDBX's asserts by default in 'devel' branch and disable in 'stable'
|
|
CGO_CFLAGS := CGO_CFLAGS="$(CGO_CFLAGS)"
|
|
DBG_CGO_CFLAGS += -DMDBX_DEBUG=1
|
|
|
|
GO_MINOR_VERSION = $(shell $(GO) version | cut -c 16-17)
|
|
BUILD_TAGS = nosqlite,noboltdb
|
|
PACKAGE = github.com/ledgerwatch/erigon
|
|
|
|
GO_FLAGS += -trimpath -tags $(BUILD_TAGS) -buildvcs=false
|
|
GO_FLAGS += -ldflags "-X ${PACKAGE}/params.GitCommit=${GIT_COMMIT} -X ${PACKAGE}/params.GitBranch=${GIT_BRANCH} -X ${PACKAGE}/params.GitTag=${GIT_TAG}"
|
|
|
|
GOBUILD = $(CGO_CFLAGS) $(GO) build $(GO_FLAGS)
|
|
GO_DBG_BUILD = $(DBG_CGO_CFLAGS) $(GO) build $(GO_FLAGS) -tags $(BUILD_TAGS),debug -gcflags=all="-N -l" # see delve docs
|
|
GOTEST = GODEBUG=cgocheck=0 $(GO) test $(GO_FLAGS) ./... -p 2
|
|
|
|
default: all
|
|
|
|
go-version:
|
|
@if [ $(GO_MINOR_VERSION) -lt 18 ]; then \
|
|
echo "minimum required Golang version is 1.18"; \
|
|
exit 1 ;\
|
|
fi
|
|
|
|
docker: git-submodules
|
|
DOCKER_BUILDKIT=1 docker build \
|
|
--build-arg "BUILD_DATE=$(shell date -Iseconds)" \
|
|
--build-arg VCS_REF=${GIT_COMMIT} \
|
|
--build-arg VERSION=${GIT_TAG} \
|
|
${DOCKER_FLAGS} \
|
|
.
|
|
|
|
xdg_data_home := ~/.local/share
|
|
ifdef XDG_DATA_HOME
|
|
xdg_data_home = $(XDG_DATA_HOME)
|
|
endif
|
|
docker-compose:
|
|
mkdir -p $(xdg_data_home)/erigon $(xdg_data_home)/erigon-grafana $(xdg_data_home)/erigon-prometheus; \
|
|
docker-compose up
|
|
|
|
# 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
|
|
dbg:
|
|
$(GO_DBG_BUILD) -o $(GOBIN)/ ./cmd/...
|
|
|
|
%.cmd: git-submodules
|
|
@# Note: $* is replaced by the command name
|
|
@echo "Building $*"
|
|
@cd ./cmd/$* && $(GOBUILD) -o $(GOBIN)/$*
|
|
@echo "Run \"$(GOBIN)/$*\" to launch $*."
|
|
|
|
geth: erigon
|
|
|
|
erigon: go-version erigon.cmd
|
|
@rm -f $(GOBIN)/tg # Remove old binary to prevent confusion where users still use it because of the scripts
|
|
|
|
COMMANDS += cons
|
|
COMMANDS += devnettest
|
|
COMMANDS += downloader
|
|
COMMANDS += evm
|
|
COMMANDS += hack
|
|
COMMANDS += integration
|
|
COMMANDS += observer
|
|
COMMANDS += pics
|
|
COMMANDS += rpcdaemon
|
|
COMMANDS += rpctest
|
|
COMMANDS += sentry
|
|
COMMANDS += state
|
|
COMMANDS += txpool
|
|
|
|
# build each command using %.cmd rule
|
|
$(COMMANDS): %: %.cmd
|
|
|
|
all: erigon $(COMMANDS)
|
|
|
|
db-tools: git-submodules
|
|
@echo "Building db-tools"
|
|
|
|
# hub.docker.com setup incorrect gitpath for git modules. Just remove it and re-init submodule.
|
|
rm -rf libmdbx
|
|
git submodule update --init --recursive --force libmdbx
|
|
|
|
cd libmdbx && MDBX_BUILD_TIMESTAMP=unknown make tools
|
|
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)
|
|
@echo "Run \"$(GOBIN)/mdbx_stat -h\" to get info about mdbx db file."
|
|
|
|
test:
|
|
$(GOTEST) --timeout 30s
|
|
|
|
test-integration:
|
|
$(GOTEST) --timeout 30m -tags $(BUILD_TAGS),integration
|
|
|
|
lint:
|
|
@./build/bin/golangci-lint run --config ./.golangci.yml
|
|
|
|
lintci:
|
|
@echo "--> Running linter for code"
|
|
@./build/bin/golangci-lint run --config ./.golangci.yml
|
|
|
|
lintci-deps:
|
|
rm -f ./build/bin/golangci-lint
|
|
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./build/bin v1.46.0
|
|
|
|
clean:
|
|
go clean -cache
|
|
rm -fr build/*
|
|
cd libmdbx/ && make clean
|
|
|
|
# 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:
|
|
# 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
|
|
PATH=$(GOBIN):$(PATH) go generate ./consensus/aura/...
|
|
@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'
|
|
|
|
bindings:
|
|
PATH=$(GOBIN):$(PATH) go generate ./tests/contracts/
|
|
PATH=$(GOBIN):$(PATH) go generate ./core/state/contracts/
|
|
|
|
prometheus:
|
|
docker-compose up prometheus grafana
|
|
|
|
|
|
escape:
|
|
cd $(path) && go test -gcflags "-m -m" -run none -bench=BenchmarkJumpdest* -benchmem -memprofile mem.out
|
|
|
|
git-submodules:
|
|
@[ -d ".git" ] || (echo "Not a git repository" && exit 1)
|
|
@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
|