Skip to content

Commit

Permalink
chore(build): refactor generate make command
Browse files Browse the repository at this point in the history
  • Loading branch information
JGiola committed May 31, 2024
1 parent 69bf47c commit 2096ad5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 24 deletions.
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ endif

# Set here the name of the package you want to build
CMDNAME:= vab
BUILD_PATH:= ./cmd/$(CMDNAME)
BUILD_PATH:= .
CONFORMANCE_TEST_PATH:= $(PROJECT_DIR)/internal/e2e
IS_LIBRARY:=

Expand All @@ -65,9 +65,6 @@ VERSION:= $(shell git describe --tags --exact-match 2>/dev/null || (echo $(GIT_R
# insert here the go module where to add the version metadata
VERSION_MODULE_NAME:= github.com/mia-platform/vab/internal/cmd

# insert here comma separated packages relative path, that need to have some files generated by deepcopy-gen
PACKAGES_TO_GENERATE:=

# supported platforms for container creation, these are a subset of the supported
# platforms of the base image.
# Or if you start from scratch the platforms you want to support in your image
Expand Down Expand Up @@ -123,3 +120,10 @@ start-kind:

stop-kind:
$(TOOLS_DIR)/stop-kind.sh ${KIND_CLUSTER_1_NAME} ${KIND_CLUSTER_2_NAME}

generate-deps: $(TOOLS_BIN)/deepcopy-gen
$(TOOLS_BIN)/deepcopy-gen: $(TOOLS_DIR)/DEEPCOPY_GEN_VERSION
$(eval DEEPCOPY_GEN_VERSION:= $(shell cat $<))
mkdir -p $(TOOLS_BIN)
$(info Installing deepcopy-gen $(DEEPCOPY_GEN_VERSION) bin in $(TOOLS_BIN))
GOBIN=$(TOOLS_BIN) go install k8s.io/code-generator/cmd/deepcopy-gen@$(DEEPCOPY_GEN_VERSION)
24 changes: 4 additions & 20 deletions tools/make/generate.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,10 @@
# limitations under the License.

##@ Deepcopy Goals

.PHONY: generate
generate:

.PHONY: generate-deps
generate-deps:

.PHONY: generate/deepcopy
generate/deepcopy:
$(info Running deepcopy-gen...)
$(TOOLS_BIN)/deepcopy-gen -i $(PACKAGES_TO_GENERATE) \
-o "$(PROJECT_DIR)" -O zz_generated.deepcopy --go-header-file $(TOOLS_DIR)/boilerplate.go.txt

$(TOOLS_BIN)/deepcopy-gen: $(TOOLS_DIR)/DEEPCOPY_GEN_VERSION
$(eval DEEPCOPY_GEN_VERSION:= $(shell cat $<))
mkdir -p $(TOOLS_BIN)
$(info Installing deepcopy-gen $(DEEPCOPY_GEN_VERSION) bin in $(TOOLS_BIN))
GOBIN=$(TOOLS_BIN) go install k8s.io/code-generator/cmd/deepcopy-gen@$(DEEPCOPY_GEN_VERSION)
generate-deps: $(TOOLS_BIN)/deepcopy-gen

.PHONY: generate-deepcopy
generate-deepcopy: $(TOOLS_BIN)/deepcopy-gen generate/deepcopy
generate: generate-deepcopy
.PHONY: generate
generate: generate-deps
go generate ./...
${TOOLS_BIN}/deepcopy-gen -i ./pkg/apis/vab.mia-platform.eu/v1alpha1 -o ${PROJECT_DIR} -O zz_generated.deepcopy --go-header-file ${TOOLS_DIR}/boilerplate.go.txt

0 comments on commit 2096ad5

Please sign in to comment.