mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Simplify build for defaulter
This commit is contained in:
		@@ -35,9 +35,9 @@ SHELL := /bin/bash
 | 
				
			|||||||
# This rule collects all the generated file sets into a single rule.  Other
 | 
					# This rule collects all the generated file sets into a single rule.  Other
 | 
				
			||||||
# rules should depend on this to ensure generated files are rebuilt.
 | 
					# rules should depend on this to ensure generated files are rebuilt.
 | 
				
			||||||
.PHONY: generated_files
 | 
					.PHONY: generated_files
 | 
				
			||||||
generated_files: gen_deepcopy 
 | 
					generated_files: gen_deepcopy gen_defaulter
 | 
				
			||||||
 | 
					
 | 
				
			||||||
##TH##FIXMEgen_defaulter gen_conversion gen_openapi gen_bindata
 | 
					##TH##FIXME gen_conversion gen_openapi gen_bindata
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
@@ -203,160 +203,100 @@ $(DEEPCOPY_GEN): $(k8s.io/kubernetes/vendor/k8s.io/code-generator/cmd/deepcopy-g
 | 
				
			|||||||
	touch $@
 | 
						touch $@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
##TH### Defaulter generation
 | 
					# Defaulter generation
 | 
				
			||||||
##TH###
 | 
					#
 | 
				
			||||||
##TH### Any package that wants defaulter functions generated must include a
 | 
					# Any package that wants defaulter functions generated must include a
 | 
				
			||||||
##TH### comment-tag in column 0 of one file of the form:
 | 
					# comment-tag in column 0 of one file of the form:
 | 
				
			||||||
##TH###     // +k8s:defaulter-gen=<VALUE>
 | 
					#     // +k8s:defaulter-gen=<VALUE>
 | 
				
			||||||
##TH###
 | 
					#
 | 
				
			||||||
##TH### The <VALUE> depends on context:
 | 
					# The <VALUE> depends on context:
 | 
				
			||||||
##TH###     on types:
 | 
					#     on types:
 | 
				
			||||||
##TH###       true:  always generate a defaulter for this type
 | 
					#       true:  always generate a defaulter for this type
 | 
				
			||||||
##TH###       false: never generate a defaulter for this type
 | 
					#       false: never generate a defaulter for this type
 | 
				
			||||||
##TH###     on functions:
 | 
					#     on functions:
 | 
				
			||||||
##TH###       covers: if the function name matches SetDefault_NAME, instructs
 | 
					#       covers: if the function name matches SetDefault_NAME, instructs
 | 
				
			||||||
##TH###               the generator not to recurse
 | 
					#               the generator not to recurse
 | 
				
			||||||
##TH###     on packages:
 | 
					#     on packages:
 | 
				
			||||||
##TH###       FIELDNAME: any object with a field of this name is a candidate
 | 
					#       FIELDNAME: any object with a field of this name is a candidate
 | 
				
			||||||
##TH###                  for having a defaulter generated
 | 
					#                  for having a defaulter generated
 | 
				
			||||||
##TH##
 | 
					
 | 
				
			||||||
##TH### The result file, in each pkg, of defaulter generation.
 | 
					# The result file, in each pkg, of defaulter generation.
 | 
				
			||||||
##TH##DEFAULTER_BASENAME := $(GENERATED_FILE_PREFIX)defaults
 | 
					DEFAULTER_BASENAME := $(GENERATED_FILE_PREFIX)defaults
 | 
				
			||||||
##TH##DEFAULTER_FILENAME := $(DEFAULTER_BASENAME).go
 | 
					DEFAULTER_FILENAME := $(DEFAULTER_BASENAME).go
 | 
				
			||||||
##TH##
 | 
					
 | 
				
			||||||
##TH### The tool used to generate defaulters.
 | 
					# The tool used to generate defaulters.
 | 
				
			||||||
##TH##DEFAULTER_GEN := $(BIN_DIR)/defaulter-gen
 | 
					DEFAULTER_GEN := $(BIN_DIR)/defaulter-gen
 | 
				
			||||||
##TH##
 | 
					
 | 
				
			||||||
##TH### All directories that request any form of defaulter generation.
 | 
					# All directories that request any form of defaulter generation.
 | 
				
			||||||
##TH##ifeq ($(DBG_MAKEFILE),1)
 | 
					ifeq ($(DBG_MAKEFILE),1)
 | 
				
			||||||
##TH##    $(warning ***** finding all +k8s:defaulter-gen tags)
 | 
					    $(warning ***** finding all +k8s:defaulter-gen tags)
 | 
				
			||||||
##TH##endif
 | 
					endif
 | 
				
			||||||
##TH##DEFAULTER_DIRS := $(shell                                            \
 | 
					DEFAULTER_DIRS := $(shell                                            \
 | 
				
			||||||
##TH##    grep --color=never -l '+k8s:defaulter-gen=' $(ALL_K8S_TAG_FILES) \
 | 
					    grep --color=never -l '+k8s:defaulter-gen=' $(ALL_K8S_TAG_FILES) \
 | 
				
			||||||
##TH##        | xargs -n1 dirname                                          \
 | 
					        | xargs -n1 dirname                                          \
 | 
				
			||||||
##TH##        | LC_ALL=C sort -u                                           \
 | 
					        | LC_ALL=C sort -u                                           \
 | 
				
			||||||
##TH##)
 | 
					)
 | 
				
			||||||
##TH##
 | 
					
 | 
				
			||||||
##TH##DEFAULTER_FILES := $(addsuffix /$(DEFAULTER_FILENAME), $(DEFAULTER_DIRS))
 | 
					DEFAULTER_FILES := $(addsuffix /$(DEFAULTER_FILENAME), $(DEFAULTER_DIRS))
 | 
				
			||||||
##TH##
 | 
					
 | 
				
			||||||
##TH### This rule aggregates the set of files to generate and then generates them all
 | 
					# Reset the list of packages that need generation.
 | 
				
			||||||
##TH### in a single run of the tool.
 | 
					$(shell mkdir -p $$(dirname $(META_DIR)/$(DEFAULTER_GEN)))
 | 
				
			||||||
##TH##.PHONY: gen_defaulter
 | 
					$(shell rm -f $(META_DIR)/$(DEFAULTER_GEN).todo)
 | 
				
			||||||
##TH##gen_defaulter: $(DEFAULTER_FILES) $(DEFAULTER_GEN)
 | 
					
 | 
				
			||||||
##TH##	if [[ -s $(META_DIR)/$(DEFAULTER_GEN).todo ]]; then                 \
 | 
					# This rule aggregates the set of files to generate and then generates them all
 | 
				
			||||||
##TH##	    pkgs=$$(cat $(META_DIR)/$(DEFAULTER_GEN).todo | paste -sd, -);  \
 | 
					# in a single run of the tool.
 | 
				
			||||||
##TH##	    if [[ "$(DBG_CODEGEN)" == 1 ]]; then                            \
 | 
					.PHONY: gen_defaulter
 | 
				
			||||||
##TH##	        echo "DBG: running $(DEFAULTER_GEN) for $$pkgs";            \
 | 
					gen_defaulter: $(DEFAULTER_GEN) $(META_DIR)/$(DEFAULTER_GEN).todo
 | 
				
			||||||
##TH##	    fi;                                                             \
 | 
						if [[ -s $(META_DIR)/$(DEFAULTER_GEN).todo ]]; then                 \
 | 
				
			||||||
##TH##	    ./hack/run-in-gopath.sh $(DEFAULTER_GEN)                        \
 | 
						    pkgs=$$(cat $(META_DIR)/$(DEFAULTER_GEN).todo | paste -sd, -);  \
 | 
				
			||||||
##TH##	        --v $(KUBE_VERBOSE)                                         \
 | 
						    if [[ "$(DBG_CODEGEN)" == 1 ]]; then                            \
 | 
				
			||||||
##TH##	        --logtostderr                                               \
 | 
						        echo "DBG: running $(DEFAULTER_GEN) for $$pkgs";            \
 | 
				
			||||||
##TH##	        -i "$$pkgs"                                                 \
 | 
						    fi;                                                             \
 | 
				
			||||||
##TH##	        --extra-peer-dirs $$(echo $(addprefix $(PRJ_SRC_PATH)/, $(DEFAULTER_DIRS)) | sed 's/ /,/g') \
 | 
						    ./hack/run-in-gopath.sh $(DEFAULTER_GEN)                        \
 | 
				
			||||||
##TH##	        -O $(DEFAULTER_BASENAME)                                    \
 | 
						        --v $(KUBE_VERBOSE)                                         \
 | 
				
			||||||
##TH##	        "$$@";                                                      \
 | 
						        --logtostderr                                               \
 | 
				
			||||||
##TH##	fi
 | 
						        -i "$$pkgs"                                                 \
 | 
				
			||||||
##TH##
 | 
						        --extra-peer-dirs $$(echo $(addprefix $(PRJ_SRC_PATH)/, $(DEFAULTER_DIRS)) | sed 's/ /,/g') \
 | 
				
			||||||
##TH### For each dir in DEFAULTER_DIRS, this establishes a dependency between the
 | 
						        -O $(DEFAULTER_BASENAME)                                    \
 | 
				
			||||||
##TH### output file and the input files that should trigger a rebuild.
 | 
						        "$$@";                                                      \
 | 
				
			||||||
##TH###
 | 
						fi
 | 
				
			||||||
##TH### The variable value was set in $(GOFILES_META) and included as part of the
 | 
					
 | 
				
			||||||
##TH### dependency management logic.
 | 
					# For each dir in DEFAULTER_DIRS, this establishes a dependency between the
 | 
				
			||||||
##TH###
 | 
					# output file and the input files that should trigger a rebuild.
 | 
				
			||||||
##TH### Note that this is a deps-only statement, not a full rule (see below).  This
 | 
					#
 | 
				
			||||||
##TH### has to be done in a distinct step because wildcards don't work in static
 | 
					# Note that this is a deps-only statement, not a full rule (see below for that).
 | 
				
			||||||
##TH### pattern rules.
 | 
					#
 | 
				
			||||||
##TH###
 | 
					# The '$(eval)' is needed because this has a different RHS for each LHS, and
 | 
				
			||||||
##TH### The '$(eval)' is needed because this has a different RHS for each LHS, and
 | 
					# would otherwise produce results that make can't parse.
 | 
				
			||||||
##TH### would otherwise produce results that make can't parse.
 | 
					$(foreach dir, $(DEFAULTER_DIRS), $(eval                     \
 | 
				
			||||||
##TH###
 | 
					    $(dir)/$(DEFAULTER_FILENAME): $($(PRJ_SRC_PATH)/$(dir))  \
 | 
				
			||||||
##TH### We depend on the $(GOFILES_META).stamp to detect when the set of input files
 | 
					))
 | 
				
			||||||
##TH### has changed.  This allows us to detect deleted input files.
 | 
					
 | 
				
			||||||
##TH##$(foreach dir, $(DEFAULTER_DIRS), $(eval                                    \
 | 
					# How to regenerate defaulter code.  This is a little slow to run, so we batch
 | 
				
			||||||
##TH##    $(dir)/$(DEFAULTER_FILENAME): $(META_DIR)/$(dir)/$(GOFILES_META).stamp  \
 | 
					# it up and trigger the batch from the 'generated_files' target.
 | 
				
			||||||
##TH##                                   $(gofiles__$(dir))                       \
 | 
					$(META_DIR)/$(DEFAULTER_GEN).todo: $(DEFAULTER_FILES)
 | 
				
			||||||
##TH##))
 | 
					
 | 
				
			||||||
##TH##
 | 
					$(DEFAULTER_FILES): $(DEFAULTER_GEN)
 | 
				
			||||||
##TH### For each dir in DEFAULTER_DIRS, for each target in $(defaulters__$(dir)),
 | 
						if [[ "$(DBG_CODEGEN)" == 1 ]]; then         \
 | 
				
			||||||
##TH### this establishes a dependency between the output file and the input files
 | 
						    echo "DBG: defaulter needed $(@D): $?";  \
 | 
				
			||||||
##TH### that should trigger a rebuild.
 | 
						    ls -lf --full-time $@ $? || true;        \
 | 
				
			||||||
##TH###
 | 
						fi
 | 
				
			||||||
##TH### The variable value was set in $(GOFILES_META) and included as part of the
 | 
						echo $(PRJ_SRC_PATH)/$(@D) >> $(META_DIR)/$(DEFAULTER_GEN).todo
 | 
				
			||||||
##TH### dependency management logic.
 | 
					
 | 
				
			||||||
##TH###
 | 
					# How to build the generator tool.  The deps for this are defined in
 | 
				
			||||||
##TH### Note that this is a deps-only statement, not a full rule (see below).  This
 | 
					# the $(GO_PKGDEPS_FILE), above.
 | 
				
			||||||
##TH### has to be done in a distinct step because wildcards don't work in static
 | 
					#
 | 
				
			||||||
##TH### pattern rules.
 | 
					# A word on the need to touch: This rule might trigger if, for example, a
 | 
				
			||||||
##TH###
 | 
					# non-Go file was added or deleted from a directory on which this depends.
 | 
				
			||||||
##TH### The '$(eval)' is needed because this has a different RHS for each LHS, and
 | 
					# This target needs to be reconsidered, but Go realizes it doesn't actually
 | 
				
			||||||
##TH### would otherwise produce results that make can't parse.
 | 
					# have to be rebuilt.  In that case, make will forever see the dependency as
 | 
				
			||||||
##TH###
 | 
					# newer than the binary, and try to "rebuild" it over and over.  So we touch
 | 
				
			||||||
##TH### We depend on the $(GOFILES_META).stamp to detect when the set of input files
 | 
					# it, and make is happy.
 | 
				
			||||||
##TH### has changed.  This allows us to detect deleted input files.
 | 
					$(DEFAULTER_GEN): $(k8s.io/kubernetes/vendor/k8s.io/code-generator/cmd/defaulter-gen)
 | 
				
			||||||
##TH##$(foreach dir, $(DEFAULTER_DIRS),                                               \
 | 
						hack/make-rules/build.sh ./vendor/k8s.io/code-generator/cmd/defaulter-gen
 | 
				
			||||||
##TH##    $(foreach tgt, $(defaulters__$(dir)), $(eval                                \
 | 
						touch $@
 | 
				
			||||||
##TH##        $(dir)/$(DEFAULTER_FILENAME): $(META_DIR)/$(tgt)/$(GOFILES_META).stamp  \
 | 
					
 | 
				
			||||||
##TH##                                       $(gofiles__$(tgt))                       \
 | 
					
 | 
				
			||||||
##TH##    ))                                                                          \
 | 
					 | 
				
			||||||
##TH##)
 | 
					 | 
				
			||||||
##TH##
 | 
					 | 
				
			||||||
##TH### Unilaterally remove any leftovers from previous runs.
 | 
					 | 
				
			||||||
##TH##$(shell rm -f $(META_DIR)/$(DEFAULTER_GEN)*.todo)
 | 
					 | 
				
			||||||
##TH##
 | 
					 | 
				
			||||||
##TH### How to regenerate defaulter code.  This is a little slow to run, so we batch
 | 
					 | 
				
			||||||
##TH### it up and trigger the batch from the 'generated_files' target.
 | 
					 | 
				
			||||||
##TH##$(DEFAULTER_FILES): $(DEFAULTER_GEN)
 | 
					 | 
				
			||||||
##TH##	mkdir -p $$(dirname $(META_DIR)/$(DEFAULTER_GEN))
 | 
					 | 
				
			||||||
##TH##	if [[ "$(DBG_CODEGEN)" == 1 ]]; then         \
 | 
					 | 
				
			||||||
##TH##	    echo "DBG: defaulter needed $(@D): $?";  \
 | 
					 | 
				
			||||||
##TH##	    ls -lf --full-time $@ $? || true;        \
 | 
					 | 
				
			||||||
##TH##	fi
 | 
					 | 
				
			||||||
##TH##	echo $(PRJ_SRC_PATH)/$(@D) >> $(META_DIR)/$(DEFAULTER_GEN).todo
 | 
					 | 
				
			||||||
##TH##
 | 
					 | 
				
			||||||
##TH### This calculates the dependencies for the generator tool, so we only rebuild
 | 
					 | 
				
			||||||
##TH### it when needed.  It is PHONY so that it always runs, but it only updates the
 | 
					 | 
				
			||||||
##TH### file if the contents have actually changed.  We 'sinclude' this later.
 | 
					 | 
				
			||||||
##TH##.PHONY: $(META_DIR)/$(DEFAULTER_GEN).mk
 | 
					 | 
				
			||||||
##TH##$(META_DIR)/$(DEFAULTER_GEN).mk:
 | 
					 | 
				
			||||||
##TH##	mkdir -p $(@D);                                                       \
 | 
					 | 
				
			||||||
##TH##	(echo -n "$(DEFAULTER_GEN): ";                                        \
 | 
					 | 
				
			||||||
##TH##	 ./hack/run-in-gopath.sh go list                                      \
 | 
					 | 
				
			||||||
##TH##	     -f '{{.ImportPath}}{{"\n"}}{{range .Deps}}{{.}}{{"\n"}}{{end}}'  \
 | 
					 | 
				
			||||||
##TH##	     ./vendor/k8s.io/code-generator/cmd/defaulter-gen                 \
 | 
					 | 
				
			||||||
##TH##	     | grep --color=never "^$(PRJ_SRC_PATH)/"                         \
 | 
					 | 
				
			||||||
##TH##	     | xargs ./hack/run-in-gopath.sh go list                          \
 | 
					 | 
				
			||||||
##TH##	         -f '{{$$d := .Dir}}{{$$d}}{{"\n"}}{{range .GoFiles}}{{$$d}}/{{.}}{{"\n"}}{{end}}'  \
 | 
					 | 
				
			||||||
##TH##	     | paste -sd' ' -                                                 \
 | 
					 | 
				
			||||||
##TH##	     | sed 's/ / \\=,/g'                                              \
 | 
					 | 
				
			||||||
##TH##	     | tr '=,' '\n\t'                                                 \
 | 
					 | 
				
			||||||
##TH##	     | sed "s|$$(pwd -P)/||";                                         \
 | 
					 | 
				
			||||||
##TH##	) > $@.tmp;                                                           \
 | 
					 | 
				
			||||||
##TH##	if ! cmp -s $@.tmp $@; then                                           \
 | 
					 | 
				
			||||||
##TH##	    if [[ "$(DBG_CODEGEN)" == 1 ]]; then                              \
 | 
					 | 
				
			||||||
##TH##	        echo "DBG: $(DEFAULTER_GEN).mk changed";                      \
 | 
					 | 
				
			||||||
##TH##	    fi;                                                               \
 | 
					 | 
				
			||||||
##TH##	    cat $@.tmp > $@;                                                  \
 | 
					 | 
				
			||||||
##TH##	    rm -f $@.tmp;                                                     \
 | 
					 | 
				
			||||||
##TH##	fi
 | 
					 | 
				
			||||||
##TH##
 | 
					 | 
				
			||||||
##TH### Include dependency info for the generator tool.  This will cause the rule of
 | 
					 | 
				
			||||||
##TH### the same name to be considered and if it is updated, make will restart.
 | 
					 | 
				
			||||||
##TH##sinclude $(META_DIR)/$(DEFAULTER_GEN).mk
 | 
					 | 
				
			||||||
##TH##
 | 
					 | 
				
			||||||
##TH### How to build the generator tool.  The deps for this are defined in
 | 
					 | 
				
			||||||
##TH### the $(DEFAULTER_GEN).mk, above.
 | 
					 | 
				
			||||||
##TH###
 | 
					 | 
				
			||||||
##TH### A word on the need to touch: This rule might trigger if, for example, a
 | 
					 | 
				
			||||||
##TH### non-Go file was added or deleted from a directory on which this depends.
 | 
					 | 
				
			||||||
##TH### This target needs to be reconsidered, but Go realizes it doesn't actually
 | 
					 | 
				
			||||||
##TH### have to be rebuilt.  In that case, make will forever see the dependency as
 | 
					 | 
				
			||||||
##TH### newer than the binary, and try to rebuild it over and over.  So we touch it,
 | 
					 | 
				
			||||||
##TH### and make is happy.
 | 
					 | 
				
			||||||
##TH##$(DEFAULTER_GEN):
 | 
					 | 
				
			||||||
##TH##	hack/make-rules/build.sh ./vendor/k8s.io/code-generator/cmd/defaulter-gen
 | 
					 | 
				
			||||||
##TH##	touch $@
 | 
					 | 
				
			||||||
##TH##
 | 
					 | 
				
			||||||
##TH###
 | 
					 | 
				
			||||||
##TH### Conversion generation
 | 
					##TH### Conversion generation
 | 
				
			||||||
##TH###
 | 
					##TH###
 | 
				
			||||||
##TH### Any package that wants conversion functions generated must include one or
 | 
					##TH### Any package that wants conversion functions generated must include one or
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user