Makefile 799 B

12345678910111213141516171819202122232425262728293031
  1. NAME := mitmengine
  2. GIT_VERSION := $(shell git describe --tags --always --dirty="-dev")
  3. TIMESTAMP := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ UTC')
  4. VERSION_FLAGS := -ldflags='-X "main.BuildVersion=$(GIT_VERSION)" -X "main.BuildTime=$(DATE)"'
  5. BIN_DIR := ./bin
  6. CMDS := $(notdir $(wildcard cmd/*))
  7. TARGETS = $(addprefix $(BIN_DIR)/,$(CMDS))
  8. $(BIN_DIR)/%:
  9. @if [ ! -d cmd/$* ]; then echo "Error: No directory at cmd/$*." && exit 1; fi
  10. go build -o bin/$* $(VERSION_FLAGS) ./cmd/$*
  11. .PHONY: build
  12. build: $(TARGETS)
  13. .PHONY: test unit
  14. test unit:
  15. go vet ./...
  16. go test ./... -cover -timeout=15s -run=Unit -race -count=1
  17. .PHONY: cover
  18. cover: TMPFILE := $(shell mktemp)
  19. cover:
  20. go test -coverprofile=$(TMPFILE) ./...
  21. go tool cover -func=$(TMPFILE) && rm $(TMPFILE)
  22. .PHONY: clean
  23. clean:
  24. rm -rf $(BIN_DIR)/*