-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
60 lines (46 loc) · 1.54 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
SHELL := /bin/bash
GO := GO15VENDOREXPERIMENT=1 go
NAME := faas-reverse-geocoding
OS := $(shell uname)
MAIN_GO := geocode.go
ROOT_PACKAGE := $(GIT_PROVIDER)/saidsef/$(NAME)
GO_VERSION := $(shell $(GO) version | sed -e 's/^[^0-9.]*\([0-9.]*\).*/\1/')
PACKAGE_DIRS := $(shell $(GO) list ./... | grep -v /vendor/)
PKGS := $(shell go list ./... | grep -v /vendor | grep -v generated)
PKGS := $(subst :,_,$(PKGS))
BUILDFLAGS := ''
CGO_ENABLED = 0
VENDOR_DIR=vendor
all: build
check: fmt build test
build:
CGO_ENABLED=$(CGO_ENABLED) $(GO) build -ldflags $(BUILDFLAGS) -o bin/$(NAME) $(MAIN_GO)
test:
CGO_ENABLED=$(CGO_ENABLED) $(GO) test $(PACKAGE_DIRS) -test.v
full: $(PKGS)
install:
GOBIN=${GOPATH}/bin $(GO) install -ldflags $(BUILDFLAGS) $(MAIN_GO)
fmt:
@FORMATTED=`$(GO) fmt $(PACKAGE_DIRS)`
@([[ ! -z "$(FORMATTED)" ]] && printf "Fixed unformatted files:\n$(FORMATTED)") || true
clean:
rm -rf build release bin
linux:
CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=amd64 $(GO) build -ldflags $(BUILDFLAGS) -o bin/$(NAME)-amd64 $(MAIN_GO)
arm64:
CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=arm64 $(GO) build -ldflags $(BUILDFLAGS) -o bin/$(NAME)-arm64 $(MAIN_GO)
.PHONY: release clean
GOLINT := $(GOPATH)/bin/golint
$(GOLINT):
go get github.com/golang/lint/golint
$(PKGS): $(GOLINT) $(FGT)
@echo "LINTING"
@echo "VETTING"
@go vet -v $@
@echo "TESTING"
@go test -v $@
.PHONY: lint
lint: vendor | $(PKGS) $(GOLINT) # ❷
@cd $(BASE) && ret=0 && for pkg in $(PKGS); do \
test -z "$$($(GOLINT) $$pkg | tee /dev/stderr)" || ret=1 ; \
done ; exit $$ret