From 90e0ac54b903117bf5f9810c7b94782113ffb6e2 Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Sun, 29 Apr 2018 18:39:01 +0100 Subject: [PATCH] Simplify Makefile for genfiles a bit --- build/root/Makefile.generated_files | 98 ++++++++++++----------------- 1 file changed, 39 insertions(+), 59 deletions(-) diff --git a/build/root/Makefile.generated_files b/build/root/Makefile.generated_files index 9bd8676f13b..68e45dfa573 100644 --- a/build/root/Makefile.generated_files +++ b/build/root/Makefile.generated_files @@ -215,30 +215,23 @@ DEEPCOPY_DIRS := $(shell \ ) DEEPCOPY_FILES := $(addsuffix /$(DEEPCOPY_FILENAME), $(DEEPCOPY_DIRS)) -# Shell function for reuse in rules. -RUN_GEN_DEEPCOPY = \ - function run_gen_deepcopy() { \ - if [[ -s $(META_DIR)/$(DEEPCOPY_GEN).todo ]]; then \ - pkgs=$$(cat $(META_DIR)/$(DEEPCOPY_GEN).todo | paste -sd, -); \ - if [[ "$(DBG_CODEGEN)" == 1 ]]; then \ - echo "DBG: running $(DEEPCOPY_GEN) for $$pkgs"; \ - fi; \ - ./hack/run-in-gopath.sh $(DEEPCOPY_GEN) \ - --v $(KUBE_VERBOSE) \ - --logtostderr \ - -i "$$pkgs" \ - --bounding-dirs $(PRJ_SRC_PATH),"k8s.io/api" \ - -O $(DEEPCOPY_BASENAME) \ - "$$@"; \ - fi \ - }; \ - run_gen_deepcopy - # This rule aggregates the set of files to generate and then generates them all # in a single run of the tool. .PHONY: gen_deepcopy gen_deepcopy: $(DEEPCOPY_FILES) $(DEEPCOPY_GEN) - $(RUN_GEN_DEEPCOPY) + if [[ -s $(META_DIR)/$(DEEPCOPY_GEN).todo ]]; then \ + pkgs=$$(cat $(META_DIR)/$(DEEPCOPY_GEN).todo | paste -sd, -); \ + if [[ "$(DBG_CODEGEN)" == 1 ]]; then \ + echo "DBG: running $(DEEPCOPY_GEN) for $$pkgs"; \ + fi; \ + ./hack/run-in-gopath.sh $(DEEPCOPY_GEN) \ + --v $(KUBE_VERBOSE) \ + --logtostderr \ + -i "$$pkgs" \ + --bounding-dirs $(PRJ_SRC_PATH),"k8s.io/api" \ + -O $(DEEPCOPY_BASENAME) \ + "$$@"; \ + fi \ # For each dir in DEEPCOPY_DIRS, this establishes a dependency between the # output file and the input files that should trigger a rebuild. @@ -350,29 +343,23 @@ DEFAULTER_DIRS := $(shell \ DEFAULTER_FILES := $(addsuffix /$(DEFAULTER_FILENAME), $(DEFAULTER_DIRS)) -RUN_GEN_DEFAULTER := \ - function run_gen_defaulter() { \ - if [[ -s $(META_DIR)/$(DEFAULTER_GEN).todo ]]; then \ - pkgs=$$(cat $(META_DIR)/$(DEFAULTER_GEN).todo | paste -sd, -); \ - if [[ "$(DBG_CODEGEN)" == 1 ]]; then \ - echo "DBG: running $(DEFAULTER_GEN) for $$pkgs"; \ - fi; \ - ./hack/run-in-gopath.sh $(DEFAULTER_GEN) \ - --v $(KUBE_VERBOSE) \ - --logtostderr \ - -i "$$pkgs" \ - --extra-peer-dirs $$(echo $(addprefix $(PRJ_SRC_PATH)/, $(DEFAULTER_DIRS)) | sed 's/ /,/g') \ - -O $(DEFAULTER_BASENAME) \ - "$$@"; \ - fi \ - }; \ - run_gen_defaulter - # This rule aggregates the set of files to generate and then generates them all # in a single run of the tool. .PHONY: gen_defaulter gen_defaulter: $(DEFAULTER_FILES) $(DEFAULTER_GEN) - $(RUN_GEN_DEFAULTER) + if [[ -s $(META_DIR)/$(DEFAULTER_GEN).todo ]]; then \ + pkgs=$$(cat $(META_DIR)/$(DEFAULTER_GEN).todo | paste -sd, -); \ + if [[ "$(DBG_CODEGEN)" == 1 ]]; then \ + echo "DBG: running $(DEFAULTER_GEN) for $$pkgs"; \ + fi; \ + ./hack/run-in-gopath.sh $(DEFAULTER_GEN) \ + --v $(KUBE_VERBOSE) \ + --logtostderr \ + -i "$$pkgs" \ + --extra-peer-dirs $$(echo $(addprefix $(PRJ_SRC_PATH)/, $(DEFAULTER_DIRS)) | sed 's/ /,/g') \ + -O $(DEFAULTER_BASENAME) \ + "$$@"; \ + fi # For each dir in DEFAULTER_DIRS, this establishes a dependency between the # output file and the input files that should trigger a rebuild. @@ -513,30 +500,23 @@ CONVERSION_DIRS := $(shell \ CONVERSION_FILES := $(addsuffix /$(CONVERSION_FILENAME), $(CONVERSION_DIRS)) CONVERSION_EXTRA_PEER_DIRS := k8s.io/kubernetes/pkg/apis/core,k8s.io/kubernetes/pkg/apis/core/v1,k8s.io/api/core/v1 -# Shell function for reuse in rules. -RUN_GEN_CONVERSION = \ - function run_gen_conversion() { \ - if [[ -s $(META_DIR)/$(CONVERSION_GEN).todo ]]; then \ - pkgs=$$(cat $(META_DIR)/$(CONVERSION_GEN).todo | paste -sd, -); \ - if [[ "$(DBG_CODEGEN)" == 1 ]]; then \ - echo "DBG: running $(CONVERSION_GEN) for $$pkgs"; \ - fi; \ - ./hack/run-in-gopath.sh $(CONVERSION_GEN) \ - --extra-peer-dirs $(CONVERSION_EXTRA_PEER_DIRS) \ - --v $(KUBE_VERBOSE) \ - --logtostderr \ - -i "$$pkgs" \ - -O $(CONVERSION_BASENAME) \ - "$$@"; \ - fi \ - }; \ - run_gen_conversion - # This rule aggregates the set of files to generate and then generates them all # in a single run of the tool. .PHONY: gen_conversion gen_conversion: $(CONVERSION_FILES) $(CONVERSION_GEN) - $(RUN_GEN_CONVERSION) + if [[ -s $(META_DIR)/$(CONVERSION_GEN).todo ]]; then \ + pkgs=$$(cat $(META_DIR)/$(CONVERSION_GEN).todo | paste -sd, -); \ + if [[ "$(DBG_CODEGEN)" == 1 ]]; then \ + echo "DBG: running $(CONVERSION_GEN) for $$pkgs"; \ + fi; \ + ./hack/run-in-gopath.sh $(CONVERSION_GEN) \ + --extra-peer-dirs $(CONVERSION_EXTRA_PEER_DIRS) \ + --v $(KUBE_VERBOSE) \ + --logtostderr \ + -i "$$pkgs" \ + -O $(CONVERSION_BASENAME) \ + "$$@"; \ + fi # Establish a dependency between the deps file and the dir. Whenever a dir # changes (files added or removed) the deps file will be considered stale.