@@ -37,6 +37,12 @@ SHELL := /bin/bash
37
37
.PHONY: generated_files
38
38
generated_files: gen_deepcopy gen_defaulter gen_conversion gen_openapi
39
39
40
+ .PHONY: verify_generated_files
41
+ verify_generated_files: verify_gen_deepcopy \
42
+ verify_gen_defaulter \
43
+ verify_gen_conversion \
44
+ verify_gen_openapi
45
+
40
46
# Code-generation logic.
41
47
#
42
48
# This stuff can be pretty tricky, and there's probably some corner cases that
@@ -209,18 +215,30 @@ DEEPCOPY_DIRS := $(shell \
209
215
)
210
216
DEEPCOPY_FILES := $(addsuffix /$(DEEPCOPY_FILENAME), $(DEEPCOPY_DIRS))
211
217
218
+ # Shell function for reuse in rules.
219
+ RUN_GEN_DEEPCOPY = \
220
+ function run_gen_deepcopy() { \
221
+ if [[ -f $(META_DIR)/$(DEEPCOPY_GEN).todo ]]; then \
222
+ ./hack/run-in-gopath.sh $(DEEPCOPY_GEN) \
223
+ --v $(KUBE_VERBOSE) \
224
+ --logtostderr \
225
+ -i $$(cat $(META_DIR)/$(DEEPCOPY_GEN).todo | paste -sd, -) \
226
+ --bounding-dirs $(PRJ_SRC_PATH) \
227
+ -O $(DEEPCOPY_BASENAME) \
228
+ "$$@"; \
229
+ fi \
230
+ }; \
231
+ run_gen_deepcopy
232
+
212
233
# This rule aggregates the set of files to generate and then generates them all
213
234
# in a single run of the tool.
214
235
.PHONY: gen_deepcopy
215
- gen_deepcopy: $(DEEPCOPY_FILES)
216
- if [[ -f $(META_DIR)/$(DEEPCOPY_GEN).todo ]]; then \
217
- ./hack/run-in-gopath.sh $(DEEPCOPY_GEN) \
218
- --v $(KUBE_VERBOSE) \
219
- --logtostderr \
220
- -i $$(cat $(META_DIR)/$(DEEPCOPY_GEN).todo | paste -sd, -) \
221
- --bounding-dirs $(PRJ_SRC_PATH) \
222
- -O $(DEEPCOPY_BASENAME); \
223
- fi
236
+ gen_deepcopy: $(DEEPCOPY_FILES) $(DEEPCOPY_GEN)
237
+ $(RUN_GEN_DEEPCOPY)
238
+
239
+ .PHONY: verify_gen_deepcopy
240
+ verify_gen_deepcopy: $(DEEPCOPY_GEN)
241
+ $(RUN_GEN_DEEPCOPY) --verify-only
224
242
225
243
# For each dir in DEEPCOPY_DIRS, this establishes a dependency between the
226
244
# output file and the input files that should trigger a rebuild.
@@ -323,18 +341,29 @@ DEFAULTER_DIRS := $(shell \
323
341
324
342
DEFAULTER_FILES := $(addsuffix /$(DEFAULTER_FILENAME), $(DEFAULTER_DIRS))
325
343
344
+ RUN_GEN_DEFAULTER := \
345
+ function run_gen_defaulter() { \
346
+ if [[ -f $(META_DIR)/$(DEFAULTER_GEN).todo ]]; then \
347
+ ./hack/run-in-gopath.sh $(DEFAULTER_GEN) \
348
+ --v $(KUBE_VERBOSE) \
349
+ --logtostderr \
350
+ -i $$(cat $(META_DIR)/$(DEFAULTER_GEN).todo | paste -sd, -) \
351
+ --extra-peer-dirs $$(echo $(addprefix $(PRJ_SRC_PATH)/, $(DEFAULTER_DIRS)) | sed 's/ /,/g') \
352
+ -O $(DEFAULTER_BASENAME) \
353
+ "$$@"; \
354
+ fi \
355
+ }; \
356
+ run_gen_defaulter
357
+
326
358
# This rule aggregates the set of files to generate and then generates them all
327
359
# in a single run of the tool.
328
360
.PHONY: gen_defaulter
329
- gen_defaulter: $(DEFAULTER_FILES)
330
- if [[ -f $(META_DIR)/$(DEFAULTER_GEN).todo ]]; then \
331
- ./hack/run-in-gopath.sh $(DEFAULTER_GEN) \
332
- --v $(KUBE_VERBOSE) \
333
- --logtostderr \
334
- -i $$(cat $(META_DIR)/$(DEFAULTER_GEN).todo | paste -sd, -) \
335
- --extra-peer-dirs $$(echo $(addprefix $(PRJ_SRC_PATH)/, $(DEFAULTER_DIRS)) | sed 's/ /,/g') \
336
- -O $(DEFAULTER_BASENAME); \
337
- fi
361
+ gen_defaulter: $(DEFAULTER_FILES) $(DEFAULTER_GEN)
362
+ $(RUN_GEN_DEFAULTER)
363
+
364
+ .PHONY: verify_gen_deepcopy
365
+ verify_gen_defaulter: $(DEFAULTER_GEN)
366
+ $(RUN_GEN_DEFAULTER) --verify-only
338
367
339
368
# For each dir in DEFAULTER_DIRS, this establishes a dependency between the
340
369
# output file and the input files that should trigger a rebuild.
@@ -453,9 +482,26 @@ OPENAPI_DIRS := $(shell \
453
482
454
483
OPENAPI_OUTFILE := $(OPENAPI_OUTPUT_PKG)/$(OPENAPI_FILENAME)
455
484
485
+ # Shell function for reuse in rules.
486
+ RUN_GEN_OPENAPI = \
487
+ function run_gen_openapi() { \
488
+ ./hack/run-in-gopath.sh $(OPENAPI_GEN) \
489
+ --v $(KUBE_VERBOSE) \
490
+ --logtostderr \
491
+ -i $$(echo $(addprefix $(PRJ_SRC_PATH)/, $(OPENAPI_DIRS)) | sed 's/ /,/g') \
492
+ -p $(PRJ_SRC_PATH)/$(OPENAPI_OUTPUT_PKG) \
493
+ -O $(OPENAPI_BASENAME) \
494
+ "$$@"; \
495
+ }; \
496
+ run_gen_openapi
497
+
456
498
# This rule is the user-friendly entrypoint for openapi generation.
457
499
.PHONY: gen_openapi
458
- gen_openapi: $(OPENAPI_OUTFILE)
500
+ gen_openapi: $(OPENAPI_OUTFILE) $(OPENAPI_GEN)
501
+
502
+ .PHONY: verify_gen_openapi
503
+ verify_gen_openapi: $(OPENAPI_GEN)
504
+ $(RUN_GEN_OPENAPI) --verify-only
459
505
460
506
# For each dir in OPENAPI_DIRS, this establishes a dependency between the
461
507
# output file and the input files that should trigger a rebuild.
@@ -475,13 +521,8 @@ $(foreach dir, $(OPENAPI_DIRS), $(eval \
475
521
))
476
522
477
523
# How to regenerate open-api code. This emits a single file for all results.
478
- $(OPENAPI_OUTFILE): $(OPENAPI_GEN)
479
- ./hack/run-in-gopath.sh $(OPENAPI_GEN) \
480
- --v $(KUBE_VERBOSE) \
481
- --logtostderr \
482
- -i $$(echo $(addprefix $(PRJ_SRC_PATH)/, $(OPENAPI_DIRS)) | sed 's/ /,/g') \
483
- -p $(PRJ_SRC_PATH)/$(OPENAPI_OUTPUT_PKG) \
484
- -O $(OPENAPI_BASENAME)
524
+ $(OPENAPI_OUTFILE): $(OPENAPI_GEN) $(OPENAPI_GEN)
525
+ $(RUN_GEN_OPENAPI)
485
526
486
527
# This calculates the dependencies for the generator tool, so we only rebuild
487
528
# it when needed. It is PHONY so that it always runs, but it only updates the
@@ -560,17 +601,29 @@ CONVERSION_DIRS := $(shell \
560
601
561
602
CONVERSION_FILES := $(addsuffix /$(CONVERSION_FILENAME), $(CONVERSION_DIRS))
562
603
604
+ # Shell function for reuse in rules.
605
+ RUN_GEN_CONVERSION = \
606
+ function run_gen_conversion() { \
607
+ if [[ -f $(META_DIR)/$(CONVERSION_GEN).todo ]]; then \
608
+ ./hack/run-in-gopath.sh $(CONVERSION_GEN) \
609
+ --v $(KUBE_VERBOSE) \
610
+ --logtostderr \
611
+ -i $$(cat $(META_DIR)/$(CONVERSION_GEN).todo | paste -sd, -) \
612
+ -O $(CONVERSION_BASENAME) \
613
+ "$$@"; \
614
+ fi \
615
+ }; \
616
+ run_gen_conversion
617
+
563
618
# This rule aggregates the set of files to generate and then generates them all
564
619
# in a single run of the tool.
565
620
.PHONY: gen_conversion
566
- gen_conversion: $(CONVERSION_FILES)
567
- if [[ -f $(META_DIR)/$(CONVERSION_GEN).todo ]]; then \
568
- ./hack/run-in-gopath.sh $(CONVERSION_GEN) \
569
- --v $(KUBE_VERBOSE) \
570
- --logtostderr \
571
- -i $$(cat $(META_DIR)/$(CONVERSION_GEN).todo | paste -sd, -) \
572
- -O $(CONVERSION_BASENAME); \
573
- fi
621
+ gen_conversion: $(CONVERSION_FILES) $(CONVERSION_GEN)
622
+ $(RUN_GEN_CONVERSION)
623
+
624
+ .PHONY: verify_gen_conversion
625
+ verify_gen_conversion: $(CONVERSION_GEN)
626
+ $(RUN_GEN_CONVERSION) --verify-only
574
627
575
628
# Establish a dependency between the deps file and the dir. Whenever a dir
576
629
# changes (files added or removed) the deps file will be considered stale.
0 commit comments