Skip to content

Commit

Permalink
Make debugging Makefile a bit easier
Browse files Browse the repository at this point in the history
  • Loading branch information
thockin committed Jul 13, 2016
1 parent 6e516e1 commit f0ef726
Showing 1 changed file with 31 additions and 27 deletions.
58 changes: 31 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ DBG_MAKEFILE ?=
ifeq ($(DBG_MAKEFILE),1)
$(warning ***** starting makefile for goal(s) "$(MAKECMDGOALS)")
$(warning ***** $(shell date))
else
# If we're not debugging the Makefile, don't echo recipes.
MAKEFLAGS += -s
endif


# Old-skool build tools.
#
# Commonly used targets (see each target for more information):
Expand Down Expand Up @@ -74,7 +78,7 @@ export KUBE_GOLDFLAGS GOLDFLAGS
# make all WHAT=cmd/kubelet GOFLAGS=-v
.PHONY: all
all: generated_files
@hack/make-rules/build.sh $(WHAT)
hack/make-rules/build.sh $(WHAT)

# Build ginkgo
#
Expand All @@ -94,7 +98,7 @@ ginkgo:
# make verify BRANCH=branch_x
.PHONY: verify
verify:
@KUBE_VERIFY_GIT_BRANCH=$(BRANCH) hack/make-rules/verify.sh -v
KUBE_VERIFY_GIT_BRANCH=$(BRANCH) hack/make-rules/verify.sh -v

# Build and run tests.
#
Expand All @@ -111,23 +115,23 @@ verify:
# make check WHAT=pkg/kubelet GOFLAGS=-v
.PHONY: check test
check test: generated_files
@hack/make-rules/test.sh $(WHAT) $(TESTS)
hack/make-rules/test.sh $(WHAT) $(TESTS)

# Build and run integration tests.
#
# Example:
# make test-integration
.PHONY: test-integration
test-integration: generated_files
@hack/make-rules/test-integration.sh
hack/make-rules/test-integration.sh

# Build and run end-to-end tests.
#
# Example:
# make test-e2e
.PHONY: test-e2e
test-e2e: ginkgo generated_files
@go run hack/e2e.go -v --build --up --test --down
go run hack/e2e.go -v --build --up --test --down

# Build and run node end-to-end tests.
#
Expand Down Expand Up @@ -164,7 +168,7 @@ test-e2e: ginkgo generated_files
# Build and run tests.
.PHONY: test-e2e-node
test-e2e-node: ginkgo generated_files
@hack/make-rules/test-e2e-node.sh
hack/make-rules/test-e2e-node.sh

# Build and run cmdline tests.
#
Expand Down Expand Up @@ -212,31 +216,31 @@ clean_generated:
# make vet WHAT=pkg/kubelet
.PHONY: vet
vet:
@hack/make-rules/vet.sh $(WHAT)
hack/make-rules/vet.sh $(WHAT)

# Build a release
#
# Example:
# make release
.PHONY: release
release: generated_files
@build/release.sh
build/release.sh

# Build a release, but skip tests
#
# Example:
# make release-skip-tests
.PHONY: release-skip-tests quick-release
release-skip-tests quick-release: generated_files
@KUBE_RELEASE_RUN_TESTS=n KUBE_FASTBUILD=true build/release.sh
KUBE_RELEASE_RUN_TESTS=n KUBE_FASTBUILD=true build/release.sh

# Cross-compile for all platforms
#
# Example:
# make cross
.PHONY: cross
cross:
@hack/make-rules/cross.sh
hack/make-rules/cross.sh

#
# Code-generation logic.
Expand Down Expand Up @@ -364,7 +368,7 @@ $(foreach dir, $(ALL_GO_DIRS), $(eval \
# but we only need to rebuild targets if the contents actually changed. That
# is what the .stamp file represents.
$(foreach dir, $(ALL_GO_DIRS), $(META_DIR)/$(dir)/$(GOFILES_META)):
@FILES=$$(ls $</*.go | grep -v $(GENERATED_FILE_PREFIX)); \
FILES=$$(ls $</*.go | grep -v $(GENERATED_FILE_PREFIX)); \
mkdir -p $(@D); \
echo "gofiles__$< := $$(echo $${FILES})" >$@.tmp; \
cmp -s $@.tmp $@ || touch $@.stamp; \
Expand Down Expand Up @@ -422,7 +426,7 @@ DEEPCOPY_FILES := $(addsuffix /$(DEEPCOPY_FILENAME), $(DEEPCOPY_DIRS))
# in a single run of the tool.
.PHONY: gen_deepcopy
gen_deepcopy: $(DEEPCOPY_FILES)
@if [[ -f $(META_DIR)/$(DEEPCOPY_GEN).todo ]]; then \
if [[ -f $(META_DIR)/$(DEEPCOPY_GEN).todo ]]; then \
$(DEEPCOPY_GEN) \
-i $$(cat $(META_DIR)/$(DEEPCOPY_GEN).todo | paste -sd,) \
--bounding-dirs $(PRJ_SRC_PATH) \
Expand Down Expand Up @@ -452,14 +456,14 @@ $(shell rm -f $(META_DIR)/$(DEEPCOPY_GEN)*.todo)
# How to regenerate deep-copy code. This is a little slow to run, so we batch
# it up and trigger the batch from the 'generated_files' target.
$(DEEPCOPY_FILES): $(DEEPCOPY_GEN)
@echo $(PRJ_SRC_PATH)/$(@D) >> $(META_DIR)/$(DEEPCOPY_GEN).todo
echo $(PRJ_SRC_PATH)/$(@D) >> $(META_DIR)/$(DEEPCOPY_GEN).todo

# 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
# 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); \
mkdir -p $(@D); \
(echo -n "$(DEEPCOPY_GEN): "; \
DIRECT=$$(go list -e -f '{{.Dir}} {{.Dir}}/*.go' \
./cmd/libs/go2idl/deepcopy-gen); \
Expand All @@ -486,8 +490,8 @@ sinclude $(META_DIR)/$(DEEPCOPY_GEN).mk
# newer than the binary, and try to rebuild it over and over. So we touch it,
# and make is happy.
$(DEEPCOPY_GEN):
@hack/make-rules/build.sh cmd/libs/go2idl/deepcopy-gen
@touch $@
hack/make-rules/build.sh cmd/libs/go2idl/deepcopy-gen
touch $@

#
# Conversion generation
Expand Down Expand Up @@ -532,7 +536,7 @@ CONVERSION_FILES := $(addsuffix /$(CONVERSION_FILENAME), $(CONVERSION_DIRS))
# in a single run of the tool.
.PHONY: gen_conversion
gen_conversion: $(CONVERSION_FILES)
@if [[ -f $(META_DIR)/$(CONVERSION_GEN).todo ]]; then \
if [[ -f $(META_DIR)/$(CONVERSION_GEN).todo ]]; then \
$(CONVERSION_GEN) \
-i $$(cat $(META_DIR)/$(CONVERSION_GEN).todo | paste -sd,) \
-O $(CONVERSION_BASENAME); \
Expand Down Expand Up @@ -563,12 +567,12 @@ $(foreach dir, $(CONVERSION_DIRS), $(eval \
# but we only need to rebuild targets if the contents actually changed. That
# is what the .stamp file represents.
$(foreach dir, $(CONVERSION_DIRS), $(META_DIR)/$(dir)/$(CONVERSIONS_META)):
@TAGS=$$(grep -h '^// *+k8s:conversion-gen=' $</*.go \
| cut -f2- -d= \
| sed 's|$(PRJ_SRC_PATH)/||'); \
mkdir -p $(@D); \
echo "conversions__$< := $$(echo $${TAGS})" >$@.tmp; \
cmp -s $@.tmp $@ || touch $@.stamp; \
TAGS=$$(grep -h '^// *+k8s:conversion-gen=' $</*.go \
| cut -f2- -d= \
| sed 's|$(PRJ_SRC_PATH)/||'); \
mkdir -p $(@D); \
echo "conversions__$< := $$(echo $${TAGS})" >$@.tmp; \
cmp -s $@.tmp $@ || touch $@.stamp; \
mv $@.tmp $@

# Include any deps files as additional Makefile rules. This triggers make to
Expand Down Expand Up @@ -628,14 +632,14 @@ $(shell rm -f $(META_DIR)/$(CONVERSION_GEN)*.todo)
# How to regenerate conversion code. This is a little slow to run, so we batch
# it up and trigger the batch from the 'generated_files' target.
$(CONVERSION_FILES): $(CONVERSION_GEN)
@echo $(PRJ_SRC_PATH)/$(@D) >> $(META_DIR)/$(CONVERSION_GEN).todo
echo $(PRJ_SRC_PATH)/$(@D) >> $(META_DIR)/$(CONVERSION_GEN).todo

# 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
# 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); \
mkdir -p $(@D); \
(echo -n "$(CONVERSION_GEN): "; \
DIRECT=$$(go list -e -f '{{.Dir}} {{.Dir}}/*.go' \
./cmd/libs/go2idl/conversion-gen); \
Expand All @@ -662,8 +666,8 @@ sinclude $(META_DIR)/$(CONVERSION_GEN).mk
# newer than the binary, and try to rebuild it over and over. So we touch it,
# and make is happy.
$(CONVERSION_GEN):
@hack/make-rules/build.sh cmd/libs/go2idl/conversion-gen
@touch $@
hack/make-rules/build.sh cmd/libs/go2idl/conversion-gen
touch $@

# This rule collects all the generated file sets into a single dep, which is
# defined BELOW the *_FILES variables and leaves higher-level rules clean.
Expand Down

0 comments on commit f0ef726

Please sign in to comment.