-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
86 lines (71 loc) · 2.62 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
76
77
78
79
80
81
82
83
84
85
86
GO_REQ_VER := 1.9.2
# AVAILABLE ENV FROM CI
# - unit
# PATH = $PATH:/usr/local/go/bin:$WORKSPACE/bin
# GOPATH = $WORKSPACE
# SRC_API_DIR = $WORKSPACE/src/local
# RESULTS_DIR = $WORKSPACE/unit_results
# - integration
# PATH = $PATH:/usr/local/go/bin:$WORKSPACE/bin
# GOPATH = $WORKSPACE
# CATALOG_API_DIR = $WORKSPACE/src/marketplace
# RESULTS_DIR = $WORKSPACE/integration_results
RESULTS_DIR := integration-results
# DO NOT TOUCH BELLOW
SHELL = /bin/bash
BUILD_DIR := cli/cmd
# It assumes that GOPATH may be a list of paths
MAIN_GOPATH := $(lastword $(subst :, ,$(GOPATH)))
BIN ?= $(MAIN_GOPATH)/bin/marketplace
BINDIR ?= $(MAIN_GOPATH)/bin/
DATE := $(shell date "+%Y-%m-%d %H:%M:%S")
GIT_LOG := $(shell git log --decorate --oneline -n1| sed -e "s/'/ /g" -e "s/\"/ /g" -e "s/\#/\â„–/g" -e 's/`/ /g')
GIT_REV := $(shell git rev-parse --short HEAD)
APP_VERSION := $(shell git branch|grep '*'| cut -f2 -d' ')
LDFLAGS = -X 'main.AppVersion=$(APP_VERSION)' \
-X 'main.GitRev=$(GIT_REV)' \
-X 'main.GoVersion=$(GO_REQ_VER)' \
-X 'main.BuildDate=$(DATE)' \
-X 'main.GitLog=$(GIT_LOG)'
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "*/vendor*")
PACKAGES := $(shell find . -name '*.go' -not -path '*/vendor*' -not -path '*/test*' -exec dirname '{}' ';' | sort -u | sed -e 's/^\.\///')
# export defined variables to included Makefiles
export
include ./tools/mk/tools.mk
include ./tools/mk/dep.mk
include ./tools/mk/lint.mk
include ./tools/mk/mocks.mk
include ./tools/mk/tests.mk
.PHONY: all
all: clean deps test fast-build
@echo "Done"
.PHONY: clean
clean:
rm -f $(BIN)
rm -rf test-results
rm -rf integration-results
# find . -name "*_gen.go" | grep -v "handler2/docs" | (xargs rm || echo "Done")
# find . -name "*_gen_test.go" | grep -v "handler2/docs" | xargs rm | (xargs rm || echo "Done")
.PHONY: deps
deps: get-dep
@test -x $(DEP_BIN) || { echo "Dep $(DEP_REQ_VERSION) is required"; exit 1; }
@mkdir -p ./vendor/
$(DEP_BIN) ensure -v -vendor-only
if ! command -v mockgen > /dev/null; then \
${GO} get github.com/golang/mock/mockgen; \
fi
${GO} get github.com/pkg/errors
.PHONY: ci-deps
ci-deps: deps
${GO} get github.com/axw/gocov/gocov
${GO} get github.com/t-yuki/gocover-cobertura
${GO} get -v github.com/tebeka/go2xunit
${GO} get -v github.com/ttacon/chalk
.PHONY: build
build: clean deps fast-build
# fast build without check for deps
.PHONY: fast-build
fast-build:
cd $(BUILD_DIR) && ${GO} build -i -ldflags "$(LDFLAGS)" -o $(BIN)
deb:
debuild --no-lintian --preserve-env -uc -us -i -I