forked from mattermost/mattermost-push-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
87 lines (61 loc) · 1.79 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
.PHONY: all dist dist-local dist-travis start-docker build-server package build-client test travis-init build-container stop-docker clean-docker clean nuke run stop setup-mac cleandb docker-build docker-run
GOPATH ?= $(GOPATH:)
GOFLAGS ?= $(GOFLAGS:)
BUILD_NUMBER ?= $(BUILD_NUMBER:)
BUILD_DATE = $(shell date -u)
BUILD_HASH = $(shell git rev-parse HEAD)
GO=$(GOPATH)/bin/godep go
ifeq ($(BUILD_NUMBER),)
BUILD_NUMBER := dev
endif
ifeq ($(TRAVIS_BUILD_NUMBER),)
BUILD_NUMBER := dev
else
BUILD_NUMBER := $(TRAVIS_BUILD_NUMBER)
endif
DIST_ROOT=dist
DIST_PATH=$(DIST_ROOT)/matter-push-proxy
TESTS=.
all: dist
dist: | build-server test package
build-server: | .prepare
@echo Building proxy push server
rm -Rf $(DIST_ROOT)
$(GO) clean $(GOFLAGS) -i ./...
@echo GOFMT
$(eval GOFMT_OUTPUT := $(shell gofmt -d -s server/ main.go 2>&1))
@echo "$(GOFMT_OUTPUT)"
@if [ ! "$(GOFMT_OUTPUT)" ]; then \
echo "gofmt sucess"; \
else \
echo "gofmt failure"; \
exit 1; \
fi
$(GO) build $(GOFLAGS) ./...
$(GO) install $(GOFLAGS) ./...
package:
@ echo Packaging push proxy
mkdir -p $(DIST_PATH)/bin
cp $(GOPATH)/bin/push-proxy $(DIST_PATH)/bin
cp -RL config $(DIST_PATH)/config
touch $(DIST_PATH)/config/build.txt
echo $(BUILD_NUMBER) | tee -a $(DIST_PATH)/config/build.txt
mkdir -p $(DIST_PATH)/logs
cp LICENSE.txt $(DIST_PATH)
cp NOTICE.txt $(DIST_PATH)
cp README.md $(DIST_PATH)
tar -C dist -czf $(DIST_PATH).tar.gz matter-push-proxy
test:
$(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=180s ./server || exit 1
clean:
rm -Rf $(DIST_ROOT)
go clean $(GOFLAGS) -i ./...
rm -rf Godeps/_workspace/pkg/
rm -f .prepare
.prepare:
@echo Preparation for run step
go get $(GOFLAGS) github.com/tools/godep
touch $@
run: .prepare
@echo Starting go web server
$(GO) run $(GOFLAGS) main.go