Skip to content

Commit fce3ad5

Browse files
author
Kubernetes Submit Queue
authored
Merge pull request kubernetes#62151 from thockin/build-cleanup-with-go-1-10
Automatic merge from submit-queue (batch tested with PRs 62495, 63003, 62829, 62151, 62002). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Build cleanup with go 1.10 Simplify our build/test scripts now that go 1.10 is in play. It has caching that seems to actually work. **Release note**: ```release-note NONE ```
2 parents 1aa67be + 59ef5e2 commit fce3ad5

File tree

11 files changed

+189
-842
lines changed

11 files changed

+189
-842
lines changed

build/root/Makefile.generated_files

Lines changed: 166 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ SHELL := /bin/bash
3535
# This rule collects all the generated file sets into a single rule. Other
3636
# rules should depend on this to ensure generated files are rebuilt.
3737
.PHONY: generated_files
38-
generated_files: gen_deepcopy gen_defaulter gen_conversion gen_openapi
38+
generated_files: gen_deepcopy gen_defaulter gen_conversion gen_openapi gen_bindata
3939

4040
.PHONY: verify_generated_files
4141
verify_generated_files: verify_gen_deepcopy \
@@ -486,110 +486,6 @@ $(DEFAULTER_GEN):
486486
hack/make-rules/build.sh ./vendor/k8s.io/code-generator/cmd/defaulter-gen
487487
touch $@
488488

489-
#
490-
# Open-api generation
491-
#
492-
# Any package that wants open-api functions generated must include a
493-
# comment-tag in column 0 of one file of the form:
494-
# // +k8s:openapi-gen=true
495-
#
496-
# The result file, in each pkg, of open-api generation.
497-
OPENAPI_BASENAME := $(GENERATED_FILE_PREFIX)openapi
498-
OPENAPI_FILENAME := $(OPENAPI_BASENAME).go
499-
OPENAPI_OUTPUT_PKG := pkg/generated/openapi
500-
501-
# The tool used to generate open apis.
502-
OPENAPI_GEN := $(BIN_DIR)/openapi-gen
503-
504-
# Find all the directories that request open-api generation.
505-
ifeq ($(DBG_MAKEFILE),1)
506-
$(warning ***** finding all +k8s:openapi-gen tags)
507-
endif
508-
OPENAPI_DIRS := $(shell \
509-
grep --color=never -l '+k8s:openapi-gen=' $(ALL_K8S_TAG_FILES) \
510-
| xargs -n1 dirname \
511-
| LC_ALL=C sort -u \
512-
)
513-
514-
OPENAPI_OUTFILE := $(OPENAPI_OUTPUT_PKG)/$(OPENAPI_FILENAME)
515-
516-
# This rule is the user-friendly entrypoint for openapi generation.
517-
.PHONY: gen_openapi
518-
gen_openapi: $(OPENAPI_OUTFILE) $(OPENAPI_GEN)
519-
520-
# For each dir in OPENAPI_DIRS, this establishes a dependency between the
521-
# output file and the input files that should trigger a rebuild.
522-
#
523-
# Note that this is a deps-only statement, not a full rule (see below). This
524-
# has to be done in a distinct step because wildcards don't work in static
525-
# pattern rules.
526-
#
527-
# The '$(eval)' is needed because this has a different RHS for each LHS, and
528-
# would otherwise produce results that make can't parse.
529-
#
530-
# We depend on the $(GOFILES_META).stamp to detect when the set of input files
531-
# has changed. This allows us to detect deleted input files.
532-
$(foreach dir, $(OPENAPI_DIRS), $(eval \
533-
$(OPENAPI_OUTFILE): $(META_DIR)/$(dir)/$(GOFILES_META).stamp \
534-
$(gofiles__$(dir)) \
535-
))
536-
537-
# How to regenerate open-api code. This emits a single file for all results.
538-
$(OPENAPI_OUTFILE): $(OPENAPI_GEN) $(OPENAPI_GEN)
539-
function run_gen_openapi() { \
540-
./hack/run-in-gopath.sh $(OPENAPI_GEN) \
541-
--v $(KUBE_VERBOSE) \
542-
--logtostderr \
543-
-i $$(echo $(addprefix $(PRJ_SRC_PATH)/, $(OPENAPI_DIRS)) | sed 's/ /,/g') \
544-
-p $(PRJ_SRC_PATH)/$(OPENAPI_OUTPUT_PKG) \
545-
-O $(OPENAPI_BASENAME) \
546-
"$$@"; \
547-
}; \
548-
run_gen_openapi
549-
550-
# This calculates the dependencies for the generator tool, so we only rebuild
551-
# it when needed. It is PHONY so that it always runs, but it only updates the
552-
# file if the contents have actually changed. We 'sinclude' this later.
553-
.PHONY: $(META_DIR)/$(OPENAPI_GEN).mk
554-
$(META_DIR)/$(OPENAPI_GEN).mk:
555-
mkdir -p $(@D); \
556-
(echo -n "$(OPENAPI_GEN): "; \
557-
./hack/run-in-gopath.sh go list \
558-
-f '{{.ImportPath}}{{"\n"}}{{range .Deps}}{{.}}{{"\n"}}{{end}}' \
559-
./vendor/k8s.io/code-generator/cmd/openapi-gen \
560-
| grep --color=never "^$(PRJ_SRC_PATH)/" \
561-
| xargs ./hack/run-in-gopath.sh go list \
562-
-f '{{$$d := .Dir}}{{$$d}}{{"\n"}}{{range .GoFiles}}{{$$d}}/{{.}}{{"\n"}}{{end}}' \
563-
| paste -sd' ' - \
564-
| sed 's/ / \\=,/g' \
565-
| tr '=,' '\n\t' \
566-
| sed "s|$$(pwd -P)/||"; \
567-
568-
if ! cmp -s [email protected] $@; then \
569-
if [[ "$(DBG_CODEGEN)" == 1 ]]; then \
570-
echo "DBG: $(OPENAPI_GEN).mk changed"; \
571-
fi; \
572-
cat [email protected] > $@; \
573-
574-
fi
575-
576-
# Include dependency info for the generator tool. This will cause the rule of
577-
# the same name to be considered and if it is updated, make will restart.
578-
sinclude $(META_DIR)/$(OPENAPI_GEN).mk
579-
580-
# How to build the generator tool. The deps for this are defined in
581-
# the $(OPENAPI_GEN).mk, above.
582-
#
583-
# A word on the need to touch: This rule might trigger if, for example, a
584-
# non-Go file was added or deleted from a directory on which this depends.
585-
# This target needs to be reconsidered, but Go realizes it doesn't actually
586-
# have to be rebuilt. In that case, make will forever see the dependency as
587-
# newer than the binary, and try to rebuild it over and over. So we touch it,
588-
# and make is happy.
589-
$(OPENAPI_GEN):
590-
hack/make-rules/build.sh ./vendor/k8s.io/code-generator/cmd/openapi-gen
591-
touch $@
592-
593489
#
594490
# Conversion generation
595491
#
@@ -805,3 +701,168 @@ sinclude $(META_DIR)/$(CONVERSION_GEN).mk
805701
$(CONVERSION_GEN):
806702
hack/make-rules/build.sh ./vendor/k8s.io/code-generator/cmd/conversion-gen
807703
touch $@
704+
705+
#
706+
# Open-api generation
707+
#
708+
# Any package that wants open-api functions generated must include a
709+
# comment-tag in column 0 of one file of the form:
710+
# // +k8s:openapi-gen=true
711+
#
712+
# The result file, in each pkg, of open-api generation.
713+
OPENAPI_BASENAME := $(GENERATED_FILE_PREFIX)openapi
714+
OPENAPI_FILENAME := $(OPENAPI_BASENAME).go
715+
OPENAPI_OUTPUT_PKG := pkg/generated/openapi
716+
717+
# The tool used to generate open apis.
718+
OPENAPI_GEN := $(BIN_DIR)/openapi-gen
719+
720+
# Find all the directories that request open-api generation.
721+
ifeq ($(DBG_MAKEFILE),1)
722+
$(warning ***** finding all +k8s:openapi-gen tags)
723+
endif
724+
OPENAPI_DIRS := $(shell \
725+
grep --color=never -l '+k8s:openapi-gen=' $(ALL_K8S_TAG_FILES) \
726+
| xargs -n1 dirname \
727+
| LC_ALL=C sort -u \
728+
)
729+
730+
OPENAPI_OUTFILE := $(OPENAPI_OUTPUT_PKG)/$(OPENAPI_FILENAME)
731+
732+
# This rule is the user-friendly entrypoint for openapi generation.
733+
.PHONY: gen_openapi
734+
gen_openapi: $(OPENAPI_OUTFILE) $(OPENAPI_GEN)
735+
736+
# For each dir in OPENAPI_DIRS, this establishes a dependency between the
737+
# output file and the input files that should trigger a rebuild.
738+
#
739+
# Note that this is a deps-only statement, not a full rule (see below). This
740+
# has to be done in a distinct step because wildcards don't work in static
741+
# pattern rules.
742+
#
743+
# The '$(eval)' is needed because this has a different RHS for each LHS, and
744+
# would otherwise produce results that make can't parse.
745+
#
746+
# We depend on the $(GOFILES_META).stamp to detect when the set of input files
747+
# has changed. This allows us to detect deleted input files.
748+
$(foreach dir, $(OPENAPI_DIRS), $(eval \
749+
$(OPENAPI_OUTFILE): $(META_DIR)/$(dir)/$(GOFILES_META).stamp \
750+
$(gofiles__$(dir)) \
751+
))
752+
753+
# How to regenerate open-api code. This emits a single file for all results.
754+
$(OPENAPI_OUTFILE): $(OPENAPI_GEN) $(OPENAPI_GEN)
755+
function run_gen_openapi() { \
756+
./hack/run-in-gopath.sh $(OPENAPI_GEN) \
757+
--v $(KUBE_VERBOSE) \
758+
--logtostderr \
759+
-i $$(echo $(addprefix $(PRJ_SRC_PATH)/, $(OPENAPI_DIRS)) | sed 's/ /,/g') \
760+
-p $(PRJ_SRC_PATH)/$(OPENAPI_OUTPUT_PKG) \
761+
-O $(OPENAPI_BASENAME) \
762+
"$$@"; \
763+
}; \
764+
run_gen_openapi
765+
766+
# This calculates the dependencies for the generator tool, so we only rebuild
767+
# it when needed. It is PHONY so that it always runs, but it only updates the
768+
# file if the contents have actually changed. We 'sinclude' this later.
769+
.PHONY: $(META_DIR)/$(OPENAPI_GEN).mk
770+
$(META_DIR)/$(OPENAPI_GEN).mk:
771+
mkdir -p $(@D); \
772+
(echo -n "$(OPENAPI_GEN): "; \
773+
./hack/run-in-gopath.sh go list \
774+
-f '{{.ImportPath}}{{"\n"}}{{range .Deps}}{{.}}{{"\n"}}{{end}}' \
775+
./vendor/k8s.io/code-generator/cmd/openapi-gen \
776+
| grep --color=never "^$(PRJ_SRC_PATH)/" \
777+
| xargs ./hack/run-in-gopath.sh go list \
778+
-f '{{$$d := .Dir}}{{$$d}}{{"\n"}}{{range .GoFiles}}{{$$d}}/{{.}}{{"\n"}}{{end}}' \
779+
| paste -sd' ' - \
780+
| sed 's/ / \\=,/g' \
781+
| tr '=,' '\n\t' \
782+
| sed "s|$$(pwd -P)/||"; \
783+
784+
if ! cmp -s [email protected] $@; then \
785+
if [[ "$(DBG_CODEGEN)" == 1 ]]; then \
786+
echo "DBG: $(OPENAPI_GEN).mk changed"; \
787+
fi; \
788+
cat [email protected] > $@; \
789+
790+
fi
791+
792+
# Include dependency info for the generator tool. This will cause the rule of
793+
# the same name to be considered and if it is updated, make will restart.
794+
sinclude $(META_DIR)/$(OPENAPI_GEN).mk
795+
796+
# How to build the generator tool. The deps for this are defined in
797+
# the $(OPENAPI_GEN).mk, above.
798+
#
799+
# A word on the need to touch: This rule might trigger if, for example, a
800+
# non-Go file was added or deleted from a directory on which this depends.
801+
# This target needs to be reconsidered, but Go realizes it doesn't actually
802+
# have to be rebuilt. In that case, make will forever see the dependency as
803+
# newer than the binary, and try to rebuild it over and over. So we touch it,
804+
# and make is happy.
805+
$(OPENAPI_GEN):
806+
hack/make-rules/build.sh ./vendor/k8s.io/code-generator/cmd/openapi-gen
807+
touch $@
808+
809+
#
810+
# bindata generation
811+
#
812+
813+
# The tool used to generate bindata files.
814+
BINDATA_GEN := $(BIN_DIR)/go-bindata
815+
816+
# A wrapper script that generates all bindata files. It is fast enough that we
817+
# don't care.
818+
BINDATA_SCRIPT := hack/generate-bindata.sh
819+
820+
# This rule is the user-friendly entrypoint for bindata generation.
821+
.PHONY: gen_bindata
822+
gen_bindata: $(BINDATA_GEN) FORCE
823+
./hack/run-in-gopath.sh $(BINDATA_SCRIPT)
824+
825+
FORCE:
826+
827+
# This calculates the dependencies for the generator tool, so we only rebuild
828+
# it when needed. It is PHONY so that it always runs, but it only updates the
829+
# file if the contents have actually changed. We 'sinclude' this later.
830+
.PHONY: $(META_DIR)/$(BINDATA_GEN).mk
831+
$(META_DIR)/$(BINDATA_GEN).mk:
832+
mkdir -p $(@D); \
833+
(echo -n "$(BINDATA_GEN): "; \
834+
./hack/run-in-gopath.sh go list \
835+
-f '{{.ImportPath}}{{"\n"}}{{range .Deps}}{{.}}{{"\n"}}{{end}}' \
836+
./vendor/github.com/jteeuwen/go-bindata/go-bindata \
837+
| grep --color=never "^$(PRJ_SRC_PATH)/" \
838+
| xargs ./hack/run-in-gopath.sh go list \
839+
-f '{{$$d := .Dir}}{{$$d}}{{"\n"}}{{range .GoFiles}}{{$$d}}/{{.}}{{"\n"}}{{end}}' \
840+
| paste -sd' ' - \
841+
| sed 's/ / \\=,/g' \
842+
| tr '=,' '\n\t' \
843+
| sed "s|$$(pwd -P)/||"; \
844+
845+
if ! cmp -s [email protected] $@; then \
846+
if [[ "$(DBG_CODEGEN)" == 1 ]]; then \
847+
echo "DBG: $(BINDATA_GEN).mk changed"; \
848+
fi; \
849+
cat [email protected] > $@; \
850+
851+
fi
852+
853+
# Include dependency info for the generator tool. This will cause the rule of
854+
# the same name to be considered and if it is updated, make will restart.
855+
sinclude $(META_DIR)/$(BINDATA_GEN).mk
856+
857+
# How to build the generator tool. The deps for this are defined in
858+
# the $(BINDATA_GEN).mk, above.
859+
#
860+
# A word on the need to touch: This rule might trigger if, for example, a
861+
# non-Go file was added or deleted from a directory on which this depends.
862+
# This target needs to be reconsidered, but Go realizes it doesn't actually
863+
# have to be rebuilt. In that case, make will forever see the dependency as
864+
# newer than the binary, and try to rebuild it over and over. So we touch it,
865+
# and make is happy.
866+
$(BINDATA_GEN):
867+
hack/make-rules/build.sh ./vendor/github.com/jteeuwen/go-bindata/go-bindata
868+
touch $@

hack/BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ filegroup(
1919
srcs = [
2020
":package-srcs",
2121
"//hack/boilerplate:all-srcs",
22-
"//hack/cmd/teststale:all-srcs",
2322
"//hack/e2e-internal:all-srcs",
2423
"//hack/lib:all-srcs",
2524
"//hack/make-rules:all-srcs",

hack/cmd/teststale/BUILD

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)