-
Notifications
You must be signed in to change notification settings - Fork 48
/
Makefile
145 lines (112 loc) · 3.98 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
export GO111MODULE=on
.DEFAULT_GOAL := help
.PHONY: build-parser build test test-parser build-core
.PHONY: install
.PHONY: dep
PWD := $(shell pwd)
PTR := ptr32
##PTR := ptr64
UNAME_S := $(shell uname -s)
ifneq (,$(findstring Linux, $(UNAME_S)))
PLATFORM := LINUX
SUBSYSTEM := LINUX
PACKAGES := PGK_NAMES_LINUX
DISPLAY := :99.0
endif
ifneq (,$(findstring Darwin, $(UNAME_S)))
PLATFORM := MACOS
SUBSYSTEM := MACOS
PACKAGES := PKG_NAMES_MACOS
endif
ifneq (,$(findstring MINGW, $(UNAME_S)))
PLATFORM := WINDOWS
SUBSYSTEM := MINGW
PACKAGES := PKG_NAMES_WINDOWS
endif
ifneq (,$(findstring MSYS, $(UNAME_S)))
PLATFORM := WINDOWS
SUBSYSTEM := MSYS
PACKAGES := PKG_NAMES_WINDOWS
endif
ifeq ($(PLATFORM), WINDOWS)
GOPATH := $(subst \,/,${GOPATH})
HOME := $(subst \,/,${HOME})
CXPATH := $(subst, \,/, ${CXPATH})
CXEXE := cx.exe
else
CXEXE := cx
endif
CXVERSION := $(shell $(PWD)/bin/$(CXEXE) --version 2> /dev/null)
GLOBAL_GOPATH := $(GOPATH)
LOCAL_GOPATH := $(HOME)/go
ifdef GLOBAL_GOPATH
GOPATH := $(GLOBAL_GOPATH)
else
GOPATH := $(LOCAL_GOPATH)
endif
GOLANGCI_LINT_VERSION ?= latest
GO_OPTS ?= -mod=vendor
ifdef CXPATH
CX_PATH := $(CXPATH)
else
CX_PATH := $(HOME)/cx
endif
ifeq ($(UNAME_S), Linux)
endif
build: ## Build CX from sources
$(GO_OPTS) go build -tags="$(PTR) cipher cxfx cxos http regexp" -o ./bin/$(CXEXE) github.com/skycoin/cx/cmd/cx
chmod +x ./bin/$(CXEXE)
build-debug: ## Build CX from sources
$(GO_OPTS) go build -gcflags="all=-N -l" -tags="$(PTR) cipher cxfx cxos http regexp" -o ./bin/$(CXEXE) github.com/skycoin/cx/cmd/cx
chmod +x ./bin/$(CXEXE)
build-core: ## Build CX with CXFX support. Done via satisfying 'cxfx' build tag.
$(GO_OPTS) go build -tags="$(PTR) base" -o ./bin/$(CXEXE) github.com/skycoin/cx/cmd/cx
chmod +x ./bin/$(CXEXE)
build-tests: build-debug
go build -gcflags="all=-N -l" -o ./bin/cxtests github.com/skycoin/cx/cmd/cxtest/
chmod +x ./bin/cxtests
clean: ## Removes binaries.
rm -rf ./bin/cx
rm -rf ./bin/$(CXEXE)
rm -rf ./bin/cxtests
install: configure-workspace ## Install CX from sources. Build dependencies
@echo 'NOTE:\tWe recommend you to test your CX installation by running "$(CXEXE) ./tests"'
./bin/$(CXEXE) -v
test-parser: build-parser build test
test: ## Run CX test suite.
ifndef CXVERSION
@echo "$(CXEXE) not found in $(PWD)/bin, please run make install first"
else
# go test $(GO_OPTS) -race -tags base github.com/skycoin/cx/cxgo/
go run -mod=vendor ./cmd/cxtest/main.go --cxpath=$(PWD)/bin/$(CXEXE) --wdir=./tests --log=fail,stderr --disable-tests=gui,issue
endif
test-all: ## Run CX test suite.
ifndef CXVERSION
@echo "$(CXEXE) not found in $(PWD)/bin, please run make install first"
else
# go test $(GO_OPTS) -race -tags base github.com/skycoin/cx/cxgo/
go run -mod=vendor ./cmd/cxtest/main.go --cxpath=$(PWD)/bin/$(CXEXE) --wdir=./tests --log=fail,stderr
endif
build-goyacc: ## Builds goyacc into /bin/goyacc
go build -o ./bin/goyacc ./cmd/goyacc/main.go
build-parser: ## Generate lexer and parser for CX grammar
#go build -o ./bin/goyacc ./cmd/goyacc/main.go
./bin/goyacc -o cxparser/cxpartialparsing/cxpartialparsing.go cxparser/cxpartialparsing/cxpartialparsing.y
./bin/goyacc -o cxparser/cxparsingcompletor/parsingcompletor.go cxparser/cxparsingcompletor/parsingcompletor.y
token-fuzzer:
go build $(GO_OPTS) -o ./bin/cx-token-fuzzer $(PWD)/development/token-fuzzer/main.go
chmod +x ./bin/cx-token-fuzzer
configure-workspace: ## Configure CX workspace environment
mkdir -p $(CX_PATH)/src $(CX_PATH)/bin $(CX_PATH)/pkg
@echo "NOTE:\tCX workspace at $(CX_PATH)"
format: ## Formats the code. Must have goimports installed (use make install-linters).
goimports -w -local github.com/skycoin/cx ./cmd
goimports -w -local github.com/skycoin/cx ./cx
goimports -w -local github.com/skycoin/cx ./cxfx
goimports -w -local github.com/skycoin/cx ./cxgo
dep: ## Update go vendor
go mod vendor
go mod verify
go mod tidy
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'