Skip to contentSkip to conversation

build-sys: generate tests/.gitignore

PATCH New Marc-André Lureau 1 participant 1 message Sep 11, 2017 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 build-sys: generate tests/.gitignore

tests/.gitignore is often out of date. Let's generate it based on the files and directories to clean. Generate it by default only when doing in-tree build.

---
 Makefile                   |  9 ++++-
 tests/.gitignore           | 97 ----------------------------------------------
 tests/Makefile.include     | 38 ++++++++++++++++--
 tests/migration/.gitignore |  2 -
 4 files changed, 42 insertions(+), 104 deletions(-)
 delete mode 100644 tests/.gitignore
 delete mode 100644 tests/migration/.gitignore

v2:
- only generate when doing in-tree builds
- fix wrong ignore of tests/qemu-iotests-quick.sh

Makefile +8 -1
index 81447b1f08..2ccb98cd64 100644
@@ -6,7 +6,7 @@ BUILD_DIR=$(CURDIR)
 # Before including a proper config-host.mak, assume we are in the source tree
 SRC_PATH=.
 
-UNCHECKED_GOALS := %clean TAGS cscope ctags docker docker-%
+UNCHECKED_GOALS := %clean TAGS cscope ctags docker docker-% gitignore
 
 # All following code might depend on configuration variables
 ifneq ($(wildcard config-host.mak),)
@@ -14,6 +14,13 @@ ifneq ($(wildcard config-host.mak),)
 all:
 include config-host.mak
 
+.PHONY: gitignore
+ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
+ifeq ($(BUILD_DIR),$(SRC_PATH))
+all $(MAKECMDGOALS): gitignore
+endif
+endif
+
 # Check that we're not trying to do an out-of-tree build from
 # a tree that's been used for an in-tree build.
 ifneq ($(realpath $(SRC_PATH)),$(realpath .))
tests/.gitignore deleted +0 -97

97 lines not on this page · raw message

tests/Makefile.include +34 -4
index f08b7418f0..29d8e4ebf4 100644
@@ -901,8 +901,33 @@ $(patsubst %, check-%, $(check-qapi-schema-y)): check-%.json: $(SRC_PATH)/%.json
 check-tests/qapi-schema/doc-good.texi: tests/qapi-schema/doc-good.test.texi
 	@diff -q $(SRC_PATH)/tests/qapi-schema/doc-good.texi $<
 
-# Consolidated targets
+tests-cleanfiles = *.o
+tests-cleanfiles += .gitignore
+tests-cleanfiles += qht-bench$(EXESUF)
+tests-cleanfiles += qapi-schema/*.test.*
+tests-cleanfiles += test-qapi-event.[ch]
+tests-cleanfiles += test-qapi-types.[ch]
+tests-cleanfiles += test-qapi-visit.[ch]
+tests-cleanfiles += test-qmp-introspect.[ch]
+tests-cleanfiles += test-qmp-commands.h
+tests-cleanfiles += test-qmp-marshal.c
+tests-cleanfiles += $(subst tests/,,$(check-unit-y))
+tests-cleanfiles += $(subst tests/,,$(check-speed-y))
+tests-cleanfiles += $(subst tests/,,$(check-qtest-y))
+tests-cleanfiles += $(subst tests/,,$(QEMU_IOTESTS_HELPERS-y))
+tests-cleanfiles += migration/initrd-stress.img
+tests-cleanfiles += migration/stress$(EXESUF)
+tests-cleanfiles += atomic_add-bench$(EXESUF)
+tests-cleanfiles += test-io-channel-file.txt
+tests-cleanfiles += test-io-channel-command.fifo
+
+tests-cleandirs += test-crypto-tlscredsx509-certs/
+tests-cleandirs += test-crypto-tlscredsx509-work/
+tests-cleandirs += test-crypto-tlssession-client/
+tests-cleandirs += test-crypto-tlssession-server/
+tests-cleandirs += test-crypto-tlssession-work/
 
+# Consolidated targets
 .PHONY: check-qapi-schema check-qtest check-unit check check-clean
 check-qapi-schema: $(patsubst %,check-%, $(check-qapi-schema-y)) check-tests/qapi-schema/doc-good.texi
 check-qtest: $(patsubst %,check-qtest-%, $(QTEST_TARGETS))
@@ -912,15 +937,20 @@ check-block: $(patsubst %,check-%, $(check-block-y))
 check: check-qapi-schema check-unit check-qtest
 check-clean:
 	$(MAKE) -C tests/tcg clean
-	rm -rf $(check-unit-y) tests/*.o $(QEMU_IOTESTS_HELPERS-y)
-	rm -rf $(sort $(foreach target,$(SYSEMU_TARGET_LIST), $(check-qtest-$(target)-y)) $(check-qtest-generic-y))
-
+	rm -f $(addprefix tests/, $(tests-cleanfiles))
+	rm -rf $(addprefix tests/, $(tests-cleandirs))
 clean: check-clean
 
 # Build the help program automatically
 
 all: $(QEMU_IOTESTS_HELPERS-y)
 
+$(SRC_PATH)/tests/.gitignore: $(MAKEFILE_LIST)
+	$(call quiet-command, echo "$(tests-cleanfiles)" "$(tests-cleandirs)" | \
+		xargs -n1 | sort | uniq | sed -e s:^:/: > $@,"GEN","$(@F)")
+
+gitignore: $(SRC_PATH)/tests/.gitignore
+
 -include $(wildcard tests/*.d)
 -include $(wildcard tests/libqos/*.d)
 
tests/migration/.gitignore deleted +0 -2
deleted file mode 100644
index 84f37552e4..0000000000
@@ -1,2 +0,0 @@
-initrd-stress.img
-stress
Signature · 1 line
2.14.1.146.gd35faa819