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.

152 lines
3.5 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: deps
  31. deps:
  32. @which go-bindata > /dev/null; if [ $$? -ne 0 ]; then \
  33. go get -u github.com/jteeuwen/go-bindata/...; \
  34. fi
  35. .PHONY: fmt
  36. fmt:
  37. go fmt $(PACKAGES)
  38. .PHONY: vet
  39. vet:
  40. go vet $(PACKAGES)
  41. .PHONY: errcheck
  42. errcheck:
  43. @which errcheck > /dev/null; if [ $$? -ne 0 ]; then \
  44. go get -u github.com/kisielk/errcheck; \
  45. fi
  46. errcheck $(PACKAGES)
  47. .PHONY: lint
  48. lint:
  49. @which golint > /dev/null; if [ $$? -ne 0 ]; then \
  50. go get -u github.com/golang/lint/golint; \
  51. fi
  52. for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done;
  53. .PHONY: test
  54. test:
  55. for PKG in $(PACKAGES); do go test -cover -coverprofile $$GOPATH/src/$$PKG/coverage.out $$PKG || exit 1; done;
  56. .PHONY: test-mysql
  57. test-mysql:
  58. @echo "Not integrated yet!"
  59. .PHONY: test-pgsql
  60. test-pgsql:
  61. @echo "Not integrated yet!"
  62. .PHONY: check
  63. check: test
  64. .PHONY: install
  65. install: $(wildcard *.go)
  66. go install -v -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)'
  67. .PHONY: build
  68. build: $(BIN)/$(EXECUTABLE)
  69. $(BIN)/$(EXECUTABLE): $(wildcard *.go)
  70. go build -v -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
  71. .PHONY: release
  72. release: release-build release-copy release-check
  73. .PHONY: release-build
  74. release-build:
  75. @which xgo > /dev/null; if [ $$? -ne 0 ]; then \
  76. go get -u github.com/karalabe/xgo; \
  77. fi
  78. xgo -dest $(BIN) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -targets '$(TARGETS)' -out $(EXECUTABLE)-$(VERSION) $(IMPORT)
  79. .PHONY: release-copy
  80. release-copy:
  81. mkdir -p $(DIST)/release
  82. $(foreach file,$(wildcard $(BIN)/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));)
  83. .PHONY: release-check
  84. release-check:
  85. cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;)
  86. .PHONY: latest
  87. latest: release-build latest-copy latest-check
  88. .PHONY: latest-copy
  89. latest-copy:
  90. mkdir -p $(DIST)/latest
  91. $(foreach file,$(wildcard $(BIN)/$(EXECUTABLE)-*),cp $(file) $(DIST)/latest/$(subst $(EXECUTABLE)-$(VERSION),$(EXECUTABLE)-latest,$(notdir $(file)));)
  92. .PHONY: latest-check
  93. latest-check:
  94. cd $(DIST)/latest; $(foreach file,$(wildcard $(DIST)/latest/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;)
  95. .PHONY: publish
  96. publish: release latest
  97. .PHONY: bindata
  98. bindata: modules/bindata/bindata.go
  99. .IGNORE: modules/bindata/bindata.go
  100. modules/bindata/bindata.go: $(BINDATA)
  101. go-bindata -o=$@ -ignore="\\.go|README.md|TRANSLATORS" -pkg=bindata conf/...
  102. go fmt $@
  103. sed -i.bak 's/confLocaleLocale_/confLocaleLocale/' $@
  104. rm $@.bak
  105. .PHONY: javascripts
  106. javascripts: public/js/index.js
  107. .IGNORE: public/js/index.js
  108. public/js/index.js: $(JAVASCRIPTS)
  109. cat $< >| $@
  110. .PHONY: stylesheets
  111. stylesheets: public/css/index.css
  112. .IGNORE: public/css/index.css
  113. public/css/index.css: $(STYLESHEETS)
  114. lessc $< $@
  115. .PHONY: generate
  116. generate: bindata javascripts stylesheets