-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
69 lines (50 loc) · 1.71 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
# Borrowed from:
# https://github.com/silven/go-example/blob/master/Makefile
# https://vic.demuzere.be/articles/golang-makefile-crosscompile/
BINARY = platform
VET_REPORT = vet.report
TEST_REPORT = tests.xml
GOARCH = amd64
RELEASE_TYPE ?= patch
PROJECT = github.com/armory/spinnaker-commits
BUILD_DIR=$(shell pwd)/build
COMMIT=$(shell git rev-parse HEAD)
BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
TAG=${COMMIT}
#select all packages except a few folders because it's an integration test
PKGS := $(shell go list ./... | grep -v -e /integration -e /vendor)
CURRENT_DIR=$(shell pwd)
PROJECT_DIR_LINK=$(shell readlink ${PROJECT_DIR})
# Setup the -ldflags option for go build here, interpolate the variable values
# Go since 1.6 creates dynamically linked exes, here we force static and strip the result
LDFLAGS = -ldflags "-X ${PROJECT}/cmd.SEMVER=${TAG} -X ${PROJECT}/cmd.COMMIT=${COMMIT} -X ${PROJECT}/cmd.BRANCH=${BRANCH} -linkmode external -extldflags -static -s -w"
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
LDFLAGS = -ldflags "-X ${PROJECT}/cmd.SEMVER=${TAG} -X ${PROJECT}/cmd.COMMIT=${COMMIT} -X ${PROJECT}/cmd.BRANCH=${BRANCH} -extldflags -s -w"
endif
# Build the project
#all: clean lint test vet build
all: lint vet build
run:
go run main.go
build:
go build -i ${LDFLAGS} -o ${BUILD_DIR}/spinnaker-commits main.go
cp -r templates/ ${BUILD_DIR}/templates
test:
PCT=0 bin/test_coverage.sh
GOLINT=$(GOPATH)/bin/golint
$(GOLINT):
go get -u golang.org/x/lint/golint
lint: $(GOLINT)
@$(GOLINT) $(PKGS)
$(BUILD_DIR):
mkdir -p $@
chmod 777 $@
vet:
go vet -v ./...
fmt:
go fmt $$(go list ./... | grep -v /vendor/)
clean:
rm -rf ${BUILD_DIR}
go clean
.PHONY: lint linux darwin test vet fmt clean run