forked from Cortys/goblin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
43 lines (34 loc) · 1.21 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
43
# variable definitions
NAME := goblin
DESC := dumps a Go AST to JSON
PREFIX ?= usr/local
VERSION := $(shell git describe --tags --always --dirty)
GOVERSION := $(shell go version)
BUILDTIME := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
BUILDDATE := $(shell date -u +"%B %d, %Y")
BUILDER := $(shell echo "`git config user.name` <`git config user.email`>")
PKG_RELEASE ?= 1
PROJECT_URL := "https://github.com/Cortys/$(NAME)"
LDFLAGS := -X 'main.version=$(VERSION)' \
-X 'main.buildTime=$(BUILDTIME)' \
-X 'main.builder=$(BUILDER)' \
-X 'main.goversion=$(GOVERSION)'
# development tasks
fmt:
go fmt -x ./...
test: fmt
go test -v $$(go list ./... | grep -v /vendor/ | grep -v /cmd/ | grep -v /fixtures/)
PACKAGES := $(shell find ./* -type d | grep -v vendor)
coverage:
@go test -coverprofile=coverage.txt -covermode=atomic
@-go tool cover -html=coverage.txt -o cover.html
benchmark:
@echo "Running tests..."
@go test -bench=. $$(go list ./... | grep -v /vendor/ | grep -v /cmd/)
CMD_SOURCES := $(shell find cmd -name main.go)
TARGETS := $(patsubst cmd/%/main.go,%,$(CMD_SOURCES))
%: cmd/%/main.go
go build -ldflags "$(LDFLAGS)" -o $@ $<
%-${TRAVIS_TAG}-${TARGET}.tar.gz: %
tar czf $@ $<
.PHONY: fmt