2020-06-18 16:13:24 +02:00
|
|
|
# Copyright 2020 The 2020 Docker, Inc.
|
|
|
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
2020-05-01 15:27:27 +02:00
|
|
|
|
2020-06-02 11:53:13 +02:00
|
|
|
GOOS?=$(shell go env GOOS)
|
|
|
|
GOARCH?=$(shell go env GOARCH)
|
2020-05-01 15:27:27 +02:00
|
|
|
|
2020-05-25 14:58:22 +02:00
|
|
|
PROTOS=$(shell find protos -name \*.proto)
|
2020-05-01 15:27:27 +02:00
|
|
|
|
2020-06-02 11:53:13 +02:00
|
|
|
EXTENSION:=
|
2020-05-04 22:31:59 +02:00
|
|
|
ifeq ($(GOOS),windows)
|
2020-06-02 11:53:13 +02:00
|
|
|
EXTENSION:=.exe
|
2020-05-04 22:31:59 +02:00
|
|
|
endif
|
|
|
|
|
2020-05-20 14:32:56 +02:00
|
|
|
STATIC_FLAGS=CGO_ENABLED=0
|
2020-06-25 13:50:16 +02:00
|
|
|
GIT_TAG=$(shell git describe --tags --match "v[0-9]*")
|
|
|
|
|
|
|
|
LDFLAGS="-s -w -X main.version=${GIT_TAG}"
|
2020-06-02 11:53:13 +02:00
|
|
|
GO_BUILD=$(STATIC_FLAGS) go build -trimpath -ldflags=$(LDFLAGS)
|
2020-05-04 22:31:59 +02:00
|
|
|
|
2020-06-02 11:53:13 +02:00
|
|
|
BINARY?=bin/docker
|
2020-05-04 22:31:59 +02:00
|
|
|
BINARY_WITH_EXTENSION=$(BINARY)$(EXTENSION)
|
2020-05-01 15:27:27 +02:00
|
|
|
|
2020-06-15 17:41:59 +02:00
|
|
|
TAGS:=
|
|
|
|
ifdef BUILD_TAGS
|
|
|
|
TAGS=-tags $(BUILD_TAGS)
|
|
|
|
endif
|
|
|
|
|
2020-05-01 15:27:27 +02:00
|
|
|
all: cli
|
|
|
|
|
|
|
|
protos:
|
2020-06-25 13:50:16 +02:00
|
|
|
protoc -I. --go_out=plugins=grpc,paths=source_relative:. ${PROTOS}
|
2020-05-01 15:27:27 +02:00
|
|
|
|
|
|
|
cli:
|
2020-06-15 17:41:59 +02:00
|
|
|
GOOS=${GOOS} GOARCH=${GOARCH} $(GO_BUILD) $(TAGS) -o $(BINARY_WITH_EXTENSION) ./cli
|
2020-05-01 15:27:27 +02:00
|
|
|
|
2020-05-04 10:32:30 +02:00
|
|
|
cross:
|
2020-06-25 13:50:16 +02:00
|
|
|
GOOS=linux GOARCH=amd64 $(GO_BUILD) $(TAGS) -o $(BINARY)-linux-amd64 ./cli
|
|
|
|
GOOS=darwin GOARCH=amd64 $(GO_BUILD) $(TAGS) -o $(BINARY)-darwin-amd64 ./cli
|
|
|
|
GOOS=windows GOARCH=amd64 $(GO_BUILD) $(TAGS) -o $(BINARY)-windows-amd64.exe ./cli
|
2020-05-01 15:27:27 +02:00
|
|
|
|
|
|
|
test:
|
2020-06-25 13:50:16 +02:00
|
|
|
go test $(TAGS) -cover $(shell go list ./... | grep -vE 'e2e')
|
2020-05-01 15:27:27 +02:00
|
|
|
|
2020-05-04 23:50:00 +02:00
|
|
|
lint:
|
|
|
|
golangci-lint run --timeout 10m0s ./...
|
|
|
|
|
2020-05-01 15:27:27 +02:00
|
|
|
FORCE:
|
|
|
|
|
2020-05-04 23:50:00 +02:00
|
|
|
.PHONY: all protos cli cross test lint
|