Fork to maintain patches against the official gitea for https://code.ceondo.com https://github.com/go-gitea/gitea

Makefile 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. DIST := dist
  2. IMPORT := code.gitea.io/gitea
  3. ifeq ($(OS), Windows_NT)
  4. EXECUTABLE := gitea.exe
  5. else
  6. EXECUTABLE := gitea
  7. endif
  8. BINDATA := modules/{options,public,templates}/bindata.go
  9. STYLESHEETS := $(wildcard public/less/index.less public/less/_*.less)
  10. JAVASCRIPTS :=
  11. GOFLAGS := -i -v
  12. EXTRA_GOFLAGS ?=
  13. LDFLAGS := -X "main.Version=$(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')" -X "main.Tags=$(TAGS)"
  14. PACKAGES ?= $(filter-out code.gitea.io/gitea/integrations,$(shell go list ./... | grep -v /vendor/))
  15. SOURCES ?= $(shell find . -name "*.go" -type f)
  16. TAGS ?=
  17. ifneq ($(DRONE_TAG),)
  18. VERSION ?= $(subst v,,$(DRONE_TAG))
  19. else
  20. ifneq ($(DRONE_BRANCH),)
  21. VERSION ?= $(subst release/v,,$(DRONE_BRANCH))
  22. else
  23. VERSION ?= master
  24. endif
  25. endif
  26. .PHONY: all
  27. all: build
  28. .PHONY: clean
  29. clean:
  30. go clean -i ./...
  31. rm -rf $(EXECUTABLE) $(DIST) $(BINDATA)
  32. .PHONY: fmt
  33. fmt:
  34. find . -name "*.go" -type f -not -path "./vendor/*" | xargs gofmt -s -w
  35. .PHONY: vet
  36. vet:
  37. go vet $(PACKAGES)
  38. .PHONY: generate
  39. generate:
  40. @hash go-bindata > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  41. go get -u github.com/jteeuwen/go-bindata/...; \
  42. fi
  43. go generate $(PACKAGES)
  44. .PHONY: errcheck
  45. errcheck:
  46. @hash errcheck > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  47. go get -u github.com/kisielk/errcheck; \
  48. fi
  49. errcheck $(PACKAGES)
  50. .PHONY: lint
  51. lint:
  52. @hash golint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  53. go get -u github.com/golang/lint/golint; \
  54. fi
  55. for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done;
  56. .PHONY: integrations
  57. integrations: TAGS=bindata sqlite
  58. integrations: build
  59. go test code.gitea.io/gitea/integrations
  60. .PHONY: test
  61. test:
  62. for PKG in $(PACKAGES); do go test -cover -coverprofile $$GOPATH/src/$$PKG/coverage.out $$PKG || exit 1; done;
  63. .PHONY: test-vendor
  64. test-vendor:
  65. @hash govendor > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  66. go get -u github.com/kardianos/govendor; \
  67. fi
  68. govendor status +outside +unused || exit 1
  69. .PHONY: test-sqlite
  70. test-sqlite: integrations.test
  71. GITEA_CONF=integrations/sqlite.ini ./integrations.test
  72. .PHONY: test-mysql
  73. test-mysql: integrations.test
  74. GITEA_CONF=integrations/mysql.ini ./integrations.test
  75. .PHONY: test-pgsql
  76. test-pgsql: integrations.test
  77. GITEA_CONF=integrations/pgsql.ini ./integrations.test
  78. integrations.test: $(SOURCES)
  79. go test -c code.gitea.io/gitea/integrations -tags 'sqlite'
  80. .PHONY: check
  81. check: test
  82. .PHONY: install
  83. install: $(wildcard *.go)
  84. go install -v -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)'
  85. .PHONY: build
  86. build: $(EXECUTABLE)
  87. $(EXECUTABLE): $(SOURCES)
  88. go build $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
  89. .PHONY: docker
  90. docker:
  91. docker run -ti --rm -v $(CURDIR):/srv/app/src/code.gitea.io/gitea -w /srv/app/src/code.gitea.io/gitea -e TAGS="bindata $(TAGS)" webhippie/golang:edge make clean generate build
  92. docker build -t gitea/gitea:latest .
  93. .PHONY: release
  94. release: release-dirs release-windows release-linux release-darwin release-copy release-check
  95. .PHONY: release-dirs
  96. release-dirs:
  97. mkdir -p $(DIST)/binaries $(DIST)/release
  98. .PHONY: release-windows
  99. release-windows:
  100. @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  101. go get -u github.com/karalabe/xgo; \
  102. fi
  103. xgo -dest $(DIST)/binaries -tags '$(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out gitea-$(VERSION) .
  104. ifeq ($(CI),drone)
  105. mv /build/* $(DIST)/binaries
  106. endif
  107. .PHONY: release-linux
  108. release-linux:
  109. @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  110. go get -u github.com/karalabe/xgo; \
  111. fi
  112. xgo -dest $(DIST)/binaries -tags '$(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'linux/*' -out gitea-$(VERSION) .
  113. ifeq ($(CI),drone)
  114. mv /build/* $(DIST)/binaries
  115. endif
  116. .PHONY: release-darwin
  117. release-darwin:
  118. @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  119. go get -u github.com/karalabe/xgo; \
  120. fi
  121. xgo -dest $(DIST)/binaries -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -targets 'darwin/*' -out gitea-$(VERSION) .
  122. ifeq ($(CI),drone)
  123. mv /build/* $(DIST)/binaries
  124. endif
  125. .PHONY: release-copy
  126. release-copy:
  127. $(foreach file,$(wildcard $(DIST)/binaries/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));)
  128. .PHONY: release-check
  129. release-check:
  130. cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;)
  131. .PHONY: javascripts
  132. javascripts: public/js/index.js
  133. .IGNORE: public/js/index.js
  134. public/js/index.js: $(JAVASCRIPTS)
  135. cat $< >| $@
  136. .PHONY: stylesheets
  137. stylesheets: public/css/index.css
  138. .IGNORE: public/css/index.css
  139. public/css/index.css: $(STYLESHEETS)
  140. lessc $< $@
  141. .PHONY: assets
  142. assets: javascripts stylesheets