1
0

builder.Makefile 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # Copyright 2020 Docker Compose CLI authors
  2. # Licensed under the Apache License, Version 2.0 (the "License");
  3. # you may not use this file except in compliance with the License.
  4. # You may obtain a copy of the License at
  5. # http://www.apache.org/licenses/LICENSE-2.0
  6. # Unless required by applicable law or agreed to in writing, software
  7. # distributed under the License is distributed on an "AS IS" BASIS,
  8. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. # See the License for the specific language governing permissions and
  10. # limitations under the License.
  11. GOOS?=$(shell go env GOOS)
  12. GOARCH?=$(shell go env GOARCH)
  13. PKG_NAME := github.com/docker/compose-cli
  14. PROTOS=$(shell find cli/server/protos -name \*.proto)
  15. EXTENSION:=
  16. ifeq ($(GOOS),windows)
  17. EXTENSION:=.exe
  18. endif
  19. STATIC_FLAGS=CGO_ENABLED=0
  20. GIT_TAG?=$(shell git describe --tags --match "v[0-9]*")
  21. LDFLAGS="-s -w -X $(PKG_NAME)/internal.Version=${GIT_TAG}"
  22. GO_BUILD=$(STATIC_FLAGS) go build -trimpath -ldflags=$(LDFLAGS)
  23. COMPOSE_BINARY?=bin/docker-compose
  24. COMPOSE_BINARY_WITH_EXTENSION=$(COMPOSE_BINARY)$(EXTENSION)
  25. WORK_DIR:=$(shell mktemp -d)
  26. TAGS:=
  27. ifdef BUILD_TAGS
  28. TAGS=-tags $(BUILD_TAGS)
  29. LINT_TAGS=--build-tags $(BUILD_TAGS)
  30. endif
  31. .PHONY: compose-plugin
  32. compose-plugin:
  33. GOOS=${GOOS} GOARCH=${GOARCH} $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY_WITH_EXTENSION) ./cmd
  34. .PHONY: cross
  35. cross:
  36. GOOS=linux GOARCH=amd64 $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-linux-amd64 ./cmd
  37. GOOS=linux GOARCH=arm64 $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-linux-arm64 ./cmd
  38. GOOS=linux GOARM=6 GOARCH=arm $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-linux-armv6 ./cmd
  39. GOOS=linux GOARM=7 GOARCH=arm $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-linux-armv7 ./cmd
  40. GOOS=linux GOARCH=s390x $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-linux-s390x ./cmd
  41. GOOS=darwin GOARCH=amd64 $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-darwin-amd64 ./cmd
  42. GOOS=darwin GOARCH=arm64 $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-darwin-arm64 ./cmd
  43. GOOS=windows GOARCH=amd64 $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-windows-amd64.exe ./cmd
  44. .PHONY: test
  45. test:
  46. go test $(TAGS) -cover $(shell go list $(TAGS) ./... | grep -vE 'e2e')
  47. .PHONY: lint
  48. lint:
  49. golangci-lint run $(LINT_TAGS) --timeout 10m0s ./...
  50. .PHONY: check-license-headers
  51. check-license-headers:
  52. ./scripts/validate/fileheader
  53. .PHONY: check-go-mod
  54. check-go-mod:
  55. ./scripts/validate/check-go-mod
  56. .PHONY: yamldocs
  57. yamldocs:
  58. go run docs/yaml/main/generate.go