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.

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