Debian Codegraph @

Makefile

raw symbols SCIP
1 # Metadata about this makefile and position
2 MKFILE_PATH := $(lastword $(MAKEFILE_LIST))
3 CURRENT_DIR := $(patsubst %/,%,$(dir $(realpath $(MKFILE_PATH))))
4
5 # Ensure GOPATH
6 GOPATH ?= $(HOME)/go
7
8 # List all our actual files, excluding vendor
9 GOFILES ?= $(shell go list $(FILES) | grep -v /vendor/)
10
11 # Tags specific for building
12 GOTAGS ?=
13
14 # Number of procs to use
15 GOMAXPROCS ?= 4
16
17 PROJECT := $(CURRENT_DIR:$(GOPATH)/src/%=%)
18 OWNER := $(notdir $(patsubst %/,%,$(dir $(PROJECT))))
19 NAME := $(notdir $(PROJECT))
20 EXTERNAL_TOOLS = \
21 github.com/golang/dep/cmd/dep
22
23 # Current system information
24 GOOS ?= $(shell go env GOOS)
25 GOARCH ?= $(shell go env GOARCH)
26 GOCACHE ?= $(shell go env GOCACHE)
27
28 # List of tests to run
29 FILES ?= ./...
30
31 # bootstrap installs the necessary go tools for development or build.
32 bootstrap:
33 @echo "==> Bootstrapping ${PROJECT}"
34 @for t in ${EXTERNAL_TOOLS}; do \
35 echo "--> Installing $$t" ; \
36 go get -u "$$t"; \
37 done
38 .PHONY: bootstrap
39
40 clean:
41 @echo "==> Cleaning ${NAME}"
42 @rm -rf pkg
43 .PHONY: clean
44
45 # build builds the binary into pkg/
46 build:
47 @echo "==> Building ${NAME} for ${GOOS}/${GOARCH}"
48 @env \
49 -i \
50 PATH="${PATH}" \
51 CGO_ENABLED="0" \
52 GOOS="${GOOS}" \
53 GOARCH="${GOARCH}" \
54 GOCACHE="${GOCACHE}" \
55 GOPATH="${GOPATH}" \
56 go build -a -o "pkg/${GOOS}_${GOARCH}/${NAME}" ${GOFILES}
57 .PHONY: build
58
59 # deps updates all dependencies for this project.
60 deps:
61 @echo "==> Updating deps for ${PROJECT}"
62 @dep ensure -update
63 @dep prune
64 .PHONY: deps
65
66 # dev builds and installs the
67 dev:
68 @echo "==> Installing ${NAME} for ${GOOS}/${GOARCH}"
69 @env \
70 -i \
71 PATH="${PATH}" \
72 CGO_ENABLED="0" \
73 GOOS="${GOOS}" \
74 GOARCH="${GOARCH}" \
75 GOCACHE="${GOCACHE}" \
76 GOPATH="${GOPATH}" \
77 go install ${GOFILES}
78 .PHONY: dev
79
80 # linux builds the linux binary
81 linux:
82 @env \
83 GOOS="linux" \
84 GOARCH="amd64" \
85 $(MAKE) -f "${MKFILE_PATH}" build
86 .PHONY: linux
87
88 # test runs the test suite.
89 test:
90 @echo "==> Testing ${NAME}"
91 @go test -timeout=30s -parallel=20 -tags="${GOTAGS}" ${GOFILES} ${TESTARGS}
92 .PHONY: test
93
94 # test-race runs the test suite.
95 test-race:
96 @echo "==> Testing ${NAME} (race)"
97 @go test -timeout=60s -race -tags="${GOTAGS}" ${GOFILES} ${TESTARGS}
98 .PHONY: test-race