builder.Makefile 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 . -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. @goimports -w -local github.com/docker/api .
  38. cli:
  39. GOOS=${GOOS} GOARCH=${GOARCH} $(GO_BUILD) -o $(BINARY_WITH_EXTENSION) ./cli
  40. cross:
  41. @GOOS=linux GOARCH=amd64 $(GO_BUILD) -o $(BINARY)-linux-amd64 ./cli
  42. @GOOS=darwin GOARCH=amd64 $(GO_BUILD) -o $(BINARY)-darwin-amd64 ./cli
  43. @GOOS=windows GOARCH=amd64 $(GO_BUILD) -o $(BINARY)-windows-amd64.exe ./cli
  44. test:
  45. @go test ./...
  46. lint:
  47. golangci-lint run --timeout 10m0s ./...
  48. FORCE:
  49. .PHONY: all protos cli cross test lint