builder.Makefile 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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/v2
  14. EXTENSION:=
  15. ifeq ($(GOOS),windows)
  16. EXTENSION:=.exe
  17. endif
  18. STATIC_FLAGS=CGO_ENABLED=0
  19. GIT_TAG?=$(shell git describe --tags --match "v[0-9]*")
  20. LDFLAGS="-s -w -X $(PKG_NAME)/internal.Version=${GIT_TAG}"
  21. GO_BUILD=$(STATIC_FLAGS) go build -trimpath -ldflags=$(LDFLAGS)
  22. COMPOSE_BINARY?=bin/docker-compose
  23. COMPOSE_BINARY_WITH_EXTENSION=$(COMPOSE_BINARY)$(EXTENSION)
  24. WORK_DIR:=$(shell mktemp -d)
  25. TAGS:=
  26. ifdef BUILD_TAGS
  27. TAGS=-tags $(BUILD_TAGS)
  28. LINT_TAGS=--build-tags $(BUILD_TAGS)
  29. endif
  30. .PHONY: compose-plugin
  31. compose-plugin:
  32. GOOS=${GOOS} GOARCH=${GOARCH} $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY_WITH_EXTENSION) ./cmd
  33. .PHONY: cross
  34. cross:
  35. GOOS=linux GOARCH=amd64 $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-linux-x86_64 ./cmd
  36. GOOS=linux GOARCH=ppc64le $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-linux-ppc64le ./cmd
  37. GOOS=linux GOARCH=arm64 $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-linux-aarch64 ./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-x86_64 ./cmd
  42. GOOS=darwin GOARCH=arm64 $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-darwin-aarch64 ./cmd
  43. GOOS=windows GOARCH=amd64 $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY)-windows-x86_64.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