/
Makefile
110 lines (85 loc) · 2.71 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
export GO111MODULE=on
.DEFAULT_GOAL := help
.PHONY: build-parser build test
.PHONY: install
.PHONY: dep
PWD := $(shell pwd)
UNAME_S := $(shell uname -s)
CXVERSION := $(shell $(PWD)/bin/cx --version 2> /dev/null)
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})
endif
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 build $(GO_OPTS) -tags="base" -o ./bin/cx github.com/skycoin/cx/cmd/cx
chmod +x ./bin/cx
clean: ## Removes binaries.
rm -r ./bin/cx
token-fuzzer:
go build $(GO_OPTS) -o ./bin/cx-token-fuzzer $(PWD)/development/token-fuzzer/main.go
chmod +x ${GOPATH}/bin/cx-token-fuzzer
build-parser: ## Generate lexer and parser for CX grammar
./bin/goyacc -o cxgo/cxgo0/cxgo0.go cxgo/cxgo0/cxgo0.y
./bin/goyacc -o cxgo/parser/cxgo.go cxgo/parser/cxgo.y
install: configure-workspace ## Install CX from sources. Build dependencies
@echo 'NOTE:\tWe recommend you to test your CX installation by running "cx ./tests"'
./bin/cx -v
test: ## Run CX test suite.
ifndef CXVERSION
@echo "cx not found in $(PWD)/bin, please run make install first"
else
# go test $(GO_OPTS) -race -tags base github.com/skycoin/cx/cxgo/
./bin/cx ./lib/args.cx ./tests/main.cx ++wdir=./tests ++disable-tests=gui,issue ++cxpath=$(PWD)/bin/cx
endif
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 $(GO_OPTS) vendor
go mod $(GO_OPTS) verify
go mod $(GO_OPTS) tidy
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'