forked from 0xPolygon/cdk-data-availability
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
97 lines (77 loc) · 2.79 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
include version.mk
# Check for required dependencies
CHECK_MOCKERY := $(shell command -v mockery 2> /dev/null)
CHECK_GO := $(shell command -v go 2> /dev/null)
CHECK_CURL := $(shell command -v curl 2> /dev/null)
CHECK_DOCKER := $(shell command -v docker 2> /dev/null)
check-mockery:
ifndef CHECK_MOCKERY
$(error "Mockery is not installed. Please install Mockery and retry.")
endif
check-go:
ifndef CHECK_GO
$(error "Go is not installed. Please install Go and retry.")
endif
check-curl:
ifndef CHECK_CURL
$(error "curl is not installed. Please install curl and retry.")
endif
check-docker:
ifndef CHECK_DOCKER
$(error "Docker is not installed. Please install Docker and retry.")
endif
clean:
env GO111MODULE=on go clean -cache
rm -fr build/_workspace/pkg/ $(GOBIN)/*
# Targets that require the checks
generate: check-go
build: check-go
build-docker: check-docker
build-docker-nc: check-docker
install-linter: check-go check-curl
lint: check-go
ARCH := $(shell uname -m)
ifeq ($(ARCH),x86_64)
ARCH = amd64
else
ifeq ($(ARCH),aarch64)
ARCH = arm64
endif
endif
GOBASE := $(shell pwd)
GOBIN := $(GOBASE)/dist
GOOS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
GOENVVARS := GOBIN=$(GOBIN) CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(ARCH)
GOBINARY := xlayer-data-availability
GOCMD := $(GOBASE)/cmd
LDFLAGS += -X 'github.com/0xPolygon/cdk-data-availability.Version=$(VERSION)'
LDFLAGS += -X 'github.com/0xPolygon/cdk-data-availability.GitRev=$(GITREV)'
LDFLAGS += -X 'github.com/0xPolygon/cdk-data-availability.GitBranch=$(GITBRANCH)'
LDFLAGS += -X 'github.com/0xPolygon/cdk-data-availability.BuildDate=$(DATE)'
.PHONY: generate
generate: ## Generates mocks and other autogenerated types
mockery
.PHONY: build
build: ## Builds the binary locally into ./dist
$(GOENVVARS) go build -ldflags "all=$(LDFLAGS)" -o $(GOBIN)/$(GOBINARY) $(GOCMD)
.PHONY: build-docker
build-docker: ## Builds a docker image with the node binary
docker build -t xlayer-data-availability -f ./Dockerfile .
.PHONY: build-docker-nc
build-docker-nc: ## Builds a docker image with the node binary - but without build cache
docker build --no-cache=true -t xlayer-data-availability -f ./Dockerfile .
.PHONY: install-linter
install-linter: ## Installs the linter
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.59.1
.PHONY: lint
lint: ## Runs the linter
export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/golangci-lint run
## Help display.
## Pulls comments from beside commands and prints a nicely formatted
## display with the commands and their usage information.
.DEFAULT_GOAL := help
.PHONY: help
help: ## Prints this help
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| sort \
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'