forked from omniscale/imposm3
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
99 lines (72 loc) · 2.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
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
.PHONY: test all build clean test test-system test-unit update_version docs
PROTOFILES=$(shell find . -name \*.proto | grep -v vendor/ )
PBGOFILES=$(patsubst %.proto,%.pb.go,$(PROTOFILES))
GOFILES=$(shell find . \( -name \*.go ! -name version.go \) | grep -v .pb.go )
# for protoc-gen-go
export PATH := $(GOPATH)/bin:$(PATH)
GOLDFLAGS=-ldflags '-r $${ORIGIN}/lib $(VERSION_LDFLAGS)'
GO:=go
ifdef LEVELDB_POST_121
GOTAGS=-tags="ldbpost121"
endif
BUILD_DATE=$(shell date +%Y%m%d)
BUILD_REV=$(shell git rev-parse --short HEAD)
BUILD_BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
TAG=$(shell git name-rev --tags --name-only $(BUILD_REV))
ifeq ($(TAG),undefined)
BUILD_VERSION=$(BUILD_BRANCH)-$(BUILD_DATE)-$(BUILD_REV)
else
# use TAG but strip v of v1.2.3
BUILD_VERSION=$(TAG:v%=%)
endif
VERSION_LDFLAGS=-X github.com/omniscale/imposm3.Version=$(BUILD_VERSION)
all: build test
imposm: $(GOFILES)
$(GO) build $(GOTAGS) $(GOLDFLAGS) ./cmd/imposm
build: imposm
clean:
rm -f imposm
(cd test && make clean)
test: imposm system-test-files
$(GO) test $(GOTAGS) -i `$(GO) list ./... | grep -Ev '/vendor'`
$(GO) test $(GOTAGS) `$(GO) list ./... | grep -Ev '/vendor'`
test-unit: imposm
$(GO) test $(GOTAGS) -i `$(GO) list ./... | grep -Ev '/test|/vendor'`
$(GO) test $(GOTAGS) `$(GO) list ./... | grep -Ev '/test|/vendor'`
test-system: imposm
(cd test && make test)
system-test-files:
(cd test && make files)
regen-protobuf: $(PBGOFILES)
%.pb.go: %.proto
protoc --proto_path=$(GOPATH)/src:$(GOPATH)/src/github.com/omniscale/imposm3/vendor/github.com/gogo/protobuf/protobuf:. --gogofaster_out=. $^
docs:
(cd docs && make html)
REMOTE_DOC_LOCATION = omniscale.de:/opt/www/imposm.org/docs/imposm3
DOC_VERSION = 3.0.0
upload-docs: docs
rsync -a -v -P -z docs/_build/html/ $(REMOTE_DOC_LOCATION)/$(DOC_VERSION)
build-license-deps:
rm LICENSE.deps
find ./vendor -iname license\* -exec bash -c '\
dep=$${1#./vendor/}; \
(echo -e "========== $$dep ==========\n"; cat $$1; echo -e "\n\n") \
| fold -s -w 80 \
>> LICENSE.deps \
' _ {} \;
comma:= ,
empty:=
space:= $(empty) $(empty)
COVER_IGNORE:='/vendor|/cmd'
COVER_PACKAGES:= $(shell $(GO) list ./... | grep -Ev $(COVER_IGNORE))
COVER_PACKAGES_LIST:=$(subst $(space),$(comma),$(COVER_PACKAGES))
test-coverage:
mkdir -p .coverprofile
rm -f .coverprofile/*
$(GO) list -f '{{if gt (len .TestGoFiles) 0}}"$(GO) test -covermode count -coverprofile ./.coverprofile/{{.Name}}-$$$$.coverprofile -coverpkg $(COVER_PACKAGES_LIST) {{.ImportPath}}"{{end}}' ./... \
| grep -Ev $(COVER_IGNORE) \
| xargs -n 1 bash -c
$(GOPATH)/bin/gocovmerge .coverprofile/*.coverprofile > overalls.coverprofile
rm -rf .coverprofile
test-coverage-html: test-coverage
$(GO) tool cover -html overalls.coverprofile