-
Notifications
You must be signed in to change notification settings - Fork 169
/
Makefile
146 lines (123 loc) · 3.44 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
SHELL = 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)
COVER_FILE = /tmp/plik.coverprofile
GO_TEST = GORACE="halt_on_error=1" go test $(BUILD_FLAG) $(BUILD_TAGS) -race -cover -coverprofile=$(COVER_FILE) -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
@MAKEFILE_TARGET="clients" 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 . 2>&1 | grep -v ^vendor` ; \
if [[ -z "$$OUT" ]]; then echo " OK" ; else echo " FAIL"; echo "$$OUT"; FAIL=1 ; fi ;\
echo -n " - go vet :" ; OUT=`go vet ./... 2>&1` ; \
if [[ -z "$$OUT" ]]; then echo " OK" ; else echo " FAIL"; echo "$$OUT"; FAIL=1 ; fi ;\
test $$FAIL -eq 0
###
# Run fmt
###
fmt:
@gofmt -w -s $(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
###
# Open last cover profile in web browser
###
cover:
@if [[ ! -f $(COVER_FILE) ]]; then echo "Please run \"make test\" first to generate a cover profile" ; exit 1; fi
@go tool cover -html=$(COVER_FILE)
@echo "Check your web browser to see the cover profile"
###
# Run integration tests for all available backends
###
test-backends:
@testing/test_backends.sh
###
# Build a docker image locally
###
docker:
@docker buildx build --progress=plain --load -t rootgg/plik:dev .
###
# Create release archives
###
release:
@releaser/release.sh
###
# Create release archives, build a multiarch Docker image and push to Docker Hub
###
release-and-push-to-docker-hub:
@PUSH_TO_DOCKER_HUB=true releaser/release.sh
###
# 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