Simplify Makefile for genfiles a bit

pull/8/head
Tim Hockin 2018-04-29 18:39:01 +01:00
parent fba394ce8c
commit 90e0ac54b9
1 changed files with 39 additions and 59 deletions

View File

@ -215,9 +215,10 @@ DEEPCOPY_DIRS := $(shell \
) )
DEEPCOPY_FILES := $(addsuffix /$(DEEPCOPY_FILENAME), $(DEEPCOPY_DIRS)) DEEPCOPY_FILES := $(addsuffix /$(DEEPCOPY_FILENAME), $(DEEPCOPY_DIRS))
# Shell function for reuse in rules. # This rule aggregates the set of files to generate and then generates them all
RUN_GEN_DEEPCOPY = \ # in a single run of the tool.
function run_gen_deepcopy() { \ .PHONY: gen_deepcopy
gen_deepcopy: $(DEEPCOPY_FILES) $(DEEPCOPY_GEN)
if [[ -s $(META_DIR)/$(DEEPCOPY_GEN).todo ]]; then \ if [[ -s $(META_DIR)/$(DEEPCOPY_GEN).todo ]]; then \
pkgs=$$(cat $(META_DIR)/$(DEEPCOPY_GEN).todo | paste -sd, -); \ pkgs=$$(cat $(META_DIR)/$(DEEPCOPY_GEN).todo | paste -sd, -); \
if [[ "$(DBG_CODEGEN)" == 1 ]]; then \ if [[ "$(DBG_CODEGEN)" == 1 ]]; then \
@ -231,14 +232,6 @@ RUN_GEN_DEEPCOPY = \
-O $(DEEPCOPY_BASENAME) \ -O $(DEEPCOPY_BASENAME) \
"$$@"; \ "$$@"; \
fi \ 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)
# For each dir in DEEPCOPY_DIRS, this establishes a dependency between the # For each dir in DEEPCOPY_DIRS, this establishes a dependency between the
# output file and the input files that should trigger a rebuild. # output file and the input files that should trigger a rebuild.
@ -350,8 +343,10 @@ DEFAULTER_DIRS := $(shell \
DEFAULTER_FILES := $(addsuffix /$(DEFAULTER_FILENAME), $(DEFAULTER_DIRS)) DEFAULTER_FILES := $(addsuffix /$(DEFAULTER_FILENAME), $(DEFAULTER_DIRS))
RUN_GEN_DEFAULTER := \ # This rule aggregates the set of files to generate and then generates them all
function run_gen_defaulter() { \ # in a single run of the tool.
.PHONY: gen_defaulter
gen_defaulter: $(DEFAULTER_FILES) $(DEFAULTER_GEN)
if [[ -s $(META_DIR)/$(DEFAULTER_GEN).todo ]]; then \ if [[ -s $(META_DIR)/$(DEFAULTER_GEN).todo ]]; then \
pkgs=$$(cat $(META_DIR)/$(DEFAULTER_GEN).todo | paste -sd, -); \ pkgs=$$(cat $(META_DIR)/$(DEFAULTER_GEN).todo | paste -sd, -); \
if [[ "$(DBG_CODEGEN)" == 1 ]]; then \ if [[ "$(DBG_CODEGEN)" == 1 ]]; then \
@ -364,15 +359,7 @@ RUN_GEN_DEFAULTER := \
--extra-peer-dirs $$(echo $(addprefix $(PRJ_SRC_PATH)/, $(DEFAULTER_DIRS)) | sed 's/ /,/g') \ --extra-peer-dirs $$(echo $(addprefix $(PRJ_SRC_PATH)/, $(DEFAULTER_DIRS)) | sed 's/ /,/g') \
-O $(DEFAULTER_BASENAME) \ -O $(DEFAULTER_BASENAME) \
"$$@"; \ "$$@"; \
fi \ 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)
# For each dir in DEFAULTER_DIRS, this establishes a dependency between the # For each dir in DEFAULTER_DIRS, this establishes a dependency between the
# output file and the input files that should trigger a rebuild. # output file and the input files that should trigger a rebuild.
@ -513,9 +500,10 @@ CONVERSION_DIRS := $(shell \
CONVERSION_FILES := $(addsuffix /$(CONVERSION_FILENAME), $(CONVERSION_DIRS)) 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 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. # This rule aggregates the set of files to generate and then generates them all
RUN_GEN_CONVERSION = \ # in a single run of the tool.
function run_gen_conversion() { \ .PHONY: gen_conversion
gen_conversion: $(CONVERSION_FILES) $(CONVERSION_GEN)
if [[ -s $(META_DIR)/$(CONVERSION_GEN).todo ]]; then \ if [[ -s $(META_DIR)/$(CONVERSION_GEN).todo ]]; then \
pkgs=$$(cat $(META_DIR)/$(CONVERSION_GEN).todo | paste -sd, -); \ pkgs=$$(cat $(META_DIR)/$(CONVERSION_GEN).todo | paste -sd, -); \
if [[ "$(DBG_CODEGEN)" == 1 ]]; then \ if [[ "$(DBG_CODEGEN)" == 1 ]]; then \
@ -528,15 +516,7 @@ RUN_GEN_CONVERSION = \
-i "$$pkgs" \ -i "$$pkgs" \
-O $(CONVERSION_BASENAME) \ -O $(CONVERSION_BASENAME) \
"$$@"; \ "$$@"; \
fi \ 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)
# Establish a dependency between the deps file and the dir. Whenever a dir # 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. # changes (files added or removed) the deps file will be considered stale.