Merge pull request #39331 from thockin/makefile-simplify-go-list

Automatic merge from submit-queue (batch tested with PRs 39022, 39331, 39070, 39344)

Makefile speedup on generated code

This has been languishing in a  branch for a long time.  It makes the build more consistent wrt GOPATH (I still hope to enforce GOPATH at some point) and it removes a `go list` from each codegen.

I verified manually that the files that this emits as part of the make are only change in safe ways (ordering, _test files removed, etc).
This commit is contained in:
Kubernetes Submit Queue 2017-01-03 10:32:20 -08:00 committed by GitHub
commit 1d8297ce92

View File

@ -271,20 +271,19 @@ $(DEEPCOPY_FILES): $(DEEPCOPY_GEN)
# file if the contents have actually changed. We 'sinclude' this later.
.PHONY: $(META_DIR)/$(DEEPCOPY_GEN).mk
$(META_DIR)/$(DEEPCOPY_GEN).mk:
mkdir -p $(@D); \
(echo -n "$(DEEPCOPY_GEN): "; \
DIRECT=$$(go list -f '{{.Dir}} {{.Dir}}/*.go' \
./cmd/libs/go2idl/deepcopy-gen); \
INDIRECT=$$(go list \
-f '{{range .Deps}}{{.}}{{"\n"}}{{end}}' \
./cmd/libs/go2idl/deepcopy-gen \
| grep --color=never "^$(PRJ_SRC_PATH)" \
| sed 's|^$(PRJ_SRC_PATH)|./|' \
| xargs go list -f '{{.Dir}} {{.Dir}}/*.go'); \
echo $$DIRECT $$INDIRECT \
| sed 's/ / \\=,/g' \
| tr '=,' '\n\t'; \
) | sed "s|$$(pwd -P)/||" > $@.tmp; \
mkdir -p $(@D); \
(echo -n "$(DEEPCOPY_GEN): "; \
./hack/run-in-gopath.sh go list \
-f '{{.ImportPath}}{{"\n"}}{{range .Deps}}{{.}}{{"\n"}}{{end}}' \
./cmd/libs/go2idl/deepcopy-gen \
| grep --color=never "^$(PRJ_SRC_PATH)/" \
| xargs ./hack/run-in-gopath.sh go list \
-f '{{$$d := .Dir}}{{$$d}}{{"\n"}}{{range .GoFiles}}{{$$d}}/{{.}}{{"\n"}}{{end}}' \
| paste -sd' ' - \
| sed 's/ / \\=,/g' \
| tr '=,' '\n\t' \
| sed "s|$$(pwd -P)/||"; \
) > $@.tmp; \
cmp -s $@.tmp $@ || cat $@.tmp > $@ && rm -f $@.tmp
# Include dependency info for the generator tool. This will cause the rule of
@ -422,20 +421,19 @@ $(DEFAULTER_FILES): $(DEFAULTER_GEN)
# file if the contents have actually changed. We 'sinclude' this later.
.PHONY: $(META_DIR)/$(DEFAULTER_GEN).mk
$(META_DIR)/$(DEFAULTER_GEN).mk:
mkdir -p $(@D); \
(echo -n "$(DEFAULTER_GEN): "; \
DIRECT=$$(go list -f '{{.Dir}} {{.Dir}}/*.go' \
./cmd/libs/go2idl/defaulter-gen); \
INDIRECT=$$(go list \
-f '{{range .Deps}}{{.}}{{"\n"}}{{end}}' \
./cmd/libs/go2idl/defaulter-gen \
| grep --color=never "^$(PRJ_SRC_PATH)" \
| sed 's|^$(PRJ_SRC_PATH)|./|' \
| xargs go list -f '{{.Dir}} {{.Dir}}/*.go'); \
echo $$DIRECT $$INDIRECT \
| sed 's/ / \\=,/g' \
| tr '=,' '\n\t'; \
) | sed "s|$$(pwd -P)/||" > $@.tmp; \
mkdir -p $(@D); \
(echo -n "$(DEFAULTER_GEN): "; \
./hack/run-in-gopath.sh go list \
-f '{{.ImportPath}}{{"\n"}}{{range .Deps}}{{.}}{{"\n"}}{{end}}' \
./cmd/libs/go2idl/defaulter-gen \
| grep --color=never "^$(PRJ_SRC_PATH)/" \
| xargs ./hack/run-in-gopath.sh go list \
-f '{{$$d := .Dir}}{{$$d}}{{"\n"}}{{range .GoFiles}}{{$$d}}/{{.}}{{"\n"}}{{end}}' \
| paste -sd' ' - \
| sed 's/ / \\=,/g' \
| tr '=,' '\n\t' \
| sed "s|$$(pwd -P)/||"; \
) > $@.tmp; \
cmp -s $@.tmp $@ || cat $@.tmp > $@ && rm -f $@.tmp
# Include dependency info for the generator tool. This will cause the rule of
@ -529,20 +527,19 @@ $(OPENAPI_OUTFILE): $(OPENAPI_GEN) $(OPENAPI_GEN)
# file if the contents have actually changed. We 'sinclude' this later.
.PHONY: $(META_DIR)/$(OPENAPI_GEN).mk
$(META_DIR)/$(OPENAPI_GEN).mk:
mkdir -p $(@D); \
(echo -n "$(OPENAPI_GEN): "; \
DIRECT=$$(go list -f '{{.Dir}} {{.Dir}}/*.go' \
./cmd/libs/go2idl/openapi-gen); \
INDIRECT=$$(go list \
-f '{{range .Deps}}{{.}}{{"\n"}}{{end}}' \
./cmd/libs/go2idl/openapi-gen \
| grep --color=never "^$(PRJ_SRC_PATH)" \
| sed 's|^$(PRJ_SRC_PATH)|./|' \
| xargs go list -f '{{.Dir}} {{.Dir}}/*.go'); \
echo $$DIRECT $$INDIRECT \
| sed 's/ / \\=,/g' \
| tr '=,' '\n\t'; \
) | sed "s|$$(pwd -P)/||" > $@.tmp; \
mkdir -p $(@D); \
(echo -n "$(OPENAPI_GEN): "; \
./hack/run-in-gopath.sh go list \
-f '{{.ImportPath}}{{"\n"}}{{range .Deps}}{{.}}{{"\n"}}{{end}}' \
./cmd/libs/go2idl/openapi-gen \
| grep --color=never "^$(PRJ_SRC_PATH)/" \
| xargs ./hack/run-in-gopath.sh go list \
-f '{{$$d := .Dir}}{{$$d}}{{"\n"}}{{range .GoFiles}}{{$$d}}/{{.}}{{"\n"}}{{end}}' \
| paste -sd' ' - \
| sed 's/ / \\=,/g' \
| tr '=,' '\n\t' \
| sed "s|$$(pwd -P)/||"; \
) > $@.tmp; \
cmp -s $@.tmp $@ || cat $@.tmp > $@ && rm -f $@.tmp
# Include dependency info for the generator tool. This will cause the rule of
@ -724,20 +721,19 @@ $(CONVERSION_FILES): $(CONVERSION_GEN)
# file if the contents have actually changed. We 'sinclude' this later.
.PHONY: $(META_DIR)/$(CONVERSION_GEN).mk
$(META_DIR)/$(CONVERSION_GEN).mk:
mkdir -p $(@D); \
(echo -n "$(CONVERSION_GEN): "; \
DIRECT=$$(go list -f '{{.Dir}} {{.Dir}}/*.go' \
./cmd/libs/go2idl/conversion-gen); \
INDIRECT=$$(go list \
-f '{{range .Deps}}{{.}}{{"\n"}}{{end}}' \
./cmd/libs/go2idl/conversion-gen \
| grep --color=never "^$(PRJ_SRC_PATH)" \
| sed 's|^$(PRJ_SRC_PATH)|./|' \
| xargs go list -f '{{.Dir}} {{.Dir}}/*.go'); \
echo $$DIRECT $$INDIRECT \
| sed 's/ / \\=,/g' \
| tr '=,' '\n\t'; \
) | sed "s|$$(pwd -P)/||" > $@.tmp; \
mkdir -p $(@D); \
(echo -n "$(CONVERSION_GEN): "; \
./hack/run-in-gopath.sh go list \
-f '{{.ImportPath}}{{"\n"}}{{range .Deps}}{{.}}{{"\n"}}{{end}}' \
./cmd/libs/go2idl/conversion-gen \
| grep --color=never "^$(PRJ_SRC_PATH)/" \
| xargs ./hack/run-in-gopath.sh go list \
-f '{{$$d := .Dir}}{{$$d}}{{"\n"}}{{range .GoFiles}}{{$$d}}/{{.}}{{"\n"}}{{end}}' \
| paste -sd' ' - \
| sed 's/ / \\=,/g' \
| tr '=,' '\n\t' \
| sed "s|$$(pwd -P)/||"; \
) > $@.tmp; \
cmp -s $@.tmp $@ || cat $@.tmp > $@ && rm -f $@.tmp
# Include dependency info for the generator tool. This will cause the rule of