Makefile 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #
  2. # github.com/docker/cli
  3. #
  4. # Sets the name of the company that produced the windows binary.
  5. PACKAGER_NAME ?=
  6. # The repository doesn't have a go.mod, but "go list", and "gotestsum"
  7. # expect to be run from a module.
  8. GO111MODULE=auto
  9. export GO111MODULE
  10. all: binary
  11. _:=$(shell ./scripts/warn-outside-container $(MAKECMDGOALS))
  12. .PHONY: dev
  13. dev: ## start a build container in interactive mode for in-container development
  14. @if [ -n "${DISABLE_WARN_OUTSIDE_CONTAINER}" ]; then \
  15. echo "you are already in the dev container"; \
  16. else \
  17. $(MAKE) -f docker.Makefile dev; \
  18. fi
  19. .PHONY: shell
  20. shell: dev ## alias for dev
  21. .PHONY: clean
  22. clean: ## remove build artifacts
  23. rm -rf ./build/* man/man[1-9] docs/yaml
  24. .PHONY: test
  25. test: test-unit ## run tests
  26. .PHONY: test-unit
  27. test-unit: ## run unit tests, to change the output format use: GOTESTSUM_FORMAT=(dots|short|standard-quiet|short-verbose|standard-verbose) make test-unit
  28. gotestsum -- $${TESTDIRS:-$(shell go list ./... | grep -vE '/vendor/|/e2e/')} $(TESTFLAGS)
  29. .PHONY: test-coverage
  30. test-coverage: ## run test coverage
  31. mkdir -p $(CURDIR)/build/coverage
  32. gotestsum -- $(shell go list ./... | grep -vE '/vendor/|/e2e/') -coverprofile=$(CURDIR)/build/coverage/coverage.txt
  33. .PHONY: lint
  34. lint: ## run all the lint tools
  35. golangci-lint run
  36. .PHONY: shellcheck
  37. shellcheck: ## run shellcheck validation
  38. find scripts/ contrib/completion/bash -type f | grep -v scripts/winresources | grep -v '.*.ps1' | xargs shellcheck
  39. .PHONY: fmt
  40. fmt: ## run gofumpt (if present) or gofmt
  41. @if command -v gofumpt > /dev/null; then \
  42. gofumpt -w -d -lang=1.23 . ; \
  43. else \
  44. go list -f {{.Dir}} ./... | xargs gofmt -w -s -d ; \
  45. fi
  46. .PHONY: binary
  47. binary: ## build executable for Linux
  48. ./scripts/build/binary
  49. .PHONY: dynbinary
  50. dynbinary: ## build dynamically linked binary
  51. GO_LINKMODE=dynamic ./scripts/build/binary
  52. .PHONY: plugins
  53. plugins: ## build example CLI plugins
  54. scripts/build/plugins
  55. .PHONY: vendor
  56. vendor: ## update vendor with go modules
  57. rm -rf vendor
  58. scripts/with-go-mod.sh scripts/vendor update
  59. .PHONY: validate-vendor
  60. validate-vendor: ## validate vendor
  61. scripts/with-go-mod.sh scripts/vendor validate
  62. .PHONY: mod-outdated
  63. mod-outdated: ## check outdated dependencies
  64. scripts/with-go-mod.sh scripts/vendor outdated
  65. .PHONY: authors
  66. authors: ## generate AUTHORS file from git history
  67. scripts/docs/generate-authors.sh
  68. .PHONY: completion
  69. completion: shell-completion
  70. completion: ## generate and install the shell-completion scripts
  71. # Note: this uses system-wide paths, and so may overwrite completion
  72. # scripts installed as part of deb/rpm packages.
  73. #
  74. # Given that this target is intended to debug/test updated versions, we could
  75. # consider installing in per-user (~/.config, XDG_DATA_DIR) paths instead, but
  76. # this will add more complexity.
  77. #
  78. # See https://github.com/docker/cli/pull/5770#discussion_r1927772710
  79. install -D -p -m 0644 ./build/completion/bash/docker /usr/share/bash-completion/completions/docker
  80. install -D -p -m 0644 ./build/completion/fish/docker.fish debian/docker-ce-cli/usr/share/fish/vendor_completions.d/docker.fish
  81. install -D -p -m 0644 ./build/completion/zsh/_docker debian/docker-ce-cli/usr/share/zsh/vendor-completions/_docker
  82. build/docker:
  83. # This target is used by the "shell-completion" target, which requires either
  84. # "binary" or "dynbinary" to have been built. We don't want to trigger those
  85. # to prevent replacing a static binary with a dynamic one, or vice-versa.
  86. @echo "Run 'make binary' or 'make dynbinary' first" && exit 1
  87. .PHONY: shell-completion
  88. shell-completion: build/docker # requires either "binary" or "dynbinary" to be built.
  89. shell-completion: ## generate shell-completion scripts
  90. @ ./scripts/build/shell-completion
  91. .PHONY: manpages
  92. manpages: ## generate man pages from go source and markdown
  93. scripts/with-go-mod.sh scripts/docs/generate-man.sh
  94. .PHONY: mddocs
  95. mddocs: ## generate markdown files from go source
  96. scripts/with-go-mod.sh scripts/docs/generate-md.sh
  97. .PHONY: yamldocs
  98. yamldocs: ## generate documentation YAML files consumed by docs repo
  99. scripts/with-go-mod.sh scripts/docs/generate-yaml.sh
  100. .PHONY: help
  101. help: ## print this help
  102. @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9_-]+:.*?## / {gsub("\\\\n",sprintf("\n%22c",""), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)