forked from samsung-cnct/jsonsvalidator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake.golang
103 lines (82 loc) · 2.86 KB
/
make.golang
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
.PHONY: all build-all build-app repo-warning-in clean vet lint test view-all-coverage
#
# This is the Makefile to build the golang components.
# It is normally run in a docker container for golang builds.
#
# 6/30/2016 mln
#
# golog compile via docker container:
# https://hub.docker.com/_/golang/
#
# Vars for version and build
IMAGE_NAME := jsonsvalidator
PKGS := "./cmd"
ARCH ?= amd64
DIST ?= $(shell uname | tr [[:upper:]] [[:lower:]])
BUILD := $(shell git rev-parse HEAD)
VERSION := $(shell date +v%Y%m%d)-$(shell git describe --tags --always --dirty)
# grab the latest tagged build
# -ldflasg to set vars
# currently hard coded. XXX need to variabalize it for portability
LDFLAGS := "-X github.com/samsung-cnct/jsonsvalidator/cmd.Version=${VERSION} \
-X github.com/samsung-cnct/jsonsvalidator/cmd.Build=${BUILD}"
# avoid checking etc the vendor dir
NOVENDOR := ./cmd/...
# find the certs. use the first location found
CONTAINER_PATH := ./_containerize
repo-warning-in:
@echo "============================================================="
@echo "make setup:$(MAKE):$(MAKECMDGOALS):$(MAKEFLAGS):"
@echo "GOPATH:$(GOPATH)"
@echo "GOROOT:$(GOROOT)"
@echo "GOBIN:$(GOBIN)"
@echo "GOOS:$(DIST)"
@echo "ARCH:$(ARCH)"
@echo "============================================================="
@pwd
@ls -l
@df
@ls -l $(GOPATH)
@env | sort
all: test build-all
build-all: build-app build-darwin build-linux
# Target for real container build
build-app: repo-warning-in vet
env GOOS=$(DIST) GOARCH=$(ARCH) go build -v -ldflags $(LDFLAGS) -o $(GOPATH)/bin/$(IMAGE_NAME)-$(DIST)-$(ARCH) main.go
# for local os-x app run only
build-darwin: repo-warning-in vet
env GOOS=darwin GOARCH=$(ARCH) go build -v -ldflags $(LDFLAGS) -o $(GOPATH)/bin/$(IMAGE_NAME)-darwin-$(ARCH) main.go
# for local linux app run only
build-linux: repo-warning-in vet
env GOOS=linux GOARCH=$(ARCH) go build -v -ldflags $(LDFLAGS) -o $(GOPATH)/bin/$(IMAGE_NAME)-linux-$(ARCH) main.go
#
# dev testing
#
test: repo-warning-in vet lint
go test -cover -v -ldflags $(LDFLAGS) $(NOVENDOR)
cover-runner: repo-warning-in
go test -covermode=count -coverprofile=coverage.out $(NOVENDOR)
go tool cover -html=coverage.out -o=coverage.html
view-debug:
echo "PKGS $(PKGS)"
view-all-coverage:
echo "mode: count" > coverage-all.out
$(foreach pkg, $(PKGS),\
echo "pkg $(pkg)";\
go test -covermode=count -coverprofile=coverage.out $(pkg);\
tail -n +2 coverage.out >> coverage-all.out;)
go tool cover -html=coverage-all.out -o=coverage-all.html
vet:
go vet $(NOVENDOR)
doc:
godoc ./cmd
lint:
@go get github.com/golang/lint/golint
@go get -u honnef.co/go/tools/cmd/...
@go get -u honnef.co/go/tools/simple
golint $(NOVENDOR)
gosimple $(NOVENDOR)
clean:
@-rm $(GOPATH)/bin/$(IMAGE_NAME)-$(DIST)-$(ARCH)
@-rm $(GOPATH)/bin/$(IMAGE_NAME)-linux-$(ARCH)
@-rm $(GOPATH)/bin/$(IMAGE_NAME)-darwin-$(ARCH)