This repository has been archived by the owner on Mar 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
/
Makefile
65 lines (53 loc) · 1.47 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
# Package configuration
PROJECT := bblfsh-sdk
# Environment
BASE_PATH := $(shell pwd)
# Assets configuration
ASSETS_PATH := $(BASE_PATH)/etc
ASSETS := $(shell ls $(ASSETS_PATH))
ASSETS_PACKAGE := assets
BINDATA_FILE := bindata.go
BINDATA_CMD := go run github.com/kevinburke/go-bindata/go-bindata/
# Go parameters
GO_CMD = go
GO_TEST = $(GO_CMD) test -v
GO_GET = $(GO_CMD) get -v
# Coverage
COVERAGE_REPORT = coverage.txt
COVERAGE_PROFILE = profile.out
COVERAGE_MODE = atomic
all: bindata
bindata: $(ASSETS)
$(ASSETS):
chmod -R go=r $(ASSETS_PATH)/$@; \
$(BINDATA_CMD) \
-pkg $@ \
-modtime 1 \
-nocompress \
-prefix $(ASSETS_PATH)/$@ \
-o $(ASSETS_PACKAGE)/$@/$(BINDATA_FILE) \
$(ASSETS_PATH)/$@/...
$(GO_CMD) fmt ./$(ASSETS_PACKAGE)/...
test:
$(GO_TEST) ./...
test-coverage:
echo "" > $(COVERAGE_REPORT); \
for dir in `$(GO_CMD) list ./... | egrep -v '/(vendor|etc)/'`; do \
$(GO_TEST) $$dir -coverprofile=$(COVERAGE_PROFILE) -covermode=$(COVERAGE_MODE); \
if [ $$? != 0 ]; then \
exit 2; \
fi; \
if [ -f $(COVERAGE_PROFILE) ]; then \
cat $(COVERAGE_PROFILE) >> $(COVERAGE_REPORT); \
rm $(COVERAGE_PROFILE); \
fi; \
done
validate-commit: bindata
git status --untracked-files=no --porcelain | grep -qe '..*'; \
if [ $$? -eq 0 ] ; then \
git diff|cat; \
echo >&2 "generated bindata is out of sync"; \
echo >&2 "Re-run 'make bindata' and commit the updates."; \
exit 2; \
fi
.PHONY: bindata test test-coverage validate-commit driver-tpl $(ASSETS)