Makefile 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. GIT ?= git
  2. GO_VARS ?=
  3. GO ?= go
  4. COMMIT := $(shell $(GIT) rev-parse HEAD)
  5. VERSION ?= $(shell $(GIT) describe --tags ${COMMIT} 2> /dev/null || echo "$(COMMIT)")
  6. BUILD_TIME := $(shell LANG=en_US date +"%F_%T_%z")
  7. ROOT := github.com/flashmob/go-guerrilla
  8. LD_FLAGS := -X $(ROOT).Version=$(VERSION) -X $(ROOT).Commit=$(COMMIT) -X $(ROOT).BuildTime=$(BUILD_TIME)
  9. .PHONY: help clean dependencies test
  10. help:
  11. @echo "Please use \`make <ROOT>' where <ROOT> is one of"
  12. @echo " dependencies to go install the dependencies"
  13. @echo " guerrillad to build the main binary for current platform"
  14. @echo " test to run unittests"
  15. clean:
  16. rm -f guerrillad
  17. rm -rf dashboard/js/node_modules
  18. rm -rf dashboard/js/build
  19. dependencies:
  20. $(GO_VARS) $(GO) list -f='{{ join .Deps "\n" }}' $(ROOT)/cmd/guerrillad | grep -v $(ROOT) | tr '\n' ' ' | $(GO_VARS) xargs $(GO) get -u -v
  21. $(GO_VARS) $(GO) list -f='{{ join .Deps "\n" }}' $(ROOT)/cmd/guerrillad | grep -v $(ROOT) | tr '\n' ' ' | $(GO_VARS) xargs $(GO) install -v
  22. cd dashboard/js && npm install && cd ../..
  23. dashboard: dashboard/*.go */*/*/*.js */*/*/*/*.js
  24. cd dashboard/js && npm run build && cd ../..
  25. statik -src=dashboard/js/build -dest=dashboard
  26. guerrillad: *.go */*.go */*/*.go
  27. $(GO_VARS) $(GO) build -o="guerrillad" -ldflags="$(LD_FLAGS)" $(ROOT)/cmd/guerrillad
  28. guerrilladrace: *.go */*.go */*/*.go
  29. $(GO_VARS) $(GO) build -o="guerrillad" -race -ldflags="$(LD_FLAGS)" $(ROOT)/cmd/guerrillad
  30. test: *.go */*.go */*/*.go
  31. $(GO_VARS) $(GO) test -v .
  32. $(GO_VARS) $(GO) test -v ./tests
  33. $(GO_VARS) $(GO) test -v ./cmd/guerrillad
  34. $(GO_VARS) $(GO) test -v ./response
  35. $(GO_VARS) $(GO) test -v ./backends
  36. $(GO_VARS) $(GO) test -v ./mail
  37. testrace: *.go */*.go */*/*.go
  38. $(GO_VARS) $(GO) test -v . -race
  39. $(GO_VARS) $(GO) test -v ./tests -race
  40. $(GO_VARS) $(GO) test -v ./cmd/guerrillad -race
  41. $(GO_VARS) $(GO) test -v ./response -race
  42. $(GO_VARS) $(GO) test -v ./backends -race