github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/cosmos-sdk/contrib/devtools/Makefile (about) 1 ### 2 # Find OS and Go environment 3 # GO contains the Go binary 4 # FS contains the OS file separator 5 ### 6 ifeq ($(OS),Windows_NT) 7 GO := $(shell where go.exe 2> NUL) 8 FS := "\\" 9 else 10 GO := $(shell command -v go 2> /dev/null) 11 FS := "/" 12 endif 13 14 ifeq ($(GO),) 15 $(error could not find go. Is it in PATH? $(GO)) 16 endif 17 18 GOPATH ?= $(shell $(GO) env GOPATH) 19 GITHUBDIR := $(GOPATH)$(FS)src$(FS)github.com 20 GOLANGCI_LINT_HASHSUM := 8d21cc95da8d3daf8321ac40091456fc26123c964d7c2281d339d431f2f4c840 21 22 ### 23 # Functions 24 ### 25 26 go_get = $(if $(findstring Windows_NT,$(OS)),\ 27 IF NOT EXIST $(GITHUBDIR)$(FS)$(1)$(FS) ( mkdir $(GITHUBDIR)$(FS)$(1) ) else (cd .) &\ 28 IF NOT EXIST $(GITHUBDIR)$(FS)$(1)$(FS)$(2)$(FS) ( cd $(GITHUBDIR)$(FS)$(1) && git clone https://github.com/$(1)/$(2) ) else (cd .) &\ 29 ,\ 30 mkdir -p $(GITHUBDIR)$(FS)$(1) &&\ 31 (test ! -d $(GITHUBDIR)$(FS)$(1)$(FS)$(2) && cd $(GITHUBDIR)$(FS)$(1) && git clone https://github.com/$(1)/$(2)) || true &&\ 32 )\ 33 cd $(GITHUBDIR)$(FS)$(1)$(FS)$(2) && git fetch origin && git checkout -q $(3) 34 35 mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) 36 mkfile_dir := $(shell cd $(shell dirname $(mkfile_path)); pwd) 37 38 ### 39 # tools 40 ### 41 42 TOOLS_DESTDIR ?= $(GOPATH)/bin 43 44 GOLANGCI_LINT = $(TOOLS_DESTDIR)/golangci-lint 45 STATIK = $(TOOLS_DESTDIR)/statik 46 RUNSIM = $(TOOLS_DESTDIR)/runsim 47 48 all: tools 49 50 tools: statik runsim golangci-lint 51 52 golangci-lint: $(GOLANGCI_LINT) 53 $(GOLANGCI_LINT): $(mkfile_dir)/install-golangci-lint.sh 54 @echo "Installing golangci-lint..." 55 @bash $(mkfile_dir)/install-golangci-lint.sh $(TOOLS_DESTDIR) $(GOLANGCI_LINT_HASHSUM) 56 57 # Install the runsim binary with a temporary workaround of entering an outside 58 # directory as the "go get" command ignores the -mod option and will polute the 59 # go.{mod, sum} files. 60 # 61 # ref: https://github.com/golang/go/issues/30515 62 statik: $(STATIK) 63 $(STATIK): 64 @echo "Installing statik..." 65 @(cd /tmp && go get github.com/rakyll/statik@v0.1.6) 66 67 # Install the runsim binary with a temporary workaround of entering an outside 68 # directory as the "go get" command ignores the -mod option and will polute the 69 # go.{mod, sum} files. 70 # 71 # ref: https://github.com/golang/go/issues/30515 72 runsim: $(RUNSIM) 73 $(RUNSIM): 74 @echo "Installing runsim..." 75 @(cd /tmp && go get github.com/cosmos/tools/cmd/runsim@v1.0.0) 76 77 tools-clean: 78 rm -f $(STATIK) $(GOLANGCI_LINT) $(RUNSIM) 79 rm -f tools-stamp 80 81 .PHONY: all tools tools-clean