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.

65 lines
1.3KB

  1. VERSION := $(shell git rev-parse --short HEAD)
  2. BUILDTIME := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
  3. BUILDTIMEFILENAME := $(shell date -u '+%Y%m%d-%H%M%SZ')
  4. BUILDTIMETAG := $(shell date -u '+%Y%m%d%H%M%S')
  5. BUILDUSER := $(shell whoami)
  6. BUILDHOST := $(shell hostname -s)
  7. BUILDARCH := $(shell uname -m)
  8. FN := historyposter
  9. UNAME_S := $(shell uname -s)
  10. GOLDFLAGS += -X main.Version=$(VERSION)
  11. GOLDFLAGS += -X main.Buildarch=$(BUILDARCH)
  12. # osx can't statically link apparently?!
  13. ifeq ($(UNAME_S),Darwin)
  14. GOFLAGS := -ldflags "$(GOLDFLAGS)"
  15. endif
  16. ifneq ($(UNAME_S),Darwin)
  17. GOFLAGS = -ldflags "-linkmode external -extldflags -static $(GOLDFLAGS)"
  18. endif
  19. default: debug
  20. commit: fmt lint
  21. git commit -a
  22. fmt:
  23. #go fmt ./...
  24. goimports -l -w .
  25. golangci-lint run --fix
  26. lint:
  27. golangci-lint run
  28. sh -c 'test -z "$$(gofmt -l .)"'
  29. debug: build
  30. -mkdir -p ./.env.d
  31. echo 1 > ./.env.d/HISTORYPOSTER_DEBUG
  32. GOTRACEBACK=all envdir ./.env.d ./$(FN)d 2>&1 | tee -a debug.log
  33. debugger:
  34. cd cmd/historyposter && dlv debug main.go
  35. run: build
  36. ./$(FN)d
  37. clean:
  38. -rm ./$(FN)d debug.log
  39. build: ./$(FN)d
  40. docker:
  41. docker build .
  42. go-get:
  43. cd cmd/$(FN) && go get -v
  44. ./$(FN)d: */*.go cmd/*/*.go go-get
  45. cd cmd/$(FN) && go build -o ../../$(FN)d $(GOFLAGS) .
  46. .PHONY: build fmt test is_uncommitted docker dist hub upload-docker-image clean run rundebug default build-docker-image-dist