From e8d3537249a15d437a2d44e36100f315c598124e Mon Sep 17 00:00:00 2001 From: Vineet Kumar Date: Fri, 20 Apr 2018 16:28:41 -0700 Subject: [PATCH] Add some dependency logic around generators. This isn't 100% correct, but it's a pretty good approximation. Specifically, it doesn't know about transitive dependencies from other go packages. But it'll rebuild a generator if any code inside its package changes (or build them all if anything in gengo changes). --- Makefile | 43 +++++++++++++------------------------------ 1 file changed, 13 insertions(+), 30 deletions(-) diff --git a/Makefile b/Makefile index 5fc0f0d9d35..80d592a25f9 100644 --- a/Makefile +++ b/Makefile @@ -143,42 +143,26 @@ $(BINDIR)/service-catalog: .init .generate_files cmd/service-catalog # This section contains the code generation stuff ################################################# -.generate_exes: $(BINDIR)/defaulter-gen \ - $(BINDIR)/deepcopy-gen \ - $(BINDIR)/conversion-gen \ - $(BINDIR)/client-gen \ - $(BINDIR)/lister-gen \ - $(BINDIR)/informer-gen \ - $(BINDIR)/openapi-gen - touch $@ - -$(BINDIR)/defaulter-gen: .init - $(DOCKER_CMD) go build -o $@ $(SC_PKG)/vendor/k8s.io/code-generator/cmd/defaulter-gen - -$(BINDIR)/deepcopy-gen: .init - $(DOCKER_CMD) go build -o $@ $(SC_PKG)/vendor/k8s.io/code-generator/cmd/deepcopy-gen - -$(BINDIR)/conversion-gen: .init - $(DOCKER_CMD) go build -o $@ $(SC_PKG)/vendor/k8s.io/code-generator/cmd/conversion-gen - -$(BINDIR)/client-gen: .init - $(DOCKER_CMD) go build -o $@ $(SC_PKG)/vendor/k8s.io/code-generator/cmd/client-gen +GENERATORS = $(addprefix $(BINDIR)/, defaulter-gen deepcopy-gen conversion-gen \ + client-gen lister-gen informer-gen openapi-gen) -$(BINDIR)/lister-gen: .init - $(DOCKER_CMD) go build -o $@ $(SC_PKG)/vendor/k8s.io/code-generator/cmd/lister-gen +.PHONY: generators +generators: $(GENERATORS) -$(BINDIR)/informer-gen: .init - $(DOCKER_CMD) go build -o $@ $(SC_PKG)/vendor/k8s.io/code-generator/cmd/informer-gen +.SECONDEXPANSION: -$(BINDIR)/openapi-gen: vendor/k8s.io/code-generator/cmd/openapi-gen - $(DOCKER_CMD) go build -o $@ $(SC_PKG)/$^ +# We specify broad dependencies for these generator binaries: each one depends +# on everything under its source tree as well as gengo's. This uses GNU Make's +# secondary expansion feature to pass $* to `find`. +$(BINDIR)/%-gen: $$(shell find vendor/k8s.io/code-generator/cmd/$$*-gen vendor/k8s.io/gengo) .init + $(DOCKER_CMD) go build -o $@ $(SC_PKG)/vendor/k8s.io/code-generator/cmd/$*-gen .PHONY: $(BINDIR)/e2e.test $(BINDIR)/e2e.test: .init $(DOCKER_CMD) go test -c -o $@ $(SC_PKG)/test/e2e # Regenerate all files if the gen exes changed or any "types.go" files changed -.generate_files: .init .generate_exes $(TYPES_FILES) +.generate_files: .init generators $(TYPES_FILES) # generate apiserver deps $(DOCKER_CMD) $(BUILD_DIR)/update-apiserver-gen.sh # generate all pkg/client contents @@ -235,10 +219,10 @@ verify-docs: .init docs @echo Running href checker$(SKIP_COMMENT): @$(DOCKER_CMD) verify-links.sh -s .pkg -s .bundler -s _plugins -s _includes -t $(SKIP_HTTP) . -verify-generated: .init .generate_exes +verify-generated: .init generators $(DOCKER_CMD) $(BUILD_DIR)/update-apiserver-gen.sh --verify-only -verify-client-gen: .init .generate_exes +verify-client-gen: .init generators $(DOCKER_CMD) $(BUILD_DIR)/verify-client-gen.sh format: .init @@ -291,7 +275,6 @@ clean: clean-bin clean-build-image clean-generated clean-coverage clean-bin: .init $(scBuildImageTarget) $(DOCKER_CMD) rm -rf $(BINDIR) - rm -f .generate_exes clean-build-image: .init $(scBuildImageTarget) $(DOCKER_CMD) rm -rf .pkg