1
1
DIST := dist
2
2
IMPORT := code.gitea.io/gitea
3
3
4
+ GO ?= go
4
5
SED_INPLACE := sed -i
5
6
6
7
ifeq ($(OS ) , Windows_NT)
@@ -24,7 +25,7 @@ EXTRA_GOFLAGS ?=
24
25
25
26
LDFLAGS := -X "main.Version=$(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//') " -X "main.Tags=$(TAGS ) "
26
27
27
- PACKAGES ?= $(filter-out code.gitea.io/gitea/integrations,$(shell go list ./... | grep -v /vendor/) )
28
+ PACKAGES ?= $(filter-out code.gitea.io/gitea/integrations,$(shell $( GO ) list ./... | grep -v /vendor/) )
28
29
SOURCES ?= $(shell find . -name "* .go" -type f)
29
30
30
31
TAGS ?=
@@ -52,31 +53,31 @@ all: build
52
53
53
54
.PHONY : clean
54
55
clean :
55
- go clean -i ./...
56
+ $( GO ) clean -i ./...
56
57
rm -rf $(EXECUTABLE ) $(DIST ) $(BINDATA )
57
58
58
59
required-gofmt-version :
59
- @go version | grep -q ' \(1.7\|1.8\)' || { echo " We require go version 1.7 or 1.8 to format code" >&2 && exit 1; }
60
+ @$( GO ) version | grep -q ' \(1.7\|1.8\)' || { echo " We require go version 1.7 or 1.8 to format code" >&2 && exit 1; }
60
61
61
62
.PHONY : fmt
62
63
fmt : required-gofmt-version
63
64
$(GOFMT ) -w $(GOFILES )
64
65
65
66
.PHONY : vet
66
67
vet :
67
- go vet $(PACKAGES )
68
+ $( GO ) vet $(PACKAGES )
68
69
69
70
.PHONY : generate
70
71
generate :
71
72
@hash go-bindata > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
72
- go get -u github.com/jteeuwen/go-bindata/...; \
73
+ $( GO ) get -u github.com/jteeuwen/go-bindata/...; \
73
74
fi
74
- go generate $(PACKAGES )
75
+ $( GO ) generate $(PACKAGES )
75
76
76
77
.PHONY : generate-swagger
77
78
generate-swagger :
78
79
@hash swagger > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
79
- go get -u github.com/go-swagger/go-swagger/cmd/swagger; \
80
+ $( GO ) get -u github.com/go-swagger/go-swagger/cmd/swagger; \
80
81
fi
81
82
swagger generate spec -o ./public/swagger.v1.json
82
83
$(SED_INPLACE ) " s;\" .ref\" : \" #/definitions/GPGKey\" ;\" type\" : \" object\" ;g" ./public/swagger.v1.json
@@ -85,28 +86,28 @@ generate-swagger:
85
86
.PHONY : errcheck
86
87
errcheck :
87
88
@hash errcheck > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
88
- go get -u github.com/kisielk/errcheck; \
89
+ $( GO ) get -u github.com/kisielk/errcheck; \
89
90
fi
90
91
errcheck $(PACKAGES )
91
92
92
93
.PHONY : lint
93
94
lint :
94
95
@hash golint > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
95
- go get -u github.com/golang/lint/golint; \
96
+ $( GO ) get -u github.com/golang/lint/golint; \
96
97
fi
97
98
for PKG in $( PACKAGES) ; do golint -set_exit_status $$ PKG || exit 1; done ;
98
99
99
100
.PHONY : misspell-check
100
101
misspell-check :
101
102
@hash misspell > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
102
- go get -u github.com/client9/misspell/cmd/misspell; \
103
+ $( GO ) get -u github.com/client9/misspell/cmd/misspell; \
103
104
fi
104
105
misspell -error -i unknwon $(GOFILES )
105
106
106
107
.PHONY : misspell
107
108
misspell :
108
109
@hash misspell > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
109
- go get -u github.com/client9/misspell/cmd/misspell; \
110
+ $( GO ) get -u github.com/client9/misspell/cmd/misspell; \
110
111
fi
111
112
misspell -w -i unknwon $(GOFILES )
112
113
@@ -122,12 +123,12 @@ fmt-check: required-gofmt-version
122
123
123
124
.PHONY : test
124
125
test : fmt-check
125
- go test $(PACKAGES )
126
+ $( GO ) test $(PACKAGES )
126
127
127
128
.PHONY : test-coverage
128
129
test-coverage : unit-test-coverage integration-test-coverage
129
130
@hash gocovmerge > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
130
- go get -u github.com/wadey/gocovmerge; \
131
+ $( GO ) get -u github.com/wadey/gocovmerge; \
131
132
fi
132
133
for PKG in $( PACKAGES) ; do\
133
134
touch $$ GOPATH/src/$$ PKG/coverage.out; \
@@ -139,12 +140,12 @@ test-coverage: unit-test-coverage integration-test-coverage
139
140
140
141
.PHONY : unit-test-coverage
141
142
unit-test-coverage :
142
- for PKG in $( PACKAGES) ; do go test -cover -coverprofile $$ GOPATH/src/$$ PKG/coverage.out $$ PKG || exit 1; done ;
143
+ for PKG in $( PACKAGES) ; do $( GO ) test -cover -coverprofile $$ GOPATH/src/$$ PKG/coverage.out $$ PKG || exit 1; done ;
143
144
144
145
.PHONY : test-vendor
145
146
test-vendor :
146
147
@hash govendor > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
147
- go get -u github.com/kardianos/govendor; \
148
+ $( GO ) get -u github.com/kardianos/govendor; \
148
149
fi
149
150
govendor list +unused | tee " $( TMPDIR) /wc-gitea-unused"
150
151
[ $$ (cat " $( TMPDIR) /wc-gitea-unused" | wc -l) -eq 0 ] || echo " Warning: /!\\ Some vendor are not used /!\\ "
@@ -185,26 +186,26 @@ integration-test-coverage: integrations.cover.test
185
186
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.cover.test -test.coverprofile=integration.coverage.out
186
187
187
188
integrations.test : $(SOURCES )
188
- go test -c code.gitea.io/gitea/integrations
189
+ $( GO ) test -c code.gitea.io/gitea/integrations
189
190
190
191
integrations.sqlite.test : $(SOURCES )
191
- go test -c code.gitea.io/gitea/integrations -o integrations.sqlite.test -tags ' sqlite'
192
+ $( GO ) test -c code.gitea.io/gitea/integrations -o integrations.sqlite.test -tags ' sqlite'
192
193
193
194
integrations.cover.test : $(SOURCES )
194
- go test -c code.gitea.io/gitea/integrations -coverpkg $(shell echo $(PACKAGES ) | tr ' ' ',') -o integrations.cover.test
195
+ $( GO ) test -c code.gitea.io/gitea/integrations -coverpkg $(shell echo $(PACKAGES ) | tr ' ' ',') -o integrations.cover.test
195
196
196
197
.PHONY : check
197
198
check : test
198
199
199
200
.PHONY : install
200
201
install : $(wildcard * .go)
201
- go install -v -tags ' $(TAGS)' -ldflags ' -s -w $(LDFLAGS)'
202
+ $( GO ) install -v -tags ' $(TAGS)' -ldflags ' -s -w $(LDFLAGS)'
202
203
203
204
.PHONY : build
204
205
build : $(EXECUTABLE )
205
206
206
207
$(EXECUTABLE ) : $(SOURCES )
207
- go build $(GOFLAGS ) $(EXTRA_GOFLAGS ) -tags ' $(TAGS)' -ldflags ' -s -w $(LDFLAGS)' -o $@
208
+ $( GO ) build $(GOFLAGS ) $(EXTRA_GOFLAGS ) -tags ' $(TAGS)' -ldflags ' -s -w $(LDFLAGS)' -o $@
208
209
209
210
.PHONY : docker
210
211
docker :
@@ -221,7 +222,7 @@ release-dirs:
221
222
.PHONY : release-windows
222
223
release-windows :
223
224
@hash xgo > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
224
- go get -u github.com/karalabe/xgo; \
225
+ $( GO ) get -u github.com/karalabe/xgo; \
225
226
fi
226
227
xgo -dest $(DIST ) /binaries -tags ' netgo $(TAGS)' -ldflags ' -linkmode external -extldflags "-static" $(LDFLAGS)' -targets ' windows/*' -out gitea-$(VERSION ) .
227
228
ifeq ($(CI ) ,drone)
@@ -231,7 +232,7 @@ endif
231
232
.PHONY : release-linux
232
233
release-linux :
233
234
@hash xgo > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
234
- go get -u github.com/karalabe/xgo; \
235
+ $( GO ) get -u github.com/karalabe/xgo; \
235
236
fi
236
237
xgo -dest $(DIST ) /binaries -tags ' netgo $(TAGS)' -ldflags ' -linkmode external -extldflags "-static" $(LDFLAGS)' -targets ' linux/*' -out gitea-$(VERSION ) .
237
238
ifeq ($(CI ) ,drone)
@@ -241,7 +242,7 @@ endif
241
242
.PHONY : release-darwin
242
243
release-darwin :
243
244
@hash xgo > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
244
- go get -u github.com/karalabe/xgo; \
245
+ $( GO ) get -u github.com/karalabe/xgo; \
245
246
fi
246
247
xgo -dest $(DIST ) /binaries -tags ' netgo $(TAGS)' -ldflags ' $(LDFLAGS)' -targets ' darwin/*' -out gitea-$(VERSION ) .
247
248
ifeq ($(CI ) ,drone)
@@ -278,7 +279,7 @@ stylesheets: public/css/index.css
278
279
.IGNORE : public/css/index.css
279
280
public/css/index.css : $(STYLESHEETS )
280
281
@which lessc > /dev/null; if [ $$ ? -ne 0 ]; then \
281
- go get -u github.com/kib357/less-go/lessc; \
282
+ $( GO ) get -u github.com/kib357/less-go/lessc; \
282
283
fi
283
284
lessc -i $< -o $@
284
285
0 commit comments