forked from operable/go-relay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (58 loc) · 2.04 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
GOLINT_BIN = $(shell go env GOPATH)/bin/golint
PKG_DIRS := $(shell find . -type d | grep relay | grep -v vendor)
FULL_PKGS := $(sort $(foreach pkg, $(PKG_DIRS), $(subst ./, github.com/operable/go-relay/, $(pkg))))
BUILD_STAMP := $(shell date -u '+%Y%m%d%H%M%S')
BUILD_HASH := $(shell git rev-parse HEAD)
BUILD_TAG ?= $(shell scripts/build_tag.sh)
DRIVER_TAG ?= 0.13
DOCKER_IMAGE ?= "operable/relay:$(BUILD_TAG)"
LINK_VARS := -X main.buildstamp=$(BUILD_STAMP) -X main.buildhash=$(BUILD_HASH)
LINK_VARS += -X main.buildtag=$(BUILD_TAG) -X main.commanddrivertag=$(DRIVER_TAG)
BUILD_DIR = _build
EXENAME = relay
ifdef FORCE
.PHONY: all tools lint test clean deps relay docker
else
.PHONY: all tools lint test clean deps docker
endif
all: test exe
deps:
govendor sync
vet:
govendor vet -x +local
test:
govendor test +local -cover
# This is only intended to run in Travis CI and requires goveralls to
# be installed.
ci-coveralls: tools deps
goveralls -service=travis-ci
# Builds Relay on the current OS
exe: clean-dev | $(BUILD_DIR)
CGO_ENABLED=0 govendor build -ldflags "$(LINK_VARS)" -o $(BUILD_DIR)/$(EXENAME)
docker:
docker build -t $(DOCKER_IMAGE) .
clean: clean-dev
rm -rf $(BUILD_DIR) relay-test
find . -name "*.test" -type f | xargs rm -fv
find . -name "*-test" -type f | xargs rm -fv
# Remove editor files (here, Emacs)
clean-dev:
rm -f `find . -name "*flymake*.go"`
$(BUILD_DIR):
mkdir -p $@
########################################################################
# The targets below stand to be cleaned up. Everything above here is
# analogous to what's in circuit-driver
#
tools: $(GOLINT_BIN)
lint: tools
@for pkg in $(FULL_PKGS); do $(GOLINT_BIN) $$pkg; done
$(GOLINT_BIN):
go get -u github.com/golang/lint/golint
tarball: $(TARBALL_NAME)
$(TARBALL_NAME): test exe
mkdir -p $(TARBALL_NAME)
cp $(BUILD_DIR)/$(EXENAME) $(TARBALL_NAME)/$(EXENAME)
cp example_relay.conf $(TARBALL_NAME)
tar czf $(TARBALL_NAME).tar.gz $(TARBALL_NAME)
rm -rf $(TARBALL_NAME)