Makefile 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. LDFLAGS += -X "gogs.io/gogs/internal/conf.BuildTime=$(shell date -u '+%Y-%m-%d %I:%M:%S %Z')"
  2. LDFLAGS += -X "gogs.io/gogs/internal/conf.BuildCommit=$(shell git rev-parse HEAD)"
  3. CONF_FILES := $(shell find conf | sed 's/ /\\ /g')
  4. TEMPLATES_FILES := $(shell find templates | sed 's/ /\\ /g')
  5. PUBLIC_FILES := $(shell find public | sed 's/ /\\ /g')
  6. LESS_FILES := $(wildcard public/less/*.less)
  7. ASSETS_GENERATED := internal/assets/conf/conf_gen.go internal/assets/templates/templates_gen.go internal/assets/public/public_gen.go
  8. GENERATED := $(ASSETS_GENERATED) public/css/gogs.css
  9. OS := $(shell uname)
  10. TAGS = ""
  11. BUILD_FLAGS = "-v"
  12. RELEASE_ROOT = "release"
  13. RELEASE_GOGS = "release/gogs"
  14. NOW = $(shell date -u '+%Y%m%d%I%M%S')
  15. GOVET = go tool vet -composites=false -methods=false -structtags=false
  16. .PHONY: build pack release generate clean
  17. .IGNORE: public/css/gogs.css
  18. all: build
  19. check: test
  20. dist: release
  21. web: build
  22. ./gogs web
  23. govet:
  24. $(GOVET) gogs.go
  25. $(GOVET) models pkg routes
  26. build: $(GENERATED)
  27. go build $(BUILD_FLAGS) -ldflags '$(LDFLAGS)' -tags '$(TAGS)' -trimpath -o gogs
  28. build-no-gen:
  29. go build $(BUILD_FLAGS) -ldflags '$(LDFLAGS)' -tags '$(TAGS)' -trimpath -o gogs
  30. pack:
  31. rm -rf $(RELEASE_GOGS)
  32. mkdir -p $(RELEASE_GOGS)
  33. cp -r gogs LICENSE README.md README_ZH.md scripts $(RELEASE_GOGS)
  34. cd $(RELEASE_ROOT) && zip -r gogs.$(NOW).zip "gogs"
  35. release: build pack
  36. generate: $(ASSETS_GENERATED)
  37. internal/assets/conf/conf_gen.go: $(CONF_FILES)
  38. -rm -f $@
  39. go generate internal/assets/conf/conf.go
  40. gofmt -s -w $@
  41. internal/assets/templates/templates_gen.go: $(TEMPLATES_FILES)
  42. -rm -f $@
  43. go generate internal/assets/templates/templates.go
  44. gofmt -s -w $@
  45. internal/assets/public/public_gen.go: $(PUBLIC_FILES)
  46. -rm -f $@
  47. go generate internal/assets/public/public.go
  48. gofmt -s -w $@
  49. less: public/css/gogs.css
  50. public/css/gogs.css: $(LESS_FILES)
  51. @type lessc >/dev/null 2>&1 && lessc --source-map "public/less/gogs.less" $@ || echo "lessc command not found or failed"
  52. clean:
  53. go clean -i ./...
  54. clean-mac: clean
  55. find . -name ".DS_Store" -print0 | xargs -0 rm
  56. test:
  57. go test -cover -race ./...
  58. fixme:
  59. grep -rnw "FIXME" internal
  60. todo:
  61. grep -rnw "TODO" internal
  62. # Legacy code should be remove by the time of release
  63. legacy:
  64. grep -rnw "\(LEGACY\|DEPRECATED\)" internal