Skip to content

Commit 0a51ecb

Browse files
author
LeopPro
authored
Change the package manager to go modules (pingcap#92)
* Change the package manager to go modules * fix module name and add vendor dir * supplement go.mod and .gitignore files * add clean_vendor.sh and rmove unused vendor * fix clean_vendor.sh
1 parent 9fba79d commit 0a51ecb

File tree

532 files changed

+130657
-94401
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

532 files changed

+130657
-94401
lines changed

Makefile

+44-22
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,33 @@ LDFLAGS += -X "github.com/pingcap/tidb-tools/pkg/utils.BuildTS=$(shell date -u '
1616
LDFLAGS += -X "github.com/pingcap/tidb-tools/pkg/utils.GitHash=$(shell git rev-parse HEAD)"
1717

1818
CURDIR := $(shell pwd)
19-
GO := GO15VENDOREXPERIMENT="1" go
19+
GO := GO15VENDOREXPERIMENT="1" GO111MODULE=on go
2020
GOTEST := CGO_ENABLED=1 $(GO) test -p 3
2121
PACKAGES := $$(go list ./... | grep -vE 'vendor')
2222
FILES := $$(find . -name '*.go' -type f | grep -vE 'vendor')
23+
VENDOR_TIDB := vendor/github.com/pingcap/tidb
2324

2425

2526
build: check test importer checker dump_region binlogctl sync_diff_inspector
2627

27-
importer:
28-
$(GO) build -ldflags '$(LDFLAGS)' -o bin/importer ./importer
28+
importer: parserlib
29+
$(GO) build -ldflags '$(LDFLAGS)' -mod=vendor -o bin/importer ./importer
2930

30-
checker:
31-
$(GO) build -ldflags '$(LDFLAGS)' -o bin/checker ./checker
31+
checker: parserlib
32+
$(GO) build -ldflags '$(LDFLAGS)' -mod=vendor -o bin/checker ./checker
3233

33-
dump_region:
34-
$(GO) build -ldflags '$(LDFLAGS)' -o bin/dump_region ./dump_region
34+
dump_region: parserlib
35+
$(GO) build -ldflags '$(LDFLAGS)' -mod=vendor -o bin/dump_region ./dump_region
3536

36-
binlogctl:
37-
$(GO) build -ldflags '$(LDFLAGS)' -o bin/binlogctl ./tidb_binlog/binlogctl
37+
binlogctl: parserlib
38+
$(GO) build -ldflags '$(LDFLAGS)' -mod=vendor -o bin/binlogctl ./tidb_binlog/binlogctl
3839

39-
sync_diff_inspector:
40-
$(GO) build -ldflags '$(LDFLAGS)' -o bin/sync_diff_inspector ./sync_diff_inspector
40+
sync_diff_inspector: parserlib
41+
$(GO) build -ldflags '$(LDFLAGS)' -mod=vendor -o bin/sync_diff_inspector ./sync_diff_inspector
4142

42-
test:
43+
test: parserlib
4344
@export log_level=error; \
44-
$(GOTEST) -cover $(PACKAGES)
45+
$(GOTEST) -cover $(PACKAGES) -mod=vendor
4546

4647
fmt:
4748
go fmt ./...
@@ -59,13 +60,34 @@ check:
5960
@ gofmt -s -l -w $(FILES) 2>&1 | awk '{print} END{if(NR>0) {exit 1}}'
6061

6162
update:
62-
which glide >/dev/null || curl https://glide.sh/get | sh
63-
which glide-vc || go get -v -u github.com/sgotti/glide-vc
64-
ifdef PKG
65-
glide get -s -v --skip-test ${PKG}
66-
else
67-
glide update -s -v -u --skip-test
68-
endif
69-
@echo "removing test files"
70-
glide vc --use-lock-file --only-code --no-tests
63+
make vendor
64+
65+
goyacc:
66+
$(GO) get github.com/pingcap/tidb/parser/goyacc
67+
68+
parser: goyacc
69+
goyacc -o /dev/null $(VENDOR_TIDB)/parser/parser.y
70+
goyacc -o $(VENDOR_TIDB)/parser/parser.go $(VENDOR_TIDB)/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;}}'
71+
rm -f y.output
72+
73+
@if [ $(ARCH) = $(LINUX) ]; \
74+
then \
75+
sed -i -e 's|//line.*||' -e 's/yyEofCode/yyEOFCode/' $(VENDOR_TIDB)/parser/parser.go; \
76+
elif [ $(ARCH) = $(MAC) ]; \
77+
then \
78+
/usr/bin/sed -i "" 's|//line.*||' $(VENDOR_TIDB)/parser/parser.go; \
79+
/usr/bin/sed -i "" 's/yyEofCode/yyEOFCode/' $(VENDOR_TIDB)/parser/parser.go; \
80+
fi
81+
82+
@awk 'BEGIN{print "// Code generated by goyacc"} {print $0}' $(VENDOR_TIDB)/parser/parser.go > tmp_parser.go && mv tmp_parser.go $(VENDOR_TIDB)/parser/parser.go;
83+
84+
parserlib: $(VENDOR_TIDB)/parser/parser.go
85+
86+
$(VENDOR_TIDB)/parser/parser.go: $(VENDOR_TIDB)/parser/parser.y
87+
make parser
88+
89+
$(VENDOR_TIDB)/parser/parser.y: vendor
7190

91+
vendor:
92+
$(GO) mod vendor
93+
sh ./hack/clean_vendor.sh

0 commit comments

Comments
 (0)