From 2b937f6d6ec8b9ed0516187223b6a1f0f72e4799 Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Fri, 23 Sep 2016 21:28:11 -0700 Subject: [PATCH] Fix openapi Make rules to emit 1 file --- Makefile.generated_files | 33 +++++++------------ .../go2idl/openapi-gen/generators/openapi.go | 1 - 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/Makefile.generated_files b/Makefile.generated_files index 59f916d56f6..a09e428fbff 100644 --- a/Makefile.generated_files +++ b/Makefile.generated_files @@ -311,20 +311,11 @@ OPENAPI_DIRS := $(shell \ | sort -u \ ) -OPENAPI_FILES := $(addsuffix /$(OPENAPI_FILENAME), $(OPENAPI_DIRS)) +OPENAPI_OUTFILE := $(OPENAPI_OUTPUT_PKG)/$(OPENAPI_FILENAME) -# This rule aggregates the set of files to generate and then generates them all -# in a single run of the tool. +# This rule is the user-friendly entrypoint for openapi generation. .PHONY: gen_openapi -gen_openapi: $(OPENAPI_FILES) - if [[ -f $(META_DIR)/$(OPENAPI_GEN).todo ]]; then \ - ./hack/run-in-gopath.sh $(OPENAPI_GEN) \ - --v $(KUBE_VERBOSE) \ - --logtostderr \ - -i $$(cat $(META_DIR)/$(OPENAPI_GEN).todo | paste -sd, -) \ - -p $(PRJ_SRC_PATH)/$(OPENAPI_OUTPUT_PKG) \ - -O $(OPENAPI_BASENAME); \ - fi +gen_openapi: $(OPENAPI_OUTFILE) # For each dir in OPENAPI_DIRS, this establishes a dependency between the # output file and the input files that should trigger a rebuild. @@ -339,18 +330,18 @@ gen_openapi: $(OPENAPI_FILES) # We depend on the $(GOFILES_META).stamp to detect when the set of input files # has changed. This allows us to detect deleted input files. $(foreach dir, $(OPENAPI_DIRS), $(eval \ - $(dir)/$(OPENAPI_FILENAME): $(META_DIR)/$(dir)/$(GOFILES_META).stamp \ + $(OPENAPI_OUTFILE): $(META_DIR)/$(dir)/$(GOFILES_META).stamp \ $(gofiles__$(dir)) \ )) -# Unilaterally remove any leftovers from previous runs. -$(shell rm -f $(META_DIR)/$(OPENAPI_GEN)*.todo) - -# How to regenerate open-api code. We need to collect these up and trigger one -# single run to generate definition for all types. -$(OPENAPI_FILES): $(OPENAPI_GEN) - mkdir -p $$(dirname $(META_DIR)/$(OPENAPI_GEN)) - echo $(PRJ_SRC_PATH)/$(@D) >> $(META_DIR)/$(OPENAPI_GEN).todo +# How to regenerate open-api code. This emits a single file for all results. +$(OPENAPI_OUTFILE): $(OPENAPI_GEN) + ./hack/run-in-gopath.sh $(OPENAPI_GEN) \ + --v $(KUBE_VERBOSE) \ + --logtostderr \ + -i $$(echo $(addprefix $(PRJ_SRC_PATH)/, $(OPENAPI_DIRS)) | sed 's/ /,/g') \ + -p $(PRJ_SRC_PATH)/$(OPENAPI_OUTPUT_PKG) \ + -O $(OPENAPI_BASENAME) # This calculates the dependencies for the generator tool, so we only rebuild # it when needed. It is PHONY so that it always runs, but it only updates the diff --git a/cmd/libs/go2idl/openapi-gen/generators/openapi.go b/cmd/libs/go2idl/openapi-gen/generators/openapi.go index 497fe54b442..11d97010f47 100644 --- a/cmd/libs/go2idl/openapi-gen/generators/openapi.go +++ b/cmd/libs/go2idl/openapi-gen/generators/openapi.go @@ -112,7 +112,6 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat }, }, } - return generator.Packages{} } const (