-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
111 lines (87 loc) · 3.02 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#
# Makefile
#
# The kickoff point for all project management commands.
#
GOCC := go
# Program version
VERSION := $(shell git describe --always --tags)
# Binary name for bintray
BIN_NAME=sentry
# Project owner for bintray
OWNER=gesquive
# Project name for bintray
PROJECT_NAME=sentry
# Project url used for builds
# examples: github.com, bitbucket.org
REPO_HOST_URL=github.com
# Grab the current commit
GIT_COMMIT=$(shell git rev-parse HEAD)
# Check if there are uncommited changes
GIT_DIRTY=$(shell test -n "`git status --porcelain`" && echo "+CHANGES" || true)
# Use a local vendor directory for any dependencies; comment this out to
# use the global GOPATH instead
# GOPATH=$(PWD)
INSTALL_PATH=$(GOPATH)/src/${REPO_HOST_URL}/${OWNER}/${PROJECT_NAME}
default: test build
.PHONY: help
help:
@echo 'Management commands for $(PROJECT_NAME):'
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: build
build: ## Compile the project
@echo "building ${OWNER} ${BIN_NAME} ${VERSION}"
@echo "GOPATH=${GOPATH}"
${GOCC} build -ldflags "-X main.version=${VERSION} -X main.dirty=${GIT_DIRTY}" -o ${BIN_NAME}
.PHONY: install
install: build ## Install the binary
install -d ${DESTDIR}/usr/local/bin/
install -m 755 ./${BIN_NAME} ${DESTDIR}/usr/local/bin/${BIN_NAME}
.PHONY: deps
deps: glide ## Download project dependencies
glide install
.PHONY: test
test: glide ## Run golang tests
${GOCC} test $(shell glide novendor)
.PHONY: bench
bench: glide ## Run golang benchmarks
${GOCC} test -benchmem -bench=. $(shell glide novendor)
.PHONY: clean
clean: ## Clean the directory tree
${GOCC} clean
rm -f ./${BIN_NAME}.test
rm -f ./${BIN_NAME}
rm -rf ./dist
.PHONY: build-all
build-all: gox
gox -verbose \
-ldflags "-X main.version=${VERSION} -X main.dirty=${GIT_DIRTY}" \
-os="linux darwin windows" \
-arch="amd64 386" \
-output="dist/{{.OS}}-{{.Arch}}/{{.Dir}}" .
.PHONY: dist
dist: build-all ## Cross compile the full distribution
pkg/dist.sh "linux-386" "${PROJECT_NAME}-${VERSION}-linux-x32"
pkg/dist.sh "linux-amd64" "${PROJECT_NAME}-${VERSION}-linux-x64"
pkg/dist.sh "darwin-386" "${PROJECT_NAME}-${VERSION}-osx-x32"
pkg/dist.sh "darwin-amd64" "${PROJECT_NAME}-${VERSION}-osx-x64"
pkg/dist.sh "windows-386" "${PROJECT_NAME}-${VERSION}-windows-x32"
pkg/dist.sh "windows-amd64" "${PROJECT_NAME}-${VERSION}-windows-x64"
cd dist && find . -mindepth 1 -maxdepth 1 -type d -exec rm -rf "{}" \;
.PHONY: fmt
fmt: ## Reformat the source tree with gofmt
find . -name '*.go' -not -path './.vendor/*' -exec gofmt -w=true {} ';'
.PHONY: link
link: $(INSTALL_PATH) ## Symlink this project into the GOPATH
$(INSTALL_PATH):
@mkdir -p `dirname $(INSTALL_PATH)`
@ln -s $(PWD) $(INSTALL_PATH) >/dev/null 2>&1
.PHONY: glide
glide:
@command -v glide >/dev/null 2>&1 || \
echo "Installing glide" && ${GOCC} get -u github.com/Masterminds/glide
.PHONY: gox
gox:
@command -v gox >/dev/null 2>&1 || \
echo "Installing gox" && ${GOCC} get -u github.com/mitchellh/gox