forked from xingetouzi/dyupdater
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
64 lines (50 loc) · 1.77 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
LINUXGOPATH = $(shell cd $${GOPATH} ;pwd)
# In windows git bash, turn GOPATH to linux path style
BIN = $(GOPATH)/bin
ON = $(BIN)/on
GO_BINDATA = $(BIN)/go-bindata
NODE_BIN = $(shell npm bin)
PID = .pid
GO_FILES = $(filter-out server/server/bindata.go, $(shell find ./server -type f -name "*.go"))
TEMPLATES = $(wildcard server/data/templates/*.html)
BINDATA = server/server/bindata.go
BINDATA_FLAGS = -pkg=server -prefix=client/dist -nomemcopy
IMPORT_PATH = $(shell pwd | sed "s|^$(LINUXGOPATH)/src/||g")
STATICS = client/dist
APP_NAME = $(shell pwd | sed 's:.*/::')
TARGET = $(APP_NAME)
GIT_HASH = $(shell git rev-parse HEAD)
LDFLAGS = -w -X main.commitHash=$(GIT_HASH)
build: $(ON) $(GO_BINDATA) clean $(TARGET)
clean:
@rm -rf client/dist
@rm -rf $(BINDATA)
$(ON):
go install $(IMPORT_PATH)/vendor/github.com/olebedev/on
$(GO_BINDATA):
go install $(IMPORT_PATH)/vendor/github.com/jteeuwen/go-bindata/...
$(STATICS):
@cd client && npm run build
$(TARGET): $(BINDATA)
go build -ldflags '$(LDFLAGS)' -o $@ $(IMPORT_PATH)/server
kill:
@kill `cat $(PID)` || true
serve: $(ON) $(GO_BINDATA) clean $(BUNDLE) restart
@BABEL_ENV=dev node hot.proxy &
@$(NODE_BIN)/webpack --watch &
@$(ON) -m 2 $(GO_FILES) $(TEMPLATES) | xargs -n1 -I{} make restart || make kill
restart: BINDATA_FLAGS += -debug
restart: LDFLAGS += -X main.debug=true
restart: $(BINDATA) kill $(TARGET)
@echo restart the app...
@$(TARGET) run & echo $$! > $(PID)
$(BINDATA): $(STATICS) $(GO_BINDATA)
$(GO_BINDATA) $(BINDATA_FLAGS) -o=$@ client/dist/...
lint:
@cd client && npm run lint || true
@golint server/... || true
install: install-client install-server
install-client:
@cd client && yarn install
install-server:
@dep ensure -v