2020-09-22 13:13:00 +03:00
|
|
|
# Copyright 2020 Docker Compose CLI authors
|
2020-06-18 17:13:24 +03:00
|
|
|
|
|
|
|
# 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 16:27:27 +03:00
|
|
|
|
2020-06-02 12:53:13 +03:00
|
|
|
GOOS?=$(shell go env GOOS)
|
|
|
|
GOARCH?=$(shell go env GOARCH)
|
2020-05-01 16:27:27 +03:00
|
|
|
|
2020-10-07 16:33:27 +03:00
|
|
|
PKG_NAME := github.com/docker/compose-cli
|
|
|
|
|
2021-01-19 18:48:54 +03:00
|
|
|
PROTOS=$(shell find cli/server/protos -name \*.proto)
|
2020-05-01 16:27:27 +03:00
|
|
|
|
2020-06-02 12:53:13 +03:00
|
|
|
EXTENSION:=
|
2020-05-04 23:31:59 +03:00
|
|
|
ifeq ($(GOOS),windows)
|
2020-06-02 12:53:13 +03:00
|
|
|
EXTENSION:=.exe
|
2020-05-04 23:31:59 +03:00
|
|
|
endif
|
|
|
|
|
2020-05-20 15:32:56 +03:00
|
|
|
STATIC_FLAGS=CGO_ENABLED=0
|
2020-07-07 16:48:09 +03:00
|
|
|
|
|
|
|
GIT_TAG?=$(shell git describe --tags --match "v[0-9]*")
|
2020-06-25 14:50:16 +03:00
|
|
|
|
2021-05-27 13:10:37 +03:00
|
|
|
LDFLAGS="-s -w -X $(PKG_NAME)/internal.Version=${GIT_TAG}"
|
2020-06-02 12:53:13 +03:00
|
|
|
GO_BUILD=$(STATIC_FLAGS) go build -trimpath -ldflags=$(LDFLAGS)
|
2020-05-04 23:31:59 +03:00
|
|
|
|
2020-06-02 12:53:13 +03:00
|
|
|
BINARY?=bin/docker
|
2020-05-04 23:31:59 +03:00
|
|
|
BINARY_WITH_EXTENSION=$(BINARY)$(EXTENSION)
|
2020-05-01 16:27:27 +03:00
|
|
|
|
2021-03-05 12:50:06 +03:00
|
|
|
COMPOSE_BINARY?=bin/docker-compose
|
|
|
|
COMPOSE_BINARY_WITH_EXTENSION=$(COMPOSE_BINARY)$(EXTENSION)
|
|
|
|
|
2020-09-22 18:13:56 +03:00
|
|
|
WORK_DIR:=$(shell mktemp -d)
|
|
|
|
|
2020-06-15 18:41:59 +03:00
|
|
|
TAGS:=
|
|
|
|
ifdef BUILD_TAGS
|
|
|
|
TAGS=-tags $(BUILD_TAGS)
|
2020-11-18 19:18:15 +03:00
|
|
|
LINT_TAGS=--build-tags $(BUILD_TAGS)
|
2020-06-15 18:41:59 +03:00
|
|
|
endif
|
|
|
|
|
2020-09-21 13:21:41 +03:00
|
|
|
.PHONY: protos
|
2020-05-01 16:27:27 +03:00
|
|
|
protos:
|
2020-06-25 14:50:16 +03:00
|
|
|
protoc -I. --go_out=plugins=grpc,paths=source_relative:. ${PROTOS}
|
2020-05-01 16:27:27 +03:00
|
|
|
|
2020-09-21 13:21:41 +03:00
|
|
|
.PHONY: cli
|
2021-05-27 13:10:37 +03:00
|
|
|
cli:
|
2020-06-15 18:41:59 +03:00
|
|
|
GOOS=${GOOS} GOARCH=${GOARCH} $(GO_BUILD) $(TAGS) -o $(BINARY_WITH_EXTENSION) ./cli
|
2020-05-01 16:27:27 +03:00
|
|
|
|
2020-09-21 13:21:41 +03:00
|
|
|
.PHONY: cross
|
2021-05-27 13:10:37 +03:00
|
|
|
cross:
|
2020-06-25 14:50:16 +03:00
|
|
|
GOOS=linux GOARCH=amd64 $(GO_BUILD) $(TAGS) -o $(BINARY)-linux-amd64 ./cli
|
2021-02-18 15:58:31 +03:00
|
|
|
GOOS=linux GOARCH=arm64 $(GO_BUILD) $(TAGS) -o $(BINARY)-linux-arm64 ./cli
|
2021-04-08 18:32:11 +03:00
|
|
|
GOOS=linux GOARM=6 GOARCH=arm $(GO_BUILD) $(TAGS) -o $(BINARY)-linux-armv6 ./cli
|
|
|
|
GOOS=linux GOARM=7 GOARCH=arm $(GO_BUILD) $(TAGS) -o $(BINARY)-linux-armv7 ./cli
|
2021-06-28 13:36:46 +03:00
|
|
|
GOOS=linux GOARCH=s390x $(GO_BUILD) $(TAGS) -o $(BINARY)-linux-s390x ./cli
|
2020-06-25 14:50:16 +03:00
|
|
|
GOOS=darwin GOARCH=amd64 $(GO_BUILD) $(TAGS) -o $(BINARY)-darwin-amd64 ./cli
|
2021-02-18 15:58:31 +03:00
|
|
|
GOOS=darwin GOARCH=arm64 $(GO_BUILD) $(TAGS) -o $(BINARY)-darwin-arm64 ./cli
|
2020-06-25 14:50:16 +03:00
|
|
|
GOOS=windows GOARCH=amd64 $(GO_BUILD) $(TAGS) -o $(BINARY)-windows-amd64.exe ./cli
|
2020-05-01 16:27:27 +03:00
|
|
|
|
2020-09-21 13:21:41 +03:00
|
|
|
.PHONY: test
|
2020-05-01 16:27:27 +03:00
|
|
|
test:
|
2021-01-26 19:35:21 +03:00
|
|
|
go test $(TAGS) -cover $(shell go list $(TAGS) ./... | grep -vE 'e2e')
|
2020-05-01 16:27:27 +03:00
|
|
|
|
2020-09-21 13:21:41 +03:00
|
|
|
.PHONY: lint
|
2020-05-05 00:50:00 +03:00
|
|
|
lint:
|
2020-11-18 19:18:15 +03:00
|
|
|
golangci-lint run $(LINT_TAGS) --timeout 10m0s ./...
|
2020-05-05 00:50:00 +03:00
|
|
|
|
2020-09-21 13:21:41 +03:00
|
|
|
.PHONY: import-restrictions
|
2020-08-18 17:10:34 +03:00
|
|
|
import-restrictions:
|
|
|
|
import-restrictions --configuration import-restrictions.yaml
|
|
|
|
|
2023-01-31 21:56:50 +03:00
|
|
|
.PHONY: check-license-headers
|
2020-08-17 16:18:47 +03:00
|
|
|
check-license-headers:
|
|
|
|
./scripts/validate/fileheader
|
|
|
|
|
2020-09-21 13:21:41 +03:00
|
|
|
.PHONY: check-go-mod
|
2020-08-18 12:53:17 +03:00
|
|
|
check-go-mod:
|
|
|
|
./scripts/validate/check-go-mod
|
|
|
|
|
2021-03-08 17:47:24 +03:00
|
|
|
.PHONY: yamldocs
|
|
|
|
yamldocs:
|
2023-01-31 21:56:50 +03:00
|
|
|
go run docs/yaml/main/generate.go
|