From 5a49853cb40a4f8a997072cbd93592b3aae19fa9 Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Wed, 2 Apr 2025 15:01:16 +0800 Subject: [PATCH] Makefile: add devtools and help targets, remove gc target --- Makefile | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 7a63bf119c..f646afc2e8 100644 --- a/Makefile +++ b/Makefile @@ -7,12 +7,8 @@ .PHONY: XDC-darwin XDC-darwin-386 XDC-darwin-amd64 GOBIN = $(shell pwd)/build/bin -GOFMT = gofmt GO ?= 1.23.6 GORUN = go run -GO_PACKAGES = . -GO_FILES := $(shell find $(shell go list -f '{{.Dir}}' $(GO_PACKAGES)) -name \*.go) -GIT = git #? XDC: Build XDC. XDC: @@ -31,11 +27,6 @@ XDC-devnet-local: @echo "Run the devnet script in local" cd cicd/devnet && ./start-local-devnet.sh -gc: - go run build/ci.go install ./cmd/gc - @echo "Done building." - @echo "Run \"$(GOBIN)/gc\" to launch gc." - bootnode: go run build/ci.go install ./cmd/bootnode @echo "Done building." @@ -70,14 +61,36 @@ check_tidy: ## Run 'go mod tidy'. check_generate: ## Run 'go generate ./...'. $(GORUN) build/ci.go check_generate -#? clean: Clean go cache, built executables, and the auto generated folder. -clean: - rm -fr build/_workspace/pkg/ $(GOBIN)/* - #? fmt: Ensure consistent code formatting. fmt: gofmt -s -w $(shell find . -name "*.go") +#? clean: Clean go cache, built executables, and the auto generated folder. +clean: + go clean -cache + rm -fr build/_workspace/pkg/ $(GOBIN)/* + +# 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: Install recommended developer tools. +devtools: + env GOBIN= go install golang.org/x/tools/cmd/stringer@latest + env GOBIN= go install github.com/fjl/gencodec@latest + env GOBIN= go install google.golang.org/protobuf/cmd/protoc-gen-go@latest + env GOBIN= go install ./cmd/abigen + @type "solc" 2> /dev/null || echo 'Please install solc' + @type "protoc" 2> /dev/null || echo 'Please install protoc' + +#? help: Get more info on make commands. +help: Makefile + @echo '' + @echo 'Usage:' + @echo ' make [target]' + @echo '' + @echo 'Targets:' + @sed -n 's/^#?//p' $< | column -t -s ':' | sort | sed -e 's/^/ /' + # Cross Compilation Targets (xgo) XDC-cross: XDC-windows-amd64 XDC-darwin-amd64 XDC-linux @@ -136,6 +149,3 @@ XDC-windows-amd64: go run build/ci.go xgo -- --go=$(GO) -buildmode=mode -x --targets=windows/amd64 -v ./cmd/XDC @echo "Windows amd64 cross compilation done:" @ls -ld $(GOBIN)/XDC-windows-* | grep amd64 -gofmt: - $(GOFMT) -s -w $(GO_FILES) - $(GIT) checkout vendor