This repository has been archived by the owner on Oct 26, 2023. It is now read-only.
forked from kingland/go-v8
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
141 lines (105 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
### Makefile for go-v8
# Ensure GOARCH is set before running build process.
ifeq "$(GOARCH)" ""
$(error Please set the environment variable GOARCH before running `make`)
endif
# Ensure GOOS is set before running build process.
ifeq "$(GOOS)" ""
$(error Please set the environment variable GOOS before running `make`)
endif
# Ensure GOROOT is set before running build process.
ifeq "$(GOROOT)" ""
$(error Please set the environment variable GOROOT before running `make`)
endif
goroot_bin := $(addsuffix /bin,$(subst :,/bin:,$(GOROOT)))
export PATH := $(goroot_bin):$(PATH)
# Ensure GOPATH is set before running build process.
ifeq "$(GOPATH)" ""
$(error Please set the environment variable GOPATH before running `make`)
endif
export GOBIN := $(CURDIR)/../bin
export PATH := $(GOBIN):$(PATH)
export GODEBUG=cgocheck=0
# After version 4, `make` could follow modified `PATH` to find
GO := go
GOVET := go tool vet
GOLINT := golint
GOGET := go get
GOLEX := golex
GOYACC := goyacc
GOINSTALL := go install
GOTEST := go test
GOCLEAN := go clean
GOBUILD := go build
GOPKG := $(CURDIR)/../pkg
PACKAGES := $$(go list ./... | grep -vE 'vendor/' | grep -vE 'cmd/' | grep -vE 'github.com' | grep -vE 'test/')
LINT_PACKAGES := $$(go list ./... | grep -vE 'vendor/' | grep -vE 'cmd/' | grep -vE 'github.com' | grep -vE 'yacc' | grep -vE 'test/')
TEST_PACKAGES := $$(go list ./... | grep -vE 'vendor/' | grep -vE 'cmd/' | grep -vE 'github.com' | grep -vE 'test/')
CLEAN_PACKAGES := $$(go list ./... | grep -vE 'vendor/' | grep -vE 'cmd/')
TEST_GREP := | grep -vE 'no test files'
TARGET = ""
.PHONY: all get debug release race build install clean test lint vet fmt testrace testv count $(COMMANDS)
all: release
debug: build vet lint test errcheck
release: FLAGS = -tags "release"
release: clean version build
race: FLAGS = --race
race: clean build
detail: FLAGS = -x
detail: build
build: lib
lib:
@go version
$(GOINSTALL) $(FLAGS) $(PACKAGES)
get:
glide install
count:
cloc --exclude-dir=vendor,yacc,test .
lint:
$(GOLINT) ./... $(LINT_GREP)
fmt:
@echo "gofmt (simplify)"
vet:
$(GOVET) -all $(LINT_PACKAGES) 2>&1 | grep -vE 'yacc' | awk '{print} END{if(NR>0) {exit 1}}'
errcheck:
errcheck -blank $(LINT_PACKAGES) $(ERR_GREP)
clean:
$(GOCLEAN) -i $(CLEAN_PACKAGES)
test:
$(GOTEST) -cover $(TEST_PACKAGES) $(TEST_GREP)
testv:
$(GOTEST) -v -cover $(TEST_PACKAGES) $(TEST_GREP)
testrace:
$(GOTEST) --race -cover $(TEST_PACKAGES) $(TEST_GREP)
yacc:
$(GOYACC) -o $(YACC_DIR)/parser.go $(YACC_DIR)/parser.y
rm -f $(TEMP_FILE)
rm -f y.output
@sed -i -e 's|//line.*||' -e 's/yyEofCode/yyEOFCode/' $(YACC_DIR)/parser.go;
$(GOLEX) -o $(YACC_DIR)/scanner.go $(YACC_DIR)/scanner.l
@awk 'BEGIN{print "// Code generated by goyacc"} {print $0}' $(YACC_DIR)/parser.go > tmp_parser.go && mv tmp_parser.go $(YACC_DIR)/parser.go;
@awk 'BEGIN{print "// Code generated by goyacc"} {print $0}' $(YACC_DIR)/scanner.go > tmp_scanner.go && mv tmp_scanner.go $(YACC_DIR)/scanner.go;
help:
@echo "Makefile for go-v8 version 1.0"
@echo
@echo "usage: make [target]"
@echo 'targets:'
@echo " help print this info"
@echo " all build and lint"
@echo " release build a release version"
@echo " debug build a debug version"
@echo " race build a data race check version"
@echo " detail build with detail information."
@echo " build build the go-v8"
@echo " count count the source code line"
@echo " lint golint check source code syntax"
@echo " vet go vet check source code bugs"
@echo " errcheck errcheck check not processed return error"
@echo " get install project's dependencies"
@echo " clean clean the build result"
@echo " test run go unit test cases"
@echo " testv run go unit test cases with print console output"
@echo " testrace run go unit test cases with race"
@echo " yacc generate sql parser go from yacc and lex file"
@echo
@echo "Report bugs to <[email protected]>."