20
20
endif
21
21
endif
22
22
23
- BINDATA := modules/{options,public,templates}/bindata.go
24
23
GOFILES := $(shell find . -name "* .go" -type f ! -path "./vendor/* " ! -path "* /bindata.go")
25
24
GOFMT ?= gofmt -s
26
25
44
43
LDFLAGS := $(LDFLAGS ) -X "main.Version=$(GITEA_VERSION ) " -X "main.Tags=$(TAGS ) "
45
44
46
45
PACKAGES ?= $(filter-out code.gitea.io/gitea/integrations/migration-test,$(filter-out code.gitea.io/gitea/integrations,$(shell GO111MODULE=on $(GO ) list -mod=vendor ./... | grep -v /vendor/) ) )
47
- SOURCES ?= $(shell find . -name "* .go" -type f)
46
+
47
+ GO_SOURCES ?= $(shell find . -name "* .go" -type f)
48
+ JS_SOURCES ?= $(shell find web_src/js web_src/css -type f)
49
+ CSS_SOURCES ?= $(shell find web_src/less -type f)
50
+
51
+ JS_DEST := public/js/index.js
52
+ CSS_DEST := public/css/index.css
53
+ BINDATA_DEST := modules/public/bindata.go modules/options/bindata.go modules/templates/bindata.go
54
+
55
+ JS_DEST_DIR := public/js
56
+ CSS_DEST_DIR := public/css
48
57
49
58
TMPDIR := ./build-tmp
50
59
@@ -80,10 +89,31 @@ all: build
80
89
81
90
include docker/Makefile
82
91
92
+ .PHONY : go-check
93
+ go-check :
94
+ $(eval GO_VERSION := $(shell printf "% 03d% 03d% 03d" $(shell go version | grep -Eo '[0-9]+\.?[0-9]+?\.?[0-9]?\s' | tr '.' ' ') ;) )
95
+ @if [ " $( GO_VERSION) " -lt " 001011000" ]; then \
96
+ echo " Gitea requires Go 1.11.0 or greater to build. You can get it at https://golang.org/dl/" ; \
97
+ exit 1; \
98
+ fi
99
+
100
+ .PHONY : node-check
101
+ node-check :
102
+ $(eval NODE_VERSION := $(shell printf "% 03d% 03d% 03d" $(shell node -v | grep -Eo '[0-9]+\.?[0-9]+?\.?[0-9]?' | tr '.' ' ') ;) )
103
+ $(eval NPM_MISSING := $(shell hash npm > /dev/null 2>&1 || echo 1) )
104
+ @if [ " $( NODE_VERSION) " -lt " 010000000" -o " $( NPM_MISSING) " = " 1" ]; then \
105
+ echo " Gitea requires Node.js 10.0.0 or greater and npm to build. You can get it at https://nodejs.org/en/download/" ; \
106
+ exit 1; \
107
+ fi
108
+
109
+ .PHONY : clean-all
110
+ clean-all : clean
111
+ rm -rf $(JS_DEST_DIR ) $(CSS_DEST_DIR )
112
+
83
113
.PHONY : clean
84
114
clean :
85
115
GO111MODULE=on $(GO ) clean -mod=vendor -i ./...
86
- rm -rf $(EXECUTABLE ) $(DIST ) $(BINDATA ) \
116
+ rm -rf $(EXECUTABLE ) $(DIST ) $(BINDATA_DEST ) \
87
117
integrations* .test \
88
118
integrations/gitea-integration-pgsql/ integrations/gitea-integration-mysql/ integrations/gitea-integration-mysql8/ integrations/gitea-integration-sqlite/ \
89
119
integrations/gitea-integration-mssql/ integrations/indexers-mysql/ integrations/indexers-mysql8/ integrations/indexers-pgsql integrations/indexers-sqlite \
@@ -309,42 +339,42 @@ bench-pgsql: integrations.pgsql.test generate-ini-pgsql
309
339
integration-test-coverage : integrations.cover.test generate-ini-mysql
310
340
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.cover.test -test.coverprofile=integration.coverage.out
311
341
312
- integrations.mysql.test : $(SOURCES )
342
+ integrations.mysql.test : $(GO_SOURCES )
313
343
GO111MODULE=on $(GO ) test -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.mysql.test
314
344
315
- integrations.mysql8.test : $(SOURCES )
345
+ integrations.mysql8.test : $(GO_SOURCES )
316
346
GO111MODULE=on $(GO ) test -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.mysql8.test
317
347
318
- integrations.pgsql.test : $(SOURCES )
348
+ integrations.pgsql.test : $(GO_SOURCES )
319
349
GO111MODULE=on $(GO ) test -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.pgsql.test
320
350
321
- integrations.mssql.test : $(SOURCES )
351
+ integrations.mssql.test : $(GO_SOURCES )
322
352
GO111MODULE=on $(GO ) test -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.mssql.test
323
353
324
- integrations.sqlite.test : $(SOURCES )
354
+ integrations.sqlite.test : $(GO_SOURCES )
325
355
GO111MODULE=on $(GO ) test -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.sqlite.test -tags ' sqlite sqlite_unlock_notify'
326
356
327
- integrations.cover.test : $(SOURCES )
357
+ integrations.cover.test : $(GO_SOURCES )
328
358
GO111MODULE=on $(GO ) test -mod=vendor -c code.gitea.io/gitea/integrations -coverpkg $(shell echo $(PACKAGES ) | tr ' ' ',') -o integrations.cover.test
329
359
330
360
.PHONY : migrations.mysql.test
331
- migrations.mysql.test : $(SOURCES )
361
+ migrations.mysql.test : $(GO_SOURCES )
332
362
$(GO ) test -c code.gitea.io/gitea/integrations/migration-test -o migrations.mysql.test
333
363
334
364
.PHONY : migrations.mysql8.test
335
- migrations.mysql8.test : $(SOURCES )
365
+ migrations.mysql8.test : $(GO_SOURCES )
336
366
$(GO ) test -c code.gitea.io/gitea/integrations/migration-test -o migrations.mysql8.test
337
367
338
368
.PHONY : migrations.pgsql.test
339
- migrations.pgsql.test : $(SOURCES )
369
+ migrations.pgsql.test : $(GO_SOURCES )
340
370
$(GO ) test -c code.gitea.io/gitea/integrations/migration-test -o migrations.pgsql.test
341
371
342
372
.PHONY : migrations.mssql.test
343
- migrations.mssql.test : $(SOURCES )
373
+ migrations.mssql.test : $(GO_SOURCES )
344
374
$(GO ) test -c code.gitea.io/gitea/integrations/migration-test -o migrations.mssql.test
345
375
346
376
.PHONY : migrations.sqlite.test
347
- migrations.sqlite.test : $(SOURCES )
377
+ migrations.sqlite.test : $(GO_SOURCES )
348
378
$(GO ) test -c code.gitea.io/gitea/integrations/migration-test -o migrations.sqlite.test -tags ' sqlite sqlite_unlock_notify'
349
379
350
380
.PHONY : check
@@ -354,14 +384,20 @@ check: test
354
384
install : $(wildcard * .go)
355
385
$(GO ) install -v -tags ' $(TAGS)' -ldflags ' -s -w $(LDFLAGS)'
356
386
387
+ .PHONY : go
388
+ go : go-check $(EXECUTABLE )
389
+
390
+ .PHONY : go-all
391
+ go-all : go-check generate go
392
+
357
393
.PHONY : build
358
- build : $( EXECUTABLE )
394
+ build : js css go-all
359
395
360
- $(EXECUTABLE ) : $(SOURCES )
396
+ $(EXECUTABLE ) : $(GO_SOURCES )
361
397
GO111MODULE=on $(GO ) build -mod=vendor $(GOFLAGS ) $(EXTRA_GOFLAGS ) -tags ' $(TAGS)' -ldflags ' -s -w $(LDFLAGS)' -o $@
362
398
363
399
.PHONY : release
364
- release : release-dirs release-windows release-linux release-darwin release-copy release-compress release-check
400
+ release : generate release-dirs release-windows release-linux release-darwin release-copy release-compress release-check
365
401
366
402
.PHONY : release-dirs
367
403
release-dirs :
@@ -412,37 +448,30 @@ release-compress:
412
448
fi
413
449
cd $(DIST ) /release/; for file in ` find . -type f -name " *" ` ; do echo " compressing $$ {file}" && gxz -k -9 $$ {file}; done ;
414
450
415
- npm-check :
416
- @hash npm > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
417
- echo " Please install Node.js 8.x or greater with npm" ; \
418
- exit 1; \
419
- fi ;
420
- @hash npx > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
421
- echo " Please install Node.js 8.x or greater with npm" ; \
422
- exit 1; \
423
- fi ;
424
-
425
- .PHONY : npm
426
- npm : npm-check
427
- test -d node_modules/.bin || npm install --no-save
451
+ node_modules : package-lock.json
452
+ npm install --no-save
428
453
429
454
.PHONY : npm-update
430
- npm-update : npm -check
455
+ npm-update : node -check node_modules
431
456
npx updates -cu
432
457
rm -rf node_modules package-lock.json
433
458
npm install --package-lock
434
459
435
460
.PHONY : js
436
- js : npm
461
+ js : node-check $(JS_DEST )
462
+
463
+ $(JS_DEST ) : node_modules $(JS_SOURCES )
437
464
npx eslint web_src/js webpack.config.js
438
465
npx webpack
439
466
440
467
.PHONY : css
441
- css : npm
468
+ css : node-check $(CSS_DEST )
469
+
470
+ $(CSS_DEST ) : node_modules $(CSS_SOURCES )
442
471
npx stylelint web_src/less
443
- npx lessc --clean-css= " --s0 -b " web_src/less/index.less public/css/index.css
444
- $(foreach file, $(filter-out web_src/less/themes/_base.less, $(wildcard web_src/less/themes/* ) ) ,npx lessc --clean-css="--s0 -b" web_src/less/themes/$(notdir $(file ) ) > public/css/theme-$(notdir $(call strip-suffix,$(file ) ) ) .css;)
445
- npx postcss --use autoprefixer --no-map --replace public/css/*
472
+ npx lessc web_src/less/index.less public/css/index.css
473
+ $(foreach file, $(filter-out web_src/less/themes/_base.less, $(wildcard web_src/less/themes/* ) ) ,npx lessc web_src/less/themes/$(notdir $(file ) ) > public/css/theme-$(notdir $(call strip-suffix,$(file ) ) ) .css;)
474
+ npx postcss --use autoprefixer --use cssnano -- no-map --replace public/css/*
446
475
447
476
.PHONY : javascripts
448
477
javascripts :
0 commit comments