Makefile 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. print-%: ; @echo $*=$($*)
  2. PREFIX?=/data/app/antispam-service
  3. PROG=antispam-service
  4. PROG_BAK=antispam-service_bak
  5. TEST_SRC=$(wildcard ./**/*_test.go)
  6. GOTESTOPT= -v
  7. SOURCE_DIR=./
  8. SUB_DIR=$(shell ls)
  9. CUR_BRANCH=$(shell git branch | grep \* | cut -d ' ' -f2)
  10. CONF?=cmd/antispam-test.toml
  11. all: build vet lint test_quick clean
  12. .PHONY: build run lint test vet clean test_quick
  13. build: $(PROG)
  14. $(PROG):
  15. @echo "\nstart build..."
  16. @go build -o $(PROG) cmd/main.go
  17. run: clean build
  18. @echo "start running in container..."
  19. @./$(PROG) -conf=$(CONF)
  20. clean:
  21. @echo "\nstart cleaning up ..."
  22. @go clean $(GO_FLAGS) $(SOURCE_DIR)
  23. @rm -rf $(PROG)
  24. @rm -rf build
  25. @rm -f `find . -name "*.swp" -print`
  26. @rm -f `find . -name "*.xlsx" -print`
  27. vet:
  28. @echo "\nstart running go vet..."
  29. @for f in $(SUB_DIR); do \
  30. if [ -d $$f ]; then \
  31. go vet ./"$$f"/...; \
  32. fi; \
  33. done
  34. lint:
  35. @echo "\nstart running golint..."
  36. @for f in $(SUB_DIR); do \
  37. if [ -d $$f ]; then \
  38. golint $$f; \
  39. fi; \
  40. done
  41. test_quick:
  42. @echo "\nstart running quick unit test..."
  43. @go test $(GOTESTOPT) ./http/... ./service/... ./util/...
  44. test:
  45. @echo "\nstart running full unit test..."
  46. @go test $(GOTESTOPT) ./dao/...
  47. deploy:
  48. @echo "start deploying on dev machine..."
  49. @cp $(PREFIX)/$(PROG) $(PREFIX)/$(PROG_BAK) && go build -o $(PREFIX)/$(PROG) && supervisorctl restart $(PROG)