You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

156 lines
3.7 KiB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. DIST := dist
  2. BIN := bin
  3. EXECUTABLE := gitea
  4. IMPORT := code.gitea.io/gitea
  5. SHA := $(shell git rev-parse --short HEAD)
  6. DATE := $(shell date -u '+%Y-%m-%d %I:%M:%S %Z')
  7. BINDATA := $(shell find conf | sed 's/ /\\ /g')
  8. STYLESHEETS := $(wildcard public/less/index.less public/less/_*.less)
  9. JAVASCRIPTS :=
  10. LDFLAGS += -X "code.gitea.io/gitea/modules/setting.BuildTime=$(DATE)"
  11. LDFLAGS += -X "code.gitea.io/gitea/modules/setting.BuildGitHash=$(SHA)"
  12. TARGETS ?= linux/*,darwin/*,windows/*
  13. PACKAGES ?= $(shell go list ./... | grep -v /vendor/)
  14. TAGS ?=
  15. ifneq ($(DRONE_TAG),)
  16. VERSION ?= $(DRONE_TAG)
  17. else
  18. ifneq ($(DRONE_BRANCH),)
  19. VERSION ?= $(DRONE_BRANCH)
  20. else
  21. VERSION ?= master
  22. endif
  23. endif
  24. .PHONY: all
  25. all: build
  26. .PHONY: clean
  27. clean:
  28. go clean -i ./...
  29. rm -rf $(BIN) $(DIST)
  30. .PHONY: fmt
  31. fmt:
  32. go fmt $(PACKAGES)
  33. .PHONY: vet
  34. vet:
  35. go vet $(PACKAGES)
  36. .PHONY: generate
  37. generate:
  38. @which go-bindata > /dev/null; if [ $$? -ne 0 ]; then \
  39. go get -u github.com/jteeuwen/go-bindata/...; \
  40. fi
  41. go generate $(PACKAGES)
  42. .PHONY: errcheck
  43. errcheck:
  44. @which errcheck > /dev/null; if [ $$? -ne 0 ]; then \
  45. go get -u github.com/kisielk/errcheck; \
  46. fi
  47. errcheck $(PACKAGES)
  48. .PHONY: lint
  49. lint:
  50. @which golint > /dev/null; if [ $$? -ne 0 ]; then \
  51. go get -u github.com/golang/lint/golint; \
  52. fi
  53. for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done;
  54. .PHONY: test
  55. test:
  56. for PKG in $(PACKAGES); do go test -cover -coverprofile $$GOPATH/src/$$PKG/coverage.out $$PKG || exit 1; done;
  57. .PHONY: test-mysql
  58. test-mysql:
  59. @echo "Not integrated yet!"
  60. .PHONY: test-pgsql
  61. test-pgsql:
  62. @echo "Not integrated yet!"
  63. .PHONY: check
  64. check: test
  65. .PHONY: install
  66. install: $(wildcard *.go)
  67. go install -v -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)'
  68. .PHONY: build
  69. build: $(EXECUTABLE)
  70. $(EXECUTABLE): $(wildcard *.go)
  71. go build -v -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
  72. .PHONY: release
  73. release: release-build release-copy release-check
  74. .PHONY: release-build
  75. release-build:
  76. @which xgo > /dev/null; if [ $$? -ne 0 ]; then \
  77. go get -u github.com/karalabe/xgo; \
  78. fi
  79. xgo -dest $(BIN) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -targets '$(TARGETS)' -out $(EXECUTABLE)-$(VERSION) $(IMPORT)
  80. .PHONY: release-copy
  81. release-copy:
  82. mkdir -p $(DIST)/release
  83. $(foreach file,$(wildcard $(BIN)/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));)
  84. .PHONY: release-check
  85. release-check:
  86. cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;)
  87. .PHONY: latest
  88. latest: release-build latest-copy latest-check
  89. .PHONY: latest-copy
  90. latest-copy:
  91. mkdir -p $(DIST)/latest
  92. $(foreach file,$(wildcard $(BIN)/$(EXECUTABLE)-*),cp $(file) $(DIST)/latest/$(subst $(EXECUTABLE)-$(VERSION),$(EXECUTABLE)-latest,$(notdir $(file)));)
  93. .PHONY: latest-check
  94. latest-check:
  95. cd $(DIST)/latest; $(foreach file,$(wildcard $(DIST)/latest/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;)
  96. .PHONY: publish
  97. publish: release latest
  98. .PHONY: bindata
  99. bindata: modules/bindata/bindata.go
  100. .IGNORE: modules/bindata/bindata.go
  101. modules/bindata/bindata.go: $(BINDATA)
  102. @which go-bindata > /dev/null; if [ $$? -ne 0 ]; then \
  103. go get -u github.com/jteeuwen/go-bindata/...; \
  104. fi
  105. go-bindata -o=$@ -ignore="\\.go|README.md|TRANSLATORS" -pkg=bindata conf/...
  106. go fmt $@
  107. sed -i.bak 's/confLocaleLocale_/confLocaleLocale/' $@
  108. rm $@.bak
  109. .PHONY: javascripts
  110. javascripts: public/js/index.js
  111. .IGNORE: public/js/index.js
  112. public/js/index.js: $(JAVASCRIPTS)
  113. cat $< >| $@
  114. .PHONY: stylesheets
  115. stylesheets: public/css/index.css
  116. .IGNORE: public/css/index.css
  117. public/css/index.css: $(STYLESHEETS)
  118. lessc $< $@
  119. .PHONY: assets
  120. assets: bindata javascripts stylesheets