cert-manager/make/util.mk
Ashley Davis 35f2206404
change name of bin dir to _bin by default and make it a variable
This is needed because go and other tools will ignore directories
starting with "_" or "." but would treat a dir called "bin" as a regular
directory.

This in turn meant that when we vendored Go in bin, these tools would by
default scan the whole stdlib included with the bundled vendored go.

See https://pkg.go.dev/cmd/go#hdr-Package_lists_and_patterns for details

Signed-off-by: Ashley Davis <ashley.davis@jetstack.io>
2022-06-21 16:34:26 +01:00

21 lines
814 B
Makefile

# Utility helper function to "get every go file in all except binary / make dirs"
# The first argument $(1) defines the commands which the find output are piped into
# Note that the "-not \( ... -prune \)" syntax is important here, if a little trickier to
# understand. It causes find to prune entire search branches and not search inside the path.
# If we used "-not -path X" instead, find would _still look inside X_.
define get-sources
$(shell find . -not \( -path "./$(BINDIR)/*" -prune \) -not \( -path "./bin/*" -prune \) -not \( -path "./make/*" -prune \) -name "*.go" | $(1))
endef
.PHONY: print-bindir
print-bindir:
@echo $(BINDIR)
.PHONY: print-sources
print-sources:
@echo $(SOURCES)
.PHONY: print-source-dirs
print-source-dirs:
@echo $(call get-sources,cut -d'/' -f2 | sort | uniq | tr '\n' ' ')