1# General
2WORKDIR = $(PWD)
3
4# Go parameters
5GOCMD = go
6GOTEST = $(GOCMD) test -v
7
8# Git config
9GIT_VERSION ?=
10GIT_DIST_PATH ?= $(PWD)/.git-dist
11GIT_REPOSITORY = http://github.com/git/git.git
12
13# Coverage
14COVERAGE_REPORT = coverage.txt
15COVERAGE_PROFILE = profile.out
16COVERAGE_MODE = atomic
17
18ifneq ($(origin CI), undefined)
19 WORKDIR := $(GOPATH)/src/gopkg.in/src-d/go-git.v4
20endif
21
22build-git:
23 @if [ -f $(GIT_DIST_PATH)/git ]; then \
24 echo "nothing to do, using cache $(GIT_DIST_PATH)"; \
25 else \
26 git clone $(GIT_REPOSITORY) -b $(GIT_VERSION) --depth 1 --single-branch $(GIT_DIST_PATH); \
27 cd $(GIT_DIST_PATH); \
28 make configure; \
29 ./configure; \
30 make all; \
31 fi
32
33test:
34 @cd $(WORKDIR); \
35 $(GOTEST) ./...
36
37test-coverage:
38 @cd $(WORKDIR); \
39 echo "" > $(COVERAGE_REPORT); \
40 for dir in `find . -name "*.go" | grep -o '.*/' | sort | uniq`; do \
41 $(GOTEST) $$dir -coverprofile=$(COVERAGE_PROFILE) -covermode=$(COVERAGE_MODE); \
42 if [ $$? != 0 ]; then \
43 exit 2; \
44 fi; \
45 if [ -f $(COVERAGE_PROFILE) ]; then \
46 cat $(COVERAGE_PROFILE) >> $(COVERAGE_REPORT); \
47 rm $(COVERAGE_PROFILE); \
48 fi; \
49 done; \
50
51clean:
52 rm -rf $(GIT_DIST_PATH)