forked from root-gg/plik
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
132 lines (112 loc) · 3.11 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
SHELL = /bin/bash
BUILD_INFO = $(shell server/gen_build_info.sh base64)
BUILD_FLAG = -ldflags="-X github.com/root-gg/plik/server/common.buildInfoString=$(BUILD_INFO) -w -s -extldflags=-static"
BUILD_TAGS = -tags osusergo,netgo,sqlite_omit_load_extension
GO_BUILD = go build $(BUILD_FLAG) $(BUILD_TAGS)
GO_TEST = GORACE="halt_on_error=1" go test $(BUILD_FLAG) $(BUILD_TAGS) -race -cover -p 1
ifdef ENABLE_RACE_DETECTOR
GO_BUILD := GORACE="halt_on_error=1" $(GO_BUILD) -race
endif
all: clean clean-frontend frontend clients server
###
# Build frontend ressources
###
frontend:
@if [ ! -d webapp/node_modules ]; then cd webapp && npm install ; fi
@if [ ! -d webapp/bower_components ]; then cd webapp && node_modules/bower/bin/bower install --allow-root ; fi
@cd webapp && node_modules/grunt-cli/bin/grunt
###
# Build plik server for the current architecture
###
server:
@server/gen_build_info.sh info
@echo "Building Plik server"
@cd server && $(GO_BUILD) -o plikd
###
# Build plik client for the current architecture
###
client:
@server/gen_build_info.sh info
@echo "Building Plik client"
@cd client && $(GO_BUILD) -o plik ./
###
# Build clients for all architectures
###
clients:
# Only build clients
@TARGETS="skip" releaser/releaser.sh
###
# Display build info
###
build-info:
@server/gen_build_info.sh info
###
# Display version
###
version:
@server/gen_build_info.sh version
###
# Run linters
###
lint:
@FAIL=0 ;echo -n " - go fmt :" ; OUT=`gofmt -l . | grep -v ^vendor` ; \
if [[ -z "$$OUT" ]]; then echo " OK" ; else echo " FAIL"; echo "$$OUT"; FAIL=1 ; fi ;\
echo -n " - go vet :" ; OUT=`go vet ./...` ; \
if [[ -z "$$OUT" ]]; then echo " OK" ; else echo " FAIL"; echo "$$OUT"; FAIL=1 ; fi ;\
echo -n " - go lint :" ; OUT=`golint ./... | grep -v ^vendor` ; \
if [[ -z "$$OUT" ]]; then echo " OK" ; else echo " FAIL"; echo "$$OUT"; FAIL=1 ; fi ;\
test $$FAIL -eq 0
###
# Run fmt
###
fmt:
@goimports -w -l -local "github.com/root-gg/plik" $(shell find . -type f -name '*.go' -not -path "./vendor/*")
###
# Run tests
###
test:
@if curl -s 127.0.0.1:8080 > /dev/null ; then echo "Plik server probably already running" && exit 1 ; fi
@$(GO_TEST) ./... 2>&1 | grep -v "no test files"; test $${PIPESTATUS[0]} -eq 0
@echo "cli client integration tests :" && cd client && ./test.sh
###
# Run integration tests for all available backends
###
test-backends:
@testing/test_backends.sh
###
# release
###
release:
@releaser/release.sh
###
# docker
###
docker:
@docker build -t rootgg/plik:dev --build-arg "TARGETS=amd64" --target="plik-amd64" .
###
# Remove server build files
###
clean:
@rm -rf server/plikd
@rm -rf client/plik
@rm -rf clients
@rm -rf servers
@rm -rf release
@rm -rf releases
###
# Remove frontend build files
###
clean-frontend:
@rm -rf webapp/bower_components
@rm -rf webapp/dist
###
# Remove all build files and node modules
###
clean-all: clean clean-frontend
@rm -rf webapp/node_modules
###
# Since the client/server/version directories are not generated
# by make, we must declare these targets as phony to avoid :
# "make: `client' is up to date" cases at compile time
###
.PHONY: client clients server release