Debian Codegraph @

cli/Makefile

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