@@ -9,14 +9,29 @@ VERSION=$(shell git describe --match 'v[0-9]*' --dirty='.m' --always)
99
1010PKG =github.com/containerd/containerd
1111
12+ GOOS ?= $(shell go env GOOS)
13+ WHALE = "🐳"
14+ ONI = "👹"
15+ ifeq ("$(OS ) ", "Windows_NT")
16+ WHALE="+"
17+ ONI="-"
18+ endif
19+
1220# Project packages.
1321PACKAGES =$(shell go list ./... | grep -v /vendor/)
1422INTEGRATION_PACKAGE =${PKG}/integration
1523SNAPSHOT_PACKAGES =$(shell go list ./snapshot/...)
1624
1725# Project binaries.
18- COMMANDS =ctr containerd containerd-shim protoc-gen-gogoctrd dist ctrd-protobuild
26+ COMMANDS =ctr containerd protoc-gen-gogoctrd dist ctrd-protobuild
27+ ifneq ("$(GOOS ) ", "windows")
28+ COMMANDS += containerd-shim
29+ endif
1930BINARIES =$(addprefix bin/,$(COMMANDS ) )
31+ ifeq ("$(GOOS ) ", "windows")
32+ BINARY_SUFFIX=".exe"
33+ endif
34+
2035
2136GO_LDFLAGS =-ldflags "-X $(PKG ) .Version=$(VERSION ) -X $(PKG ) .Package=$(PKG ) "
2237
@@ -36,45 +51,45 @@ AUTHORS: .mailmap .git/HEAD
3651 git log --format=' %aN <%aE>' | sort -fu > $@
3752
3853setup : # # install dependencies
39- @echo " 🐳 $@ "
54+ @echo " $( WHALE ) $@ "
4055 # TODO(stevvooe): Install these from the vendor directory
4156 @go get -u github.com/golang/lint/golint
4257 # @go get -u github.com/kisielk/errcheck
4358 @go get -u github.com/gordonklaus/ineffassign
4459
4560generate : protos
46- @echo " 🐳 $@ "
61+ @echo " $( WHALE ) $@ "
4762 @PATH=${ROOTDIR} /bin:${PATH} go generate -x ${PACKAGES}
4863
4964protos : bin/protoc-gen-gogoctrd bin/ctrd-protobuild # # generate protobuf
50- @echo " 🐳 $@ "
65+ @echo " $( WHALE ) $@ "
5166 @PATH=${ROOTDIR} /bin:${PATH} ctrd-protobuild ${PACKAGES}
5267
5368checkprotos : protos # # check if protobufs needs to be generated again
54- @echo " 🐳 $@ "
69+ @echo " $( WHALE ) $@ "
5570 @test -z " $$ (git status --short | grep " .pb.go" | tee /dev/stderr)" || \
5671 (( git diff | cat) && \
57- (echo " 👹 please run 'make generate' when making changes to proto files" && false))
72+ (echo " $( ONI ) please run 'make generate' when making changes to proto files" && false))
5873
5974# Depends on binaries because vet will silently fail if it can't load compiled
6075# imports
6176vet : binaries # # run go vet
62- @echo " 🐳 $@ "
77+ @echo " $( WHALE ) $@ "
6378 @test -z " $$ (go vet ${PACKAGES} 2>&1 | grep -v 'constant [0-9]* not a string in call to Errorf' | egrep -v '(timestamp_test.go|duration_test.go|exit status 1)' | tee /dev/stderr)"
6479
6580fmt : # # run go fmt
66- @echo " 🐳 $@ "
81+ @echo " $( WHALE ) $@ "
6782 @test -z " $$ (gofmt -s -l . | grep -v vendor/ | grep -v " .pb.go$$ " | tee /dev/stderr)" || \
68- (echo " 👹 please format Go code with 'gofmt -s -w'" && false)
83+ (echo " $( ONI ) please format Go code with 'gofmt -s -w'" && false)
6984 @test -z " $$ (find . -path ./vendor -prune -o ! -name timestamp.proto ! -name duration.proto -name '*.proto' -type f -exec grep -Hn -e " ^ " {} \; | tee /dev/stderr)" || \
70- (echo " 👹 please indent proto files with tabs only" && false)
85+ (echo " $( ONI ) please indent proto files with tabs only" && false)
7186 @test -z " $$ (find . -path ./vendor -prune -o -name '*.proto' -type f -exec grep -EHn " [_ ]id = " {} \; | grep -v gogoproto.customname | tee /dev/stderr)" || \
72- (echo " 👹 id fields in proto files must have a gogoproto.customname set" && false)
87+ (echo " $( ONI ) id fields in proto files must have a gogoproto.customname set" && false)
7388 @test -z " $$ (find . -path ./vendor -prune -o -name '*.proto' -type f -exec grep -Hn " Meta meta = " {} \; | grep -v '(gogoproto.nullable) = false' | tee /dev/stderr)" || \
74- (echo " 👹 meta fields in proto files must have option (gogoproto.nullable) = false" && false)
89+ (echo " $( ONI ) meta fields in proto files must have option (gogoproto.nullable) = false" && false)
7590
7691lint : # # run go lint
77- @echo " 🐳 $@ "
92+ @echo " $( WHALE ) $@ "
7893 @test -z " $$ (golint ./... | grep -v vendor/ | grep -v " .pb.go:" | tee /dev/stderr)"
7994
8095dco : # # dco check
@@ -86,57 +101,57 @@ else
86101endif
87102
88103ineffassign : # # run ineffassign
89- @echo " 🐳 $@ "
104+ @echo " $( WHALE ) $@ "
90105 @test -z " $$ (ineffassign . | grep -v vendor/ | grep -v " .pb.go:" | tee /dev/stderr)"
91106
92107# errcheck: ## run go errcheck
93- # @echo "🐳 $@"
108+ # @echo "$(WHALE) $@"
94109# @test -z "$$(errcheck ./... | grep -v vendor/ | grep -v ".pb.go:" | tee /dev/stderr)"
95110
96111build : # # build the go packages
97- @echo " 🐳 $@ "
112+ @echo " $( WHALE ) $@ "
98113 @go build -i -v ${GO_LDFLAGS} ${GO_GCFLAGS} ${PACKAGES}
99114
100115test : # # run tests, except integration tests and tests that require root
101- @echo " 🐳 $@ "
116+ @echo " $( WHALE ) $@ "
102117 @go test ${TESTFLAGS} $(filter-out ${INTEGRATION_PACKAGE},${PACKAGES})
103118
104119root-test : # # run tests, except integration tests
105- @echo " 🐳 $@ "
120+ @echo " $( WHALE ) $@ "
106121 @go test ${TESTFLAGS} ${SNAPSHOT_PACKAGES} -test.root
107122
108123integration : # # run integration tests
109- @echo " 🐳 $@ "
124+ @echo " $( WHALE ) $@ "
110125 @go test ${TESTFLAGS} ${INTEGRATION_PACKAGE}
111126
112127FORCE :
113128
114129# Build a binary from a cmd.
115130bin/% : cmd/% FORCE
116131 @test $$(go list ) = " ${PKG} " || \
117- (echo " 👹 Please correctly set up your Go build environment. This project must be located at <GOPATH>/src/${PKG} " && false)
118- @echo " 🐳 $@ "
119- @go build -i -o $@ ${GO_LDFLAGS} ${GO_GCFLAGS} ./$<
132+ (echo " $( ONI ) Please correctly set up your Go build environment. This project must be located at <GOPATH>/src/${PKG} " && false)
133+ @echo " $( WHALE ) $@ ${BINARY_SUFFIX} "
134+ @go build -i -o $@ ${BINARY_SUFFIX} ${GO_LDFLAGS} ${GO_GCFLAGS} ./$<
120135
121136binaries : $(BINARIES ) # # build binaries
122- @echo " 🐳 $@ "
137+ @echo " $( WHALE ) $@ "
123138
124139clean : # # clean up binaries
125- @echo " 🐳 $@ "
140+ @echo " $( WHALE ) $@ "
126141 @rm -f $(BINARIES )
127142
128143install : # # install binaries
129- @echo " 🐳 $@ $( BINARIES) "
144+ @echo " $( WHALE ) $@ $( BINARIES) "
130145 @mkdir -p $(DESTDIR ) /bin
131146 @install $(BINARIES ) $(DESTDIR ) /bin
132147
133148uninstall :
134- @echo " 🐳 $@ "
149+ @echo " $( WHALE ) $@ "
135150 @rm -f $(addprefix $(DESTDIR ) /bin/,$(notdir $(BINARIES ) ) )
136151
137152
138153coverage : # # generate coverprofiles from the unit tests, except tests that require root
139- @echo " 🐳 $@ "
154+ @echo " $( WHALE ) $@ "
140155 @rm -f coverage.txt
141156 ( for pkg in $( filter-out ${INTEGRATION_PACKAGE} ,${PACKAGES} ) ; do \
142157 go test -i ${TESTFLAGS} -test.short -coverprofile=coverage.out -covermode=atomic $$ pkg || exit ; \
@@ -152,18 +167,18 @@ coverage: ## generate coverprofiles from the unit tests, except tests that requi
152167 done )
153168
154169root-coverage : # # generae coverage profiles for the unit tests
155- @echo " 🐳 $@ "
170+ @echo " $( WHALE ) $@ "
156171 @ ( for pkg in ${SNAPSHOT_PACKAGES} ; do \
157172 go test -i ${TESTFLAGS} -test.short -coverprofile=" ../../../$$ pkg/coverage.txt" -covermode=atomic $$ pkg -test.root || exit ; \
158173 go test ${TESTFLAGS} -test.short -coverprofile=" ../../../$$ pkg/coverage.txt" -covermode=atomic $$ pkg -test.root || exit ; \
159174 done )
160175
161176coverage-integration : # # generate coverprofiles from the integration tests
162- @echo " 🐳 $@ "
177+ @echo " $( WHALE ) $@ "
163178 go test ${TESTFLAGS} -test.short -coverprofile=" ../../../${INTEGRATION_PACKAGE} /coverage.txt" -covermode=atomic ${INTEGRATION_PACKAGE}
164179
165180vendor :
166- @echo " 🐳 $@ "
181+ @echo " $( WHALE ) $@ "
167182 @vndr
168183
169184help : # # this help
0 commit comments