forked from cloudflare/mitmengine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
30 lines (24 loc) · 799 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
NAME := mitmengine
GIT_VERSION := $(shell git describe --tags --always --dirty="-dev")
TIMESTAMP := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ UTC')
VERSION_FLAGS := -ldflags='-X "main.BuildVersion=$(GIT_VERSION)" -X "main.BuildTime=$(DATE)"'
BIN_DIR := ./bin
CMDS := $(notdir $(wildcard cmd/*))
TARGETS = $(addprefix $(BIN_DIR)/,$(CMDS))
$(BIN_DIR)/%:
@if [ ! -d cmd/$* ]; then echo "Error: No directory at cmd/$*." && exit 1; fi
go build -o bin/$* $(VERSION_FLAGS) ./cmd/$*
.PHONY: build
build: $(TARGETS)
.PHONY: test unit
test unit:
go vet ./...
go test ./... -cover -timeout=15s -run=Unit -race -count=1
.PHONY: cover
cover: TMPFILE := $(shell mktemp)
cover:
go test -coverprofile=$(TMPFILE) ./...
go tool cover -func=$(TMPFILE) && rm $(TMPFILE)
.PHONY: clean
clean:
rm -rf $(BIN_DIR)/*