summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHervé Beraud <hberaud@redhat.com>2019-02-06 18:27:00 +0100
committerHervé Beraud <hberaud@redhat.com>2019-02-06 20:15:53 +0100
commite0c3af6523b5ce11877f63002c137b4c9f74a84b (patch)
tree7b6e545c7269d7a2211f12465ce80e4593e346ff
parentca6ab2029caae9fcea35579c87634a0520284aae (diff)
downloadpodman-e0c3af6523b5ce11877f63002c137b4c9f74a84b.tar.gz
podman-e0c3af6523b5ce11877f63002c137b4c9f74a84b.tar.bz2
podman-e0c3af6523b5ce11877f63002c137b4c9f74a84b.zip
Generate make helping message dynamicaly.
Generate make helping message dynamicaly by using python code snippet inside Makefile. All commented make targets will be added to the help message. To be added to the helping message comment need to start with '## '. These specials comments are detected by the python code. Python code generate the helping output from these results. Notice that this commit introduce a dependency with python (compatible python 2 and 3). Signed-off-by: Hervé Beraud <hberaud@redhat.com>
-rw-r--r--Makefile62
1 files changed, 35 insertions, 27 deletions
diff --git a/Makefile b/Makefile
index ae791e5e0..726f805aa 100644
--- a/Makefile
+++ b/Makefile
@@ -72,15 +72,23 @@ all: binaries docs
default: help
+define PRINT_HELP_PYSCRIPT
+import re, sys
+
+print("Usage: make <target>")
+cmds = {}
+for line in sys.stdin:
+ match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
+ if match:
+ target, help = match.groups()
+ cmds.update({target: help})
+for cmd in sorted(cmds):
+ print(" * '%s' - %s" % (cmd, cmds[cmd]))
+endef
+export PRINT_HELP_PYSCRIPT
+
help:
- @echo "Usage: make <target>"
- @echo
- @echo " * 'install' - Install binaries to system locations"
- @echo " * 'binaries' - Build podman"
- @echo " * 'integration' - Execute integration tests"
- @echo " * 'clean' - Clean artifacts"
- @echo " * 'lint' - Execute the source code linter"
- @echo " * 'gofmt' - Verify the source code gofmt"
+ @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
.gopathok:
ifeq ("$(wildcard $(GOPKGDIR))","")
@@ -89,11 +97,11 @@ ifeq ("$(wildcard $(GOPKGDIR))","")
endif
touch $@
-lint: .gopathok varlink_generate
+lint: .gopathok varlink_generate ## Execute the source code linter
@echo "checking lint"
@./.tool/lint
-gofmt:
+gofmt: ## Verify the source code gofmt
find . -name '*.go' ! -path './vendor/*' -exec gofmt -s -w {} \+
git diff --exit-code
@@ -109,16 +117,16 @@ test/checkseccomp/checkseccomp: .gopathok $(wildcard test/checkseccomp/*.go)
test/goecho/goecho: .gopathok $(wildcard test/goecho/*.go)
$(GO) build -ldflags '$(LDFLAGS)' -o $@ $(PROJECT)/test/goecho
-podman: .gopathok $(PODMAN_VARLINK_DEPENDENCIES)
+podman: .gopathok $(PODMAN_VARLINK_DEPENDENCIES) ## Build with podman
$(GO) build -ldflags '$(LDFLAGS_PODMAN)' -tags "$(BUILDTAGS)" -o bin/$@ $(PROJECT)/cmd/podman
-podman-remote: .gopathok $(PODMAN_VARLINK_DEPENDENCIES)
+podman-remote: .gopathok $(PODMAN_VARLINK_DEPENDENCIES) ## Build with podman on remote environment
$(GO) build -ldflags '$(LDFLAGS_PODMAN)' -tags "$(BUILDTAGS) remoteclient" -o bin/$@ $(PROJECT)/cmd/podman
-podman-remote-darwin: .gopathok $(PODMAN_VARLINK_DEPENDENCIES)
+podman-remote-darwin: .gopathok $(PODMAN_VARLINK_DEPENDENCIES) ## Build with podman on remote OSX environment
GOOS=darwin $(GO) build -ldflags '$(LDFLAGS_PODMAN)' -tags "remoteclient containers_image_openpgp exclude_graphdriver_devicemapper" -o bin/$@ $(PROJECT)/cmd/podman
-local-cross: $(CROSS_BUILD_TARGETS)
+local-cross: $(CROSS_BUILD_TARGETS) ## Cross local compilation
bin/podman.cross.%: .gopathok
TARGET="$*"; \
@@ -126,7 +134,7 @@ bin/podman.cross.%: .gopathok
GOARCH="$${TARGET##*.}" \
$(GO) build -ldflags '$(LDFLAGS_PODMAN)' -tags '$(BUILDTAGS_CROSS)' -o "$@" $(PROJECT)/cmd/podman
-clean:
+clean: ## Clean artifacts
rm -rf \
.gopathok \
_output \
@@ -146,16 +154,16 @@ clean:
find . -name \*~ -delete
find . -name \#\* -delete
-libpodimage:
+libpodimage: ## Build the libpod image
${CONTAINER_RUNTIME} build -t ${LIBPOD_IMAGE} .
dbuild: libpodimage
${CONTAINER_RUNTIME} run --name=${LIBPOD_INSTANCE} --privileged -v ${PWD}:/go/src/${PROJECT} --rm ${LIBPOD_IMAGE} make all
-test: libpodimage
+test: libpodimage ## Run tests on built image
${CONTAINER_RUNTIME} run -e STORAGE_OPTIONS="--storage-driver=vfs" -e TESTFLAGS -e OCI_RUNTIME -e CGROUP_MANAGER=cgroupfs -e TRAVIS -t --privileged --rm -v ${CURDIR}:/go/src/${PROJECT} ${LIBPOD_IMAGE} make clean all localunit install.catatonit localintegration
-integration: libpodimage
+integration: libpodimage ## Execute integration tests
${CONTAINER_RUNTIME} run -e STORAGE_OPTIONS="--storage-driver=vfs" -e TESTFLAGS -e OCI_RUNTIME -e CGROUP_MANAGER=cgroupfs -e TRAVIS -t --privileged --rm -v ${CURDIR}:/go/src/${PROJECT} ${LIBPOD_IMAGE} make clean all install.catatonit localintegration
integration.fedora:
@@ -164,10 +172,10 @@ integration.fedora:
integration.centos:
DIST=CentOS sh .papr_prepare.sh
-shell: libpodimage
+shell: libpodimage ## Run the built image and attach a shell
${CONTAINER_RUNTIME} run -e STORAGE_OPTIONS="--storage-driver=vfs" -e CGROUP_MANAGER=cgroupfs -e TESTFLAGS -e OCI_RUNTIME -e TRAVIS -it --privileged --rm -v ${CURDIR}:/go/src/${PROJECT} ${LIBPOD_IMAGE} sh
-testunit: libpodimage
+testunit: libpodimage ## Run unittest on the built image
${CONTAINER_RUNTIME} run -e STORAGE_OPTIONS="--storage-driver=vfs" -e TESTFLAGS -e CGROUP_MANAGER=cgroupfs -e OCI_RUNTIME -e TRAVIS -t --privileged --rm -v ${CURDIR}:/go/src/${PROJECT} ${LIBPOD_IMAGE} make localunit
localunit: test/goecho/goecho varlink_generate
@@ -188,16 +196,16 @@ localsystem: .install.ginkgo .install.gomega
system.test-binary: .install.ginkgo .install.gomega
$(GO) test -c ./test/system
-perftest:
+perftest: ## Build perf tests
$ cd contrib/perftest;go build
-run-perftest: perftest
+run-perftest: perftest ## Build and run perf tests
$ contrib/perftest/perftest
vagrant-check:
BOX=$(BOX) sh ./vagrant.sh
-binaries: varlink_generate podman podman-remote
+binaries: varlink_generate podman podman-remote ## Build podman
install.catatonit:
./hack/install_catatonit.sh
@@ -210,12 +218,12 @@ MANPAGES ?= $(MANPAGES_MD:%.md=%)
$(MANPAGES): %: %.md .gopathok
@sed -e 's/\((podman.*\.md)\)//' -e 's/\[\(podman.*\)\]/\1/' $< | $(GOMD2MAN) -in /dev/stdin -out $@
-docs: $(MANPAGES)
+docs: $(MANPAGES) ## Generate documentation
docker-docs: docs
(cd docs; ./dckrman.sh *.1)
-changelog:
+changelog: ## Generate changelog
@echo "Creating changelog from $(CHANGELOG_BASE) to $(CHANGELOG_TARGET)"
$(eval TMPFILE := $(shell mktemp))
$(shell cat changelog.txt > $(TMPFILE))
@@ -225,7 +233,7 @@ changelog:
$(shell cat $(TMPFILE) >> changelog.txt)
$(shell rm $(TMPFILE))
-install: .gopathok install.bin install.man install.cni install.systemd
+install: .gopathok install.bin install.man install.cni install.systemd ## Install binaries to system locations
install.bin:
install ${SELINUXOPT} -d -m 755 $(BINDIR)
@@ -278,7 +286,7 @@ uninstall:
.PHONY: install.tools
-install.tools: .install.gitvalidation .install.gometalinter .install.md2man .install.ginkgo
+install.tools: .install.gitvalidation .install.gometalinter .install.md2man .install.ginkgo ## Install needed tools
.install.vndr: .gopathok
$(GO) get github.com/LK4D4/vndr