Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Add some dependency logic around generators. #1966

Merged
merged 1 commit into from
Aug 2, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 13 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's this target for? not used anywhere

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly a convenience, to be able to say "make generators" from the command line. But I've taken your suggestion to reference it throughout instead of $(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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice comment. this is neat. I'm wondering if the find is the right practice vs having golang handle it vs handling it like upstream k/k does with the go2mk generator.


.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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down