mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
update makefile for prerelease-lifecycle
This commit is contained in:
parent
4b0080d71f
commit
1c6210a319
@ -35,7 +35,7 @@ SHELL := /bin/bash
|
||||
# This rule collects all the generated file sets into a single rule. Other
|
||||
# rules should depend on this to ensure generated files are rebuilt.
|
||||
.PHONY: generated_files
|
||||
generated_files: gen_deepcopy gen_defaulter gen_conversion gen_openapi gen_bindata
|
||||
generated_files: gen_prerelease_lifecycle gen_deepcopy gen_defaulter gen_conversion gen_openapi gen_bindata
|
||||
|
||||
#
|
||||
# Helper logic to calculate Go's dependency DAG ourselves.
|
||||
@ -112,6 +112,90 @@ ALL_K8S_TAG_FILES := $(shell \
|
||||
#
|
||||
|
||||
|
||||
# prerelease-lifecycle generation
|
||||
#
|
||||
# Any package that wants prerelease-lifecycle functions generated must include a
|
||||
# comment-tag in column 0 of one file of the form:
|
||||
# // +k8s:prerelease-lifecycle-gen=true
|
||||
#
|
||||
|
||||
# The result file, in each pkg, of deep-copy generation.
|
||||
PRERELEASE_LIFECYCLE_BASENAME := $(GENERATED_FILE_PREFIX)prerelease-lifecycle
|
||||
PRERELEASE_LIFECYCLE_FILENAME := $(PRERELEASE_LIFECYCLE_BASENAME).go
|
||||
|
||||
# The tool used to generate deep copies.
|
||||
PRERELEASE_LIFECYCLE_GEN := $(BIN_DIR)/prerelease-lifecycle-gen
|
||||
|
||||
# Find all the directories that request deep-copy generation.
|
||||
ifeq ($(DBG_MAKEFILE),1)
|
||||
$(warning ***** finding all +k8s:prerelease-lifecycle-gen tags)
|
||||
endif
|
||||
PRERELEASE_LIFECYCLE_DIRS := $(shell \
|
||||
grep --color=never -l '+k8s:prerelease-lifecycle-gen=' $(ALL_K8S_TAG_FILES) \
|
||||
| xargs -n1 dirname \
|
||||
| LC_ALL=C sort -u \
|
||||
)
|
||||
PRERELEASE_LIFECYCLE_FILES := $(addsuffix /$(PRERELEASE_LIFECYCLE_FILENAME), $(PRERELEASE_LIFECYCLE_DIRS))
|
||||
|
||||
# Reset the list of packages that need generation.
|
||||
$(shell mkdir -p $$(dirname $(META_DIR)/$(PRERELEASE_LIFECYCLE_GEN)))
|
||||
$(shell rm -f $(META_DIR)/$(PRERELEASE_LIFECYCLE_GEN).todo)
|
||||
|
||||
# This rule aggregates the set of files to generate and then generates them all
|
||||
# in a single run of the tool.
|
||||
.PHONY: gen_prerelease_lifecycle
|
||||
gen_prerelease_lifecycle: $(PRERELEASE_LIFECYCLE_GEN) $(META_DIR)/$(PRERELEASE_LIFECYCLE_GEN).todo
|
||||
if [[ -s $(META_DIR)/$(PRERELEASE_LIFECYCLE_GEN).todo ]]; then \
|
||||
pkgs=$$(cat $(META_DIR)/$(PRERELEASE_LIFECYCLE_GEN).todo | paste -sd, -); \
|
||||
if [[ "$(DBG_CODEGEN)" == 1 ]]; then \
|
||||
echo "DBG: running $(PRERELEASE_LIFECYCLE_GEN) for $$pkgs"; \
|
||||
fi; \
|
||||
./hack/run-in-gopath.sh $(PRERELEASE_LIFECYCLE_GEN) \
|
||||
--v $(KUBE_VERBOSE) \
|
||||
--logtostderr \
|
||||
-i "$$pkgs" \
|
||||
-O $(PRERELEASE_LIFECYCLE_BASENAME) \
|
||||
"$$@"; \
|
||||
fi \
|
||||
|
||||
# For each dir in PRERELEASE_LIFECYCLE_DIRS, this establishes a dependency between the
|
||||
# output file and the input files that should trigger a rebuild.
|
||||
#
|
||||
# Note that this is a deps-only statement, not a full rule (see below). This
|
||||
# has to be done in a distinct step because wildcards don't work in static
|
||||
# pattern rules.
|
||||
#
|
||||
# The '$(eval)' is needed because this has a different RHS for each LHS, and
|
||||
# would otherwise produce results that make can't parse.
|
||||
$(foreach dir, $(PRERELEASE_LIFECYCLE_DIRS), $(eval \
|
||||
$(dir)/$(PRERELEASE_LIFECYCLE_FILENAME): $($(PRJ_SRC_PATH)/$(dir)) \
|
||||
))
|
||||
|
||||
# How to regenerate deep-copy code. This is a little slow to run, so we batch
|
||||
# it up and trigger the batch from the 'generated_files' target.
|
||||
$(META_DIR)/$(PRERELEASE_LIFECYCLE_GEN).todo: $(PRERELEASE_LIFECYCLE_FILES)
|
||||
|
||||
$(PRERELEASE_LIFECYCLE_FILES): $(PRERELEASE_LIFECYCLE_GEN)
|
||||
if [[ "$(DBG_CODEGEN)" == 1 ]]; then \
|
||||
echo "DBG: prerelease-lifecycle needed $(@D):"; \
|
||||
ls -lf --full-time $@ $? || true; \
|
||||
fi
|
||||
echo $(PRJ_SRC_PATH)/$(@D) >> $(META_DIR)/$(PRERELEASE_LIFECYCLE_GEN).todo
|
||||
|
||||
# How to build the generator tool. The deps for this are defined in
|
||||
# the $(GO_PKGDEPS_FILE), above.
|
||||
#
|
||||
# A word on the need to touch: This rule might trigger if, for example, a
|
||||
# non-Go file was added or deleted from a directory on which this depends.
|
||||
# This target needs to be reconsidered, but Go realizes it doesn't actually
|
||||
# have to be rebuilt. In that case, make will forever see the dependency as
|
||||
# newer than the binary, and try to "rebuild" it over and over. So we touch
|
||||
# it, and make is happy.
|
||||
$(PRERELEASE_LIFECYCLE_GEN): $(k8s.io/kubernetes/vendor/k8s.io/code-generator/cmd/prerelease-lifecycle-gen)
|
||||
KUBE_BUILD_PLATFORMS="" hack/make-rules/build.sh ./vendor/k8s.io/code-generator/cmd/prerelease-lifecycle-gen
|
||||
touch $@
|
||||
|
||||
|
||||
# Deep-copy generation
|
||||
#
|
||||
# Any package that wants deep-copy functions generated must include a
|
||||
|
Loading…
Reference in New Issue
Block a user