...
1# Copyright The containerd Authors.
2
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6
7# http://www.apache.org/licenses/LICENSE-2.0
8
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15# Set an output prefix, which is the local directory if not specified
16PREFIX?=$(shell pwd)
17
18PKG=github.com/containerd/continuity
19
20PACKAGES=$(shell go list -mod=vendor ./... | grep -v /vendor/)
21TEST_REQUIRES_ROOT_PACKAGES=$(filter \
22 ${PACKAGES}, \
23 $(shell \
24 for f in $$(git grep -l testutil.RequiresRoot | grep -v Makefile); do \
25 d="$$(dirname $$f)"; \
26 [ "$$d" = "." ] && echo "${PKG}" && continue; \
27 echo "${PKG}/$$d"; \
28 done | sort -u) \
29 )
30
31.PHONY: clean all lint build test binaries
32.DEFAULT: default
33
34all: AUTHORS clean lint build test binaries
35
36AUTHORS: .mailmap .git/HEAD
37 git log --format='%aN <%aE>' | sort -fu > $@
38
39${PREFIX}/bin/continuity:
40 @echo "+ $@"
41 @(cd cmd/continuity && go build -mod=mod -o $@ ${GO_GCFLAGS} .)
42
43generate:
44 go generate -mod=vendor $(PACKAGES)
45
46lint:
47 @echo "+ $@"
48 @golangci-lint run
49
50build:
51 @echo "+ $@"
52 @go build -mod=vendor -v ${GO_LDFLAGS} $(PACKAGES)
53
54test:
55 @echo "+ $@"
56 @go test -mod=vendor $(PACKAGES)
57
58root-test:
59 @echo "+ $@"
60 @go test -exec sudo ${TEST_REQUIRES_ROOT_PACKAGES} -test.root
61
62test-compile:
63 @echo "+ $@"
64 @for pkg in $(PACKAGES); do go test -mod=vendor -c $$pkg; done
65
66binaries: ${PREFIX}/bin/continuity
67 @echo "+ $@"
68 @if [ x$$GOOS = xwindows ]; then echo "+ continuity -> continuity.exe"; mv ${PREFIX}/bin/continuity ${PREFIX}/bin/continuity.exe; fi
69
70clean:
71 @echo "+ $@"
72 @rm -rf "${PREFIX}/bin/continuity" "${PREFIX}/bin/continuity.exe"
73
View as plain text