builder.Makefile 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # Copyright (c) 2020 Docker Inc.
  2. # Permission is hereby granted, free of charge, to any person
  3. # obtaining a copy of this software and associated documentation
  4. # files (the "Software"), to deal in the Software without
  5. # restriction, including without limitation the rights to use, copy,
  6. # modify, merge, publish, distribute, sublicense, and/or sell copies
  7. # of the Software, and to permit persons to whom the Software is
  8. # furnished to do so, subject to the following conditions:
  9. # The above copyright notice and this permission notice shall be
  10. # included in all copies or substantial portions of the Software.
  11. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  12. # EXPRESS OR IMPLIED,
  13. # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  15. # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  16. # HOLDERS BE LIABLE FOR ANY CLAIM,
  17. # DAMAGES OR OTHER LIABILITY,
  18. # WHETHER IN AN ACTION OF CONTRACT,
  19. # TORT OR OTHERWISE,
  20. # ARISING FROM, OUT OF OR IN CONNECTION WITH
  21. # THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. GOOS?=$(shell go env GOOS)
  23. GOARCH?=$(shell go env GOARCH)
  24. PROTOS=$(shell find protos -name \*.proto)
  25. EXTENSION:=
  26. ifeq ($(GOOS),windows)
  27. EXTENSION:=.exe
  28. endif
  29. STATIC_FLAGS=CGO_ENABLED=0
  30. LDFLAGS:="-s -w"
  31. GO_BUILD=$(STATIC_FLAGS) go build -trimpath -ldflags=$(LDFLAGS)
  32. BINARY?=bin/docker
  33. BINARY_WITH_EXTENSION=$(BINARY)$(EXTENSION)
  34. all: cli
  35. protos:
  36. @protoc -I. --go_out=plugins=grpc,paths=source_relative:. ${PROTOS}
  37. cli:
  38. GOOS=${GOOS} GOARCH=${GOARCH} $(GO_BUILD) -o $(BINARY_WITH_EXTENSION) ./cli
  39. cross:
  40. @GOOS=linux GOARCH=amd64 $(GO_BUILD) -o $(BINARY)-linux-amd64 ./cli
  41. @GOOS=darwin GOARCH=amd64 $(GO_BUILD) -o $(BINARY)-darwin-amd64 ./cli
  42. @GOOS=windows GOARCH=amd64 $(GO_BUILD) -o $(BINARY)-windows-amd64.exe ./cli
  43. test:
  44. @go test -cover $(shell go list ./... | grep -vE 'e2e')
  45. lint:
  46. golangci-lint run --timeout 10m0s ./...
  47. FORCE:
  48. .PHONY: all protos cli cross test lint