Skip to content

Commit

Permalink
aviod multi package collision & refine (pingcap#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
silentsai authored and holys committed Mar 16, 2018
1 parent 5426c8c commit 04b0598
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ ifeq "$(GOPATH)" ""
$(error Please set the environment variable GOPATH before running `make`)
endif

LIGHTNING_BIN := bin/tidb-lightning

TIDBDIR := $(GOPATH)/src/github.com/pingcap/tidb/
path_to_add := $(addsuffix /bin,$(subst :,/bin:,$(GOPATH)))
export PATH := $(path_to_add):$(PATH)
Expand All @@ -28,13 +30,20 @@ TARGET = ""

.PHONY: all build parser clean parserlib

default: lightning buildsucc
default: clean lightning checksuccess

build:
$(GOBUILD)

buildsucc:
@echo Build Lightning Successfully!
clean:
$(GO) clean -i ./...
rm -f $(LIGHTNING_BIN)

checksuccess:
@if [ -f $(LIGHTNING_BIN) ]; \
then \
echo "Lightning build successfully :-) !" ; \
fi

goyacc:
$(GOBUILD) -o $(TIDBDIR)/bin/goyacc $(TIDBDIR)/parser/goyacc/main.go
Expand All @@ -60,11 +69,13 @@ parserlib: parser/parser.go
parser/parser.go: $(TIDBDIR)/parser/parser.y
make parser

RACE_FLAG =
RACE_FLAG =
ifeq ("$(WITH_RACE)", "1")
RACE_FLAG = -race
GOBUILD = GOPATH=$(TIDBDIR)/_vendor:$(GOPATH) CGO_ENABLED=1 $(GO) build
endif

lightning: parserlib
$(GOBUILD) $(RACE_FLAG) -o bin/tidb-lightning cmd/main.go
@mv $(TIDBDIR)/vendor/golang.org/x/net/trace $(TIDBDIR)/vendor/golang.org/x/net/_trace
-$(GOBUILD) $(RACE_FLAG) -o $(LIGHTNING_BIN) cmd/main.go
@mv $(TIDBDIR)/vendor/golang.org/x/net/_trace $(TIDBDIR)/vendor/golang.org/x/net/trace

0 comments on commit 04b0598

Please sign in to comment.