-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
40 lines (30 loc) · 1008 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
31
32
33
34
35
36
37
38
39
40
MAKEFLAGS += --no-builtin-rules
.SUFFIXES:
.SECONDARY:
.DELETE_ON_ERROR:
ARGS ?= -v
TESTS ?= ./... -cover
COVER ?=
SRC := $(shell find . -name '*.go')
# If the first argument to make is "migrate" use the rest as arguments for the migrate target...
ifeq (migrate,$(firstword $(MAKECMDGOALS)))
RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
$(eval $(RUN_ARGS):;@:) # ...and turn them into do-nothing targets
endif
# Prefix the user's GOPATH with our godep path. I don't want to totally blast the user's GOPATH here.
# TODO: Is it worth ensuring that godep is installed here?
export GOPATH := $(shell godep path):$(GOPATH)
all: test build;
build:
@echo 'Building with GOPATH: $(GOPATH)'
@go build $(GOFLAGS) -o build/migrate cmd/migrate/main.go
clean:
@rm -rf build
test: $(SRC)
@go test $(TESTS) $(ARGS)
test-cover: $(SRC)
@go test $(COVER) -coverprofile=coverage.out
@go tool cover -html=coverage.out
migrate:
@go run cmd/migrate/main.go $(RUN_ARGS)
.PHONY: migrate