From 56ad63913affeb3647fba19b3c47f63f875c2c53 Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Mon, 10 Jan 2022 15:34:42 -0800 Subject: [PATCH] Make builds fail if go2make misbehaves Rather than an obscure error. --- build/root/Makefile.generated_files | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/build/root/Makefile.generated_files b/build/root/Makefile.generated_files index 1217f87f820..13e4095dfef 100644 --- a/build/root/Makefile.generated_files +++ b/build/root/Makefile.generated_files @@ -61,7 +61,7 @@ GO_PKGDEPS_FILE = go-pkgdeps.mk # Include the Go package dependencies file. This will cause the rule of # the same name to be considered and if it is updated, make will restart and # reload the updated deps. -sinclude $(META_DIR)/$(GO_PKGDEPS_FILE) +include $(META_DIR)/$(GO_PKGDEPS_FILE) # Only build and run go2make on the first pass. If that generates a new # GO_PKGDEPS_FILE, make will restart the whole process and set MAKE_RESTARTS to @@ -77,17 +77,23 @@ $(META_DIR)/$(GO_PKGDEPS_FILE): FORCE fi KUBE_BUILD_PLATFORMS="" \ hack/make-rules/build.sh hack/make-rules/helpers/go2make - hack/run-in-gopath.sh go2make \ - k8s.io/kubernetes/... \ - --prune k8s.io/kubernetes/staging \ - --prune k8s.io/kubernetes/vendor \ - k8s.io/kubernetes/vendor/k8s.io/... \ + hack/run-in-gopath.sh go2make \ + k8s.io/kubernetes/... \ + --prune k8s.io/kubernetes/staging \ + --prune k8s.io/kubernetes/vendor \ + k8s.io/kubernetes/vendor/k8s.io/... \ > $@.tmp - if ! cmp -s $@.tmp $@; then \ - if [[ "$(DBG_CODEGEN)" == 1 ]]; then \ - echo "DBG: $(GO_PKGDEPS_FILE) changed"; \ - fi; \ - cat $@.tmp > $@; \ + if [[ -s $@.tmp ]]; then \ + if ! cmp -s $@.tmp $@; then \ + if [[ "$(DBG_CODEGEN)" == 1 ]]; then \ + echo "DBG: $(GO_PKGDEPS_FILE) changed"; \ + fi; \ + cat $@.tmp > $@; \ + fi \ + else \ + kube::log::error "go2make produced no results"; \ + rm -f $@; \ + false; \ fi rm -f $@.tmp endif # MAKE_RESTARTS