Makefile 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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.min.css
  9. TAGS = ""
  10. BUILD_FLAGS = "-v"
  11. RELEASE_ROOT = "release"
  12. RELEASE_GOGS = "release/gogs"
  13. NOW = $(shell date -u '+%Y%m%d%I%M%S')
  14. .PHONY: check dist build build-no-gen pack release generate less clean test fixme todo legacy
  15. .IGNORE: public/css/gogs.css
  16. all: build
  17. check: test
  18. dist: release
  19. web: build
  20. ./gogs web
  21. build: $(GENERATED)
  22. go build $(BUILD_FLAGS) -ldflags '$(LDFLAGS)' -tags '$(TAGS)' -trimpath -o gogs
  23. build-no-gen:
  24. go build $(BUILD_FLAGS) -ldflags '$(LDFLAGS)' -tags '$(TAGS)' -trimpath -o gogs
  25. pack:
  26. rm -rf $(RELEASE_GOGS)
  27. mkdir -p $(RELEASE_GOGS)
  28. cp -r gogs LICENSE README.md README_ZH.md scripts $(RELEASE_GOGS)
  29. cd $(RELEASE_ROOT) && zip -r gogs.$(NOW).zip "gogs"
  30. release: build pack
  31. generate: clean $(ASSETS_GENERATED)
  32. internal/assets/conf/conf_gen.go: $(CONF_FILES)
  33. -rm -f $@
  34. go generate internal/assets/conf/conf.go
  35. gofmt -s -w $@
  36. internal/assets/templates/templates_gen.go: $(TEMPLATES_FILES)
  37. -rm -f $@
  38. go generate internal/assets/templates/templates.go
  39. gofmt -s -w $@
  40. internal/assets/public/public_gen.go: $(PUBLIC_FILES)
  41. -rm -f $@
  42. go generate internal/assets/public/public.go
  43. gofmt -s -w $@
  44. less: clean public/css/gogs.min.css
  45. public/css/gogs.min.css: $(LESS_FILES)
  46. @type lessc >/dev/null 2>&1 && lessc --clean-css --source-map "public/less/gogs.less" $@ || echo "lessc command not found or failed"
  47. clean:
  48. find . -name "*.DS_Store" -type f -delete
  49. test:
  50. go test -cover -race ./...
  51. fixme:
  52. grep -rnw "FIXME" internal
  53. todo:
  54. grep -rnw "TODO" internal
  55. # Legacy code should be removed by the time of release
  56. legacy:
  57. grep -rnw "\(LEGACY\|Deprecated\)" internal