forked from ruiaylin/sqlparser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
57 lines (41 loc) · 1.49 KB
/
Copy pathMakefile
File metadata and controls
57 lines (41 loc) · 1.49 KB
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
### Makefile for sqlparser
# Ensure GOPATH is set before running build process.
ifeq "$(GOPATH)" ""
$(error Please set the environment variable GOPATH before running `make`)
endif
path_to_add := $($(GOPATH))
export PATH := $(path_to_add):$(PATH)
GOLEX := golex
GOYACC := goyacc
GOLINT := golint
GO := go
GOBUILD := $(GO) build $(BUILD_FLAG)
GOTEST := $(GO) test -p 3
ARCH := "`uname -s`"
LINUX := "Linux"
MAC := "Darwin"
PACKAGES := $$(go list ./...| grep -vE 'vendor')
.PHONY: parser goyacc golex
all: parser test
golex:
$(GO) get github.com/qiuyesuifeng/golex
goyacc:
$(GOBUILD) -o bin/goyacc parser/goyacc/main.go
packges:
$(GO) get github.com/ruiaylin/sqlparser/util/charset
$(GO) get github.com/qiuyesuifeng/golex
parser: goyacc
bin/goyacc -o /dev/null parser/parser.y
bin/goyacc -o parser/parser.go parser/parser.y 2>&1 | egrep "(shift|reduce)/reduce" | awk '{print} END {if (NR > 0) {print "Find conflict in parser.y. Please check y.output for more information."; exit 1;}}'
rm -f y.output
@if [ $(ARCH) = $(LINUX) ]; \
then \
sed -i -e 's|//line.*||' -e 's/yyEofCode/yyEOFCode/' parser/parser.go; \
elif [ $(ARCH) = $(MAC) ]; \
then \
/usr/bin/sed -i "" 's|//line.*||' parser/parser.go; \
/usr/bin/sed -i "" 's/yyEofCode/yyEOFCode/' parser/parser.go; \
fi
@awk 'BEGIN{print "// Code generated by goyacc"} {print $0}' parser/parser.go > tmp_parser.go && mv tmp_parser.go parser/parser.go;
test:
$(GO) test github.com/ruiaylin/sqlparser/parser