github.com/palisadeinc/bor@v0.0.0-20230615125219-ab7196213d15/Makefile (about)

     1  # This Makefile is meant to be used by people that do not usually work
     2  # with Go source code. If you know what GOPATH is then you probably
     3  # don't need to bother with make.
     4  
     5  .PHONY: geth android ios geth-cross evm all test clean docs
     6  .PHONY: geth-linux geth-linux-386 geth-linux-amd64 geth-linux-mips64 geth-linux-mips64le
     7  .PHONY: geth-linux-arm geth-linux-arm-5 geth-linux-arm-6 geth-linux-arm-7 geth-linux-arm64
     8  .PHONY: geth-darwin geth-darwin-386 geth-darwin-amd64
     9  .PHONY: geth-windows geth-windows-386 geth-windows-amd64
    10  
    11  GO ?= latest
    12  GOBIN = $(CURDIR)/build/bin
    13  GORUN = env GO111MODULE=on go run
    14  GOPATH = $(shell go env GOPATH)
    15  
    16  GIT_COMMIT ?= $(shell git rev-list -1 HEAD)
    17  
    18  PACKAGE = github.com/ethereum/go-ethereum
    19  GO_FLAGS += -buildvcs=false
    20  GO_LDFLAGS += -ldflags "-X ${PACKAGE}/params.GitCommit=${GIT_COMMIT}"
    21  
    22  TESTALL = $$(go list ./... | grep -v go-ethereum/cmd/)
    23  TESTE2E = ./tests/...
    24  GOTEST = GODEBUG=cgocheck=0 go test $(GO_FLAGS) $(GO_LDFLAGS) -p 1
    25  
    26  bor:
    27  	mkdir -p $(GOPATH)/bin/
    28  	go build -o $(GOBIN)/bor $(GO_LDFLAGS) ./cmd/cli/main.go 
    29  	cp $(GOBIN)/bor $(GOPATH)/bin/
    30  	@echo "Done building."
    31  
    32  protoc:
    33  	protoc --go_out=. --go-grpc_out=. ./internal/cli/server/proto/*.proto
    34  
    35  generate-mocks:
    36  	go generate mockgen -destination=./tests/bor/mocks/IHeimdallClient.go -package=mocks ./consensus/bor IHeimdallClient
    37  	go generate mockgen -destination=./eth/filters/IBackend.go -package=filters ./eth/filters Backend
    38  
    39  geth:
    40  	$(GORUN) build/ci.go install ./cmd/geth
    41  	@echo "Done building."
    42  	@echo "Run \"$(GOBIN)/geth\" to launch geth."
    43  
    44  all:
    45  	$(GORUN) build/ci.go install
    46  
    47  android:
    48  	$(GORUN) build/ci.go aar --local
    49  	@echo "Done building."
    50  	@echo "Import \"$(GOBIN)/geth.aar\" to use the library."
    51  	@echo "Import \"$(GOBIN)/geth-sources.jar\" to add javadocs"
    52  	@echo "For more info see https://stackoverflow.com/questions/20994336/android-studio-how-to-attach-javadoc"
    53  
    54  ios:
    55  	$(GORUN) build/ci.go xcode --local
    56  	@echo "Done building."
    57  	@echo "Import \"$(GOBIN)/Geth.framework\" to use the library."
    58  
    59  test:
    60  	$(GOTEST) --timeout 5m -shuffle=on -cover -short -coverprofile=cover.out -covermode=atomic $(TESTALL)
    61  
    62  test-txpool-race:
    63  	$(GOTEST) -run=TestPoolMiningDataRaces --timeout 600m -race -v ./core/
    64  
    65  test-race:
    66  	$(GOTEST) --timeout 15m -race -shuffle=on $(TESTALL)
    67  
    68  test-integration:
    69  	$(GOTEST) --timeout 60m -tags integration $(TESTE2E)
    70  
    71  escape:
    72  	cd $(path) && go test -gcflags "-m -m" -run none -bench=BenchmarkJumpdest* -benchmem -memprofile mem.out
    73  
    74  lint:
    75  	@./build/bin/golangci-lint run --config ./.golangci.yml
    76  
    77  lintci-deps:
    78  	rm -f ./build/bin/golangci-lint
    79  	curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./build/bin v1.50.1
    80  
    81  goimports:
    82  	goimports -local "$(PACKAGE)" -w .
    83  
    84  docs:
    85  	$(GORUN) cmd/clidoc/main.go -d ./docs/cli
    86  
    87  clean:
    88  	env GO111MODULE=on go clean -cache
    89  	rm -fr build/_workspace/pkg/ $(GOBIN)/*
    90  
    91  # The devtools target installs tools required for 'go generate'.
    92  # You need to put $GOBIN (or $GOPATH/bin) in your PATH to use 'go generate'.
    93  
    94  devtools:
    95  	# Notice! If you adding new binary - add it also to tests/deps/fake.go file
    96  	$(GOBUILD) -o $(GOBIN)/stringer github.com/golang.org/x/tools/cmd/stringer
    97  	$(GOBUILD) -o $(GOBIN)/go-bindata github.com/kevinburke/go-bindata/go-bindata
    98  	$(GOBUILD) -o $(GOBIN)/codecgen github.com/ugorji/go/codec/codecgen
    99  	$(GOBUILD) -o $(GOBIN)/abigen ./cmd/abigen
   100  	$(GOBUILD) -o $(GOBIN)/mockgen github.com/golang/mock/mockgen
   101  	$(GOBUILD) -o $(GOBIN)/protoc-gen-go google.golang.org/protobuf/cmd/protoc-gen-go
   102  	PATH=$(GOBIN):$(PATH) go generate ./common
   103  	PATH=$(GOBIN):$(PATH) go generate ./core/types
   104  	PATH=$(GOBIN):$(PATH) go generate ./consensus/bor
   105  	@type "solc" 2> /dev/null || echo 'Please install solc'
   106  	@type "protoc" 2> /dev/null || echo 'Please install protoc'
   107  
   108  # Cross Compilation Targets (xgo)
   109  geth-cross: geth-linux geth-darwin geth-windows geth-android geth-ios
   110  	@echo "Full cross compilation done:"
   111  	@ls -ld $(GOBIN)/geth-*
   112  
   113  geth-linux: geth-linux-386 geth-linux-amd64 geth-linux-arm geth-linux-mips64 geth-linux-mips64le
   114  	@echo "Linux cross compilation done:"
   115  	@ls -ld $(GOBIN)/geth-linux-*
   116  
   117  geth-linux-386:
   118  	$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=linux/386 -v ./cmd/geth
   119  	@echo "Linux 386 cross compilation done:"
   120  	@ls -ld $(GOBIN)/geth-linux-* | grep 386
   121  
   122  geth-linux-amd64:
   123  	$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=linux/amd64 -v ./cmd/geth
   124  	@echo "Linux amd64 cross compilation done:"
   125  	@ls -ld $(GOBIN)/geth-linux-* | grep amd64
   126  
   127  geth-linux-arm: geth-linux-arm-5 geth-linux-arm-6 geth-linux-arm-7 geth-linux-arm64
   128  	@echo "Linux ARM cross compilation done:"
   129  	@ls -ld $(GOBIN)/geth-linux-* | grep arm
   130  
   131  geth-linux-arm-5:
   132  	$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=linux/arm-5 -v ./cmd/geth
   133  	@echo "Linux ARMv5 cross compilation done:"
   134  	@ls -ld $(GOBIN)/geth-linux-* | grep arm-5
   135  
   136  geth-linux-arm-6:
   137  	$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=linux/arm-6 -v ./cmd/geth
   138  	@echo "Linux ARMv6 cross compilation done:"
   139  	@ls -ld $(GOBIN)/geth-linux-* | grep arm-6
   140  
   141  geth-linux-arm-7:
   142  	$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=linux/arm-7 -v ./cmd/geth
   143  	@echo "Linux ARMv7 cross compilation done:"
   144  	@ls -ld $(GOBIN)/geth-linux-* | grep arm-7
   145  
   146  geth-linux-arm64:
   147  	$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=linux/arm64 -v ./cmd/geth
   148  	@echo "Linux ARM64 cross compilation done:"
   149  	@ls -ld $(GOBIN)/geth-linux-* | grep arm64
   150  
   151  geth-linux-mips:
   152  	$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=linux/mips --ldflags '-extldflags "-static"' -v ./cmd/geth
   153  	@echo "Linux MIPS cross compilation done:"
   154  	@ls -ld $(GOBIN)/geth-linux-* | grep mips
   155  
   156  geth-linux-mipsle:
   157  	$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=linux/mipsle --ldflags '-extldflags "-static"' -v ./cmd/geth
   158  	@echo "Linux MIPSle cross compilation done:"
   159  	@ls -ld $(GOBIN)/geth-linux-* | grep mipsle
   160  
   161  geth-linux-mips64:
   162  	$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=linux/mips64 --ldflags '-extldflags "-static"' -v ./cmd/geth
   163  	@echo "Linux MIPS64 cross compilation done:"
   164  	@ls -ld $(GOBIN)/geth-linux-* | grep mips64
   165  
   166  geth-linux-mips64le:
   167  	$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=linux/mips64le --ldflags '-extldflags "-static"' -v ./cmd/geth
   168  	@echo "Linux MIPS64le cross compilation done:"
   169  	@ls -ld $(GOBIN)/geth-linux-* | grep mips64le
   170  
   171  geth-darwin: geth-darwin-386 geth-darwin-amd64
   172  	@echo "Darwin cross compilation done:"
   173  	@ls -ld $(GOBIN)/geth-darwin-*
   174  
   175  geth-darwin-386:
   176  	$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=darwin/386 -v ./cmd/geth
   177  	@echo "Darwin 386 cross compilation done:"
   178  	@ls -ld $(GOBIN)/geth-darwin-* | grep 386
   179  
   180  geth-darwin-amd64:
   181  	$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=darwin/amd64 -v ./cmd/geth
   182  	@echo "Darwin amd64 cross compilation done:"
   183  	@ls -ld $(GOBIN)/geth-darwin-* | grep amd64
   184  
   185  geth-windows: geth-windows-386 geth-windows-amd64
   186  	@echo "Windows cross compilation done:"
   187  	@ls -ld $(GOBIN)/geth-windows-*
   188  
   189  geth-windows-386:
   190  	$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=windows/386 -v ./cmd/geth
   191  	@echo "Windows 386 cross compilation done:"
   192  	@ls -ld $(GOBIN)/geth-windows-* | grep 386
   193  
   194  geth-windows-amd64:
   195  	$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=windows/amd64 -v ./cmd/geth
   196  	@echo "Windows amd64 cross compilation done:"
   197  	@ls -ld $(GOBIN)/geth-windows-* | grep amd64
   198  
   199  PACKAGE_NAME          := github.com/maticnetwork/bor
   200  GOLANG_CROSS_VERSION  ?= v1.19.1
   201  
   202  .PHONY: release-dry-run
   203  release-dry-run:
   204  	@docker run \
   205  		--rm \
   206  		--privileged \
   207  		-e CGO_ENABLED=1 \
   208  		-e GITHUB_TOKEN \
   209  		-e DOCKER_USERNAME \
   210  		-e DOCKER_PASSWORD \
   211  		-v /var/run/docker.sock:/var/run/docker.sock \
   212  		-v `pwd`:/go/src/$(PACKAGE_NAME) \
   213  		-w /go/src/$(PACKAGE_NAME) \
   214  		goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
   215  		--rm-dist --skip-validate --skip-publish
   216  
   217  .PHONY: release
   218  release:
   219  	@docker run \
   220  		--rm \
   221  		--privileged \
   222  		-e CGO_ENABLED=1 \
   223  		-e GITHUB_TOKEN \
   224  		-e DOCKER_USERNAME \
   225  		-e DOCKER_PASSWORD \
   226  		-e SLACK_WEBHOOK \
   227  		-v /var/run/docker.sock:/var/run/docker.sock \
   228  		-v $(HOME)/.docker/config.json:/root/.docker/config.json \
   229  		-v `pwd`:/go/src/$(PACKAGE_NAME) \
   230  		-w /go/src/$(PACKAGE_NAME) \
   231  		goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
   232  		--rm-dist --skip-validate