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

Makefile 4.3KB

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