Skip to contentSkip to conversation

build-sys: generate tests/.gitignore

PATCH In review Marc-André Lureau 5 participants 7 messages Sep 4, 2017 – Sep 6, 2017 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 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.

Note: I didn't succeed yet at generalizing this approach for the rest of qemu .gitignore files, but I hope it may eventually happen.

---
 Makefile                   |  7 +++-
 tests/.gitignore           | 97 ----------------------------------------------
 tests/Makefile.include     | 39 +++++++++++++++++--
 tests/migration/.gitignore |  2 -
 4 files changed, 41 insertions(+), 104 deletions(-)
 delete mode 100644 tests/.gitignore
 delete mode 100644 tests/migration/.gitignore
Makefile +6 -1
index 81447b1f08..89d5edf531 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,11 @@ ifneq ($(wildcard config-host.mak),)
 all:
 include config-host.mak
 
+.PHONY: gitignore
+ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
+all $(MAKECMDGOALS): gitignore
+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 +35 -4
index f08b7418f0..e94671e879 100644
@@ -901,8 +901,34 @@ $(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-block-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 +938,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
#1 lore raw
Quoted 185 lines · Marc-André Lureau

tests/.gitignore is often out of date. Let's generate it based on the files and directories to clean.

Note: I didn't succeed yet at generalizing this approach for the rest of qemu .gitignore files, but I hope it may eventually happen.

---
 Makefile                   |  7 +++-
 tests/.gitignore           | 97 ----------------------------------------------
 tests/Makefile.include     | 39 +++++++++++++++++--
 tests/migration/.gitignore |  2 -
 4 files changed, 41 insertions(+), 104 deletions(-)
 delete mode 100644 tests/.gitignore
 delete mode 100644 tests/migration/.gitignore
Makefile +6 -1
index 81447b1f08..89d5edf531 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,11 @@ ifneq ($(wildcard config-host.mak),)
 all:
 include config-host.mak
 
+.PHONY: gitignore
+ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
+all $(MAKECMDGOALS): gitignore
+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
deleted file mode 100644
index fed0189a5a..0000000000
@@ -1,97 +0,0 @@
-atomic_add-bench
-benchmark-crypto-cipher
-benchmark-crypto-hash
-benchmark-crypto-hmac
-check-qdict
-check-qnum
-check-qjson
-check-qlist
-check-qnull
-check-qstring
-check-qom-interface
-check-qom-proplist
-qht-bench
-rcutorture
-test-aio
-test-aio-multithread
-test-arm-mptimer
-test-base64
-test-bitops
-test-bitcnt
-test-blockjob
-test-blockjob-txn
-test-bufferiszero
-test-char
-test-clone-visitor
-test-coroutine
-test-crypto-afsplit
-test-crypto-block
-test-crypto-cipher
-test-crypto-hash
-test-crypto-hmac
-test-crypto-ivgen
-test-crypto-pbkdf
-test-crypto-secret
-test-crypto-tlscredsx509
-test-crypto-tlscredsx509-work/
-test-crypto-tlscredsx509-certs/
-test-crypto-tlssession
-test-crypto-tlssession-work/
-test-crypto-tlssession-client/
-test-crypto-tlssession-server/
-test-crypto-xts
-test-cutils
-test-hbitmap
-test-hmp
-test-int128
-test-iov
-test-io-channel-buffer
-test-io-channel-command
-test-io-channel-command.fifo
-test-io-channel-file
-test-io-channel-file.txt
-test-io-channel-socket
-test-io-channel-tls
-test-io-task
-test-keyval
-test-logging
-test-mul64
-test-opts-visitor
-test-qapi-event.[ch]
-test-qapi-types.[ch]
-test-qapi-util
-test-qapi-visit.[ch]
-test-qdev-global-props
-test-qemu-opts
-test-qdist
-test-qga
-test-qht
-test-qht-par
-test-qmp-commands
-test-qmp-commands.h
-test-qmp-event
-test-qobject-input-strict
-test-qobject-input-visitor
-test-qmp-introspect.[ch]
-test-qmp-marshal.c
-test-qobject-output-visitor
-test-rcu-list
-test-replication
-test-shift128
-test-string-input-visitor
-test-string-output-visitor
-test-thread-pool
-test-throttle
-test-timed-average
-test-uuid
-test-visitor-serialization
-test-vmstate
-test-write-threshold
-test-x86-cpuid
-test-x86-cpuid-compat
-test-xbzrle
-test-netfilter
-test-filter-mirror
-test-filter-redirector
-*-test
-qapi-schema/*.test.*
tests/Makefile.include +27 -1
index f08b7418f0..e94671e879 100644
@@ -901,8 +901,34 @@ $(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-block-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))

tests/Makefile.include check-block: $(patsubst %,check-%, $(check-block-y)) · line 942

Quoted 8 lines
tests/Makefile.include +2 -3
@@ -912,15 +938,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))

I think you should mention this in the patch description, too, that you're touching the "clean" target here.

tests/Makefile.include check-block: $(patsubst %,check-%, $(check-block-y)) · line 951

Quoted 9 lines
tests/Makefile.include +3 -0
 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)")

Please do not use SRC_PATH here. I'm doing out of tree builds, and I don't want that these are touching my source folder!

Thomas

#2 lore raw

Hi

Quoted 212 lines · Thomas Huth
Quoted 10 lines · Marc-André Lureau

tests/.gitignore is often out of date. Let's generate it based on the files and directories to clean.

Note: I didn't succeed yet at generalizing this approach for the rest of qemu .gitignore files, but I hope it may eventually happen.

---
 Makefile                   |  7 +++-
 tests/.gitignore           | 97

----------------------------------------------

Makefile BUILD_DIR=$(CURDIR) · line 6

Quoted 12 lines
 tests/Makefile.include     | 39 +++++++++++++++++--
 tests/migration/.gitignore |  2 -
 4 files changed, 41 insertions(+), 104 deletions(-)
 delete mode 100644 tests/.gitignore
 delete mode 100644 tests/migration/.gitignore
Makefile +0 -0
index 81447b1f08..89d5edf531 100644
@@ -6,7 +6,7 @@ BUILD_DIR=$(CURDIR)
 # Before including a proper config-host.mak, assume we are in the

source tree

Makefile ifneq ($(wildcard config-host.mak),) · line 18

Quoted 13 lines
Makefile +3 -1
 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,11 @@ ifneq ($(wildcard config-host.mak),)
 all:
 include config-host.mak
 
+.PHONY: gitignore
+ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if

$(MAKECMDGOALS),,fail))

tests/Makefile.include $(patsubst %, check-%, $(check-qapi-schema-y)):

Quoted 114 lines
Makefile +3 -0
+all $(MAKECMDGOALS): gitignore
+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
deleted file mode 100644
index fed0189a5a..0000000000
@@ -1,97 +0,0 @@
-atomic_add-bench
-benchmark-crypto-cipher
-benchmark-crypto-hash
-benchmark-crypto-hmac
-check-qdict
-check-qnum
-check-qjson
-check-qlist
-check-qnull
-check-qstring
-check-qom-interface
-check-qom-proplist
-qht-bench
-rcutorture
-test-aio
-test-aio-multithread
-test-arm-mptimer
-test-base64
-test-bitops
-test-bitcnt
-test-blockjob
-test-blockjob-txn
-test-bufferiszero
-test-char
-test-clone-visitor
-test-coroutine
-test-crypto-afsplit
-test-crypto-block
-test-crypto-cipher
-test-crypto-hash
-test-crypto-hmac
-test-crypto-ivgen
-test-crypto-pbkdf
-test-crypto-secret
-test-crypto-tlscredsx509
-test-crypto-tlscredsx509-work/
-test-crypto-tlscredsx509-certs/
-test-crypto-tlssession
-test-crypto-tlssession-work/
-test-crypto-tlssession-client/
-test-crypto-tlssession-server/
-test-crypto-xts
-test-cutils
-test-hbitmap
-test-hmp
-test-int128
-test-iov
-test-io-channel-buffer
-test-io-channel-command
-test-io-channel-command.fifo
-test-io-channel-file
-test-io-channel-file.txt
-test-io-channel-socket
-test-io-channel-tls
-test-io-task
-test-keyval
-test-logging
-test-mul64
-test-opts-visitor
-test-qapi-event.[ch]
-test-qapi-types.[ch]
-test-qapi-util
-test-qapi-visit.[ch]
-test-qdev-global-props
-test-qemu-opts
-test-qdist
-test-qga
-test-qht
-test-qht-par
-test-qmp-commands
-test-qmp-commands.h
-test-qmp-event
-test-qobject-input-strict
-test-qobject-input-visitor
-test-qmp-introspect.[ch]
-test-qmp-marshal.c
-test-qobject-output-visitor
-test-rcu-list
-test-replication
-test-shift128
-test-string-input-visitor
-test-string-output-visitor
-test-thread-pool
-test-throttle
-test-timed-average
-test-uuid
-test-visitor-serialization
-test-vmstate
-test-write-threshold
-test-x86-cpuid
-test-x86-cpuid-compat
-test-xbzrle
-test-netfilter
-test-filter-mirror
-test-filter-redirector
-*-test
-qapi-schema/*.test.*
tests/Makefile.include +0 -0
index f08b7418f0..e94671e879 100644
@@ -901,8 +901,34 @@ $(patsubst %, check-%, $(check-qapi-schema-y)):

check-%.json: $(SRC_PATH)/%.json

tests/Makefile.include $(patsubst %, check-%, $(check-qapi-schema-y)): · line 901

Quoted 1 line
tests/Makefile.include +0 -0
 check-tests/qapi-schema/doc-good.texi:

tests/qapi-schema/doc-good.test.texi

Quoted 23 lines
tests/Makefile.include +20 -1
      @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-block-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/Makefile.include $(patsubst %, check-%, $(check-qapi-schema-y)): check-%.json: $(SRC_PATH)/%.json

Quoted 10 lines
tests/Makefile.include +7 -0
+
+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

tests/Makefile.include check-block: $(patsubst %,check-%,

Quoted 2 lines
tests/Makefile.include +0 -0
 check-qtest: $(patsubst %,check-qtest-%, $(QTEST_TARGETS))
@@ -912,15 +938,20 @@ check-block: $(patsubst %,check-%,

$(check-block-y))

tests/Makefile.include check-block: $(patsubst %,check-%, $(check-block-y))

Quoted 5 lines
tests/Makefile.include +0 -2
 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))

tests/Makefile.include check-block: $(patsubst %,check-%, $(check-block-y)) · line 942

Quoted 3 lines
tests/Makefile.include +2 -1
-
+     rm -f $(addprefix tests/, $(tests-cleanfiles))
+     rm -rf $(addprefix tests/, $(tests-cleandirs))

I think you should mention this in the patch description, too, that you're touching the "clean" target here.

Quoted 6 lines
tests/Makefile.include +0 -0
 clean: check-clean
 
 # Build the help program automatically
 
 all: $(QEMU_IOTESTS_HELPERS-y)
 
Quoted 8 lines

tests/Makefile.include check-block: $(patsubst %,check-%, · line 950

Quoted 2 lines
tests/Makefile.include +2 -0
+$(SRC_PATH)/tests/.gitignore: $(MAKEFILE_LIST)
+     $(call quiet-command, echo "$(tests-cleanfiles)"

"$(tests-cleandirs)" | \

tests/Makefile.include check-block: $(patsubst %,check-%, $(check-block-y)) · line 951

Quoted 1 line
tests/Makefile.include +1 -0
+             xargs -n1 | sort | uniq | sed -e s:^:/: > $@,"GEN","$(@F)")

Please do not use SRC_PATH here. I'm doing out of tree builds, and I don't want that these are touching my source folder!

I understand the feeling, I do also mostly out of tree build. However, I don't think it makes much sense to generate .gitignore in the build dir. It's git related, and in the git source dir, you have .git that is writable
already: it'd be odd that the git wortree/srcdir is read-only, and the point is to generate .gitignore. Not so true with tarballs though.

I wrote this patch inspired by how the
https://github.com/behdad/git.mk/blob/master/git.mk rules does it (it is uses by many GNOME projects and others with autoconf). The way it gets away with not touching the srcdir in non-git tree, is that the git.mk file is not shipped in distributed tarball. We could have a similar approach if necessary.

Another alternative, which I find much less appealing, is that qemu tree keeps shipping .gitignore, and we just add a manual rule to maintain it.

You suggested using more test* *test etc wildcards. I think this is bad, I would rather have a precise .gitignore, and not ignore extra files that are not part of the build-system. I couldn't find a simple way to generate precise rules for intermediary files (like .o etc), but for end targets, this patch demonstrates it can be done quite easily.

Finally, there is this trend these days with meson to not even allow in-tree build, and thus no need for .gitignore..

Signature · 1 line
Marc-André Lureau
#3 lore raw
Quoted 7 lines · Marc-André Lureau

I understand the feeling, I do also mostly out of tree build. However, I don't think it makes much sense to generate .gitignore in the build dir. It's git related, and in the git source dir, you have .git that is writable
already: it'd be odd that the git wortree/srcdir is read-only, and the point is to generate .gitignore. Not so true with tarballs though.

Quoted 6 lines

I wrote this patch inspired by how the
https://github.com/behdad/git.mk/blob/master/git.mk rules does it (it is uses by many GNOME projects and others with autoconf). The way it gets away with not touching the srcdir in non-git tree, is that the git.mk file is not shipped in distributed tarball. We could have a similar approach if necessary.

Shipping .gitignore in the tarball is not necessary; it's main benefit is for in-tree development.

Quoted 3 lines

Another alternative, which I find much less appealing, is that qemu tree keeps shipping .gitignore, and we just add a manual rule to maintain it.

Keeping .gitignore in git, if it is generated, is a pain, because then we have to manually resync it every time it gets out of date (and we're already demonstrating that we forget to update .gitignore with new tests). This patch is only worthwhile if it reduces maintainer overhead, but not if it trades one task for another.

Quoted 9 lines

You suggested using more test* *test etc wildcards. I think this is bad, I would rather have a precise .gitignore, and not ignore extra files that are not part of the build-system. I couldn't find a simple way to generate precise rules for intermediary files (like .o etc), but for end targets, this patch demonstrates it can be done quite easily.

Finally, there is this trend these days with meson to not even allow in-tree build, and thus no need for .gitignore..

Please don't go the direction of forbidding in-tree builds. While I am a BIG fan of VPATH builds, I'm also a big fan of in-tree builds (it's slightly faster to do a one-off in-tree build of a fresh git checkout than it is to set up yet another VPATH build directory). Projects that force one way or the other are annoying. I see no reason why we should not keep both approaches working, particularly if we have patchew or other automation that covers both styles.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#4 lore raw
Quoted 11 lines · Eric Blake
Quoted 10 lines · Marc-André Lureau
Quoted 8 lines · Thomas Huth
Quoted 7 lines · Marc-André Lureau

tests/.gitignore is often out of date. Let's generate it based on the files and directories to clean.

Note: I didn't succeed yet at generalizing this approach for the rest of qemu .gitignore files, but I hope it may eventually happen.

[...]

Quoted 57 lines
Quoted 57 lines
Quoted 57 lines
Quoted 41 lines
tests/Makefile.include +27 -1
index f08b7418f0..e94671e879 100644
@@ -901,8 +901,34 @@ $(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-block-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))

tests/Makefile.include check-block: $(patsubst %,check-%, $(check-block-y)) · line 942

Quoted 8 lines
tests/Makefile.include +2 -3
@@ -912,15 +938,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))

I think you should mention this in the patch description, too, that you're touching the "clean" target here.

Quoted 4 lines
tests/Makefile.include +0 -0
 clean: check-clean
 
 # Build the help program automatically
 
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

tests/Makefile.include check-block: $(patsubst %,check-%, $(check-block-y)) · line 951

Quoted 5 lines
tests/Makefile.include +3 -0
 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)")

Please do not use SRC_PATH here. I'm doing out of tree builds, and I don't want that these are touching my source folder!

I dislike generating .gitignore almost as much as I dislike maintaining it, and I'm adamantly opposed to generating it into the source tree.

Let's step back and consider what the problem is.

The problem is that we choose to litter the source tree with haphazardly named build artifacts. "Doctor, it hurts when I do that!"

"Don't do that then" is the simplest and sanest solution. Either name the build artifacts so that a few simple patterns can safely catch them. Or stop doing in-tree builds. As a convenience for people who have in-tree builds in muscle memory, have ./configure create and configure a suitable build directory, and have a trivial Makefile in the source tree that redirects there. Name the default build directory bld, add bld* to .gitignore, done.

I've meant to propose such a patch since forever, but I somehow never get around to actually doing it.

Quoted 17 lines
Quoted 6 lines

I understand the feeling, I do also mostly out of tree build. However, I don't think it makes much sense to generate .gitignore in the build dir. It's git related, and in the git source dir, you have .git that is writable
already: it'd be odd that the git wortree/srcdir is read-only, and the point is to generate .gitignore. Not so true with tarballs though.

Quoted 6 lines

I wrote this patch inspired by how the
https://github.com/behdad/git.mk/blob/master/git.mk rules does it (it is uses by many GNOME projects and others with autoconf). The way it gets away with not touching the srcdir in non-git tree, is that the git.mk file is not shipped in distributed tarball. We could have a similar approach if necessary.

Shipping .gitignore in the tarball is not necessary; it's main benefit is for in-tree development.

Quoted 1 line
Quoted 8 lines
Quoted 2 lines

Another alternative, which I find much less appealing, is that qemu tree keeps shipping .gitignore, and we just add a manual rule to maintain it.

Keeping .gitignore in git, if it is generated, is a pain, because then we have to manually resync it every time it gets out of date (and we're already demonstrating that we forget to update .gitignore with new tests). This patch is only worthwhile if it reduces maintainer overhead, but not if it trades one task for another.

Keeping generated files in Git is almost always a bad idea.

Quoted 9 lines
Quoted 8 lines

You suggested using more test* *test etc wildcards. I think this is bad, I would rather have a precise .gitignore, and not ignore extra files that are not part of the build-system. I couldn't find a simple way to generate precise rules for intermediary files (like .o etc), but for end targets, this patch demonstrates it can be done quite easily.

Finally, there is this trend these days with meson to not even allow in-tree build, and thus no need for .gitignore..

Quoted 7 lines

Please don't go the direction of forbidding in-tree builds. While I am a BIG fan of VPATH builds, I'm also a big fan of in-tree builds (it's slightly faster to do a one-off in-tree build of a fresh git checkout than it is to set up yet another VPATH build directory). Projects that force one way or the other are annoying. I see no reason why we should not keep both approaches working, particularly if we have patchew or other automation that covers both styles.

I do: people regularly break the one they're not using right now. Even when Patchew catches these mistake, it's still a waste of developer time.

#5 lore raw
In reply to Marc-André Lureau
Quoted 7 lines · Marc-André Lureau

Hi

On Mon, Sep 4, 2017 at 12:21 PM Thomas Huth <[email protected] <mailto:[email protected]>> wrote:

    On 04.09.2017 11 <tel:04%2009%2020%2017%2011>:03, Marc-André Lureau
    wrote:

[...]

Quoted 10 lines
Quoted 6 lines

  # 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)")

Quoted 5 lines

Please do not use SRC_PATH here. I'm doing out of tree builds, and I don't want that these are touching my source folder!

I understand the feeling, I do also mostly out of tree build. However, I don't think it makes much sense to generate .gitignore in the build dir.

Why not? If you're doing out-of-tree builds, you don't need the .gitignore in the source directory anyway, so it certainly does not make sense to generate there such a file in the source directory.

Quoted 2 lines

It's git related, and in the git source dir, you have .git that is writable already

It's unlikely, but I think it is perfectly legal to have your git source directory e.g. mounted temporarily as a read-only file system. I'd then still expect to be able to use my read-only sources to build QEMU out of tree.

Thomas

PS: Looks like you're sending HTML mails ... please check the setup of your mail program.

#6 lore raw
In reply to Marc-André Lureau
Quoted 2 lines · Marc-André Lureau

tests/.gitignore is often out of date. Let's generate it based on the files and directories to clean.

In fact, it got out-of-date again with the recent cbb6540.

Quoted 16 lines

Note: I didn't succeed yet at generalizing this approach for the rest of qemu .gitignore files, but I hope it may eventually happen.

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

Makefile ifneq ($(wildcard config-host.mak),) · line 20

Quoted 7 lines
Makefile +4 -0
@@ -14,6 +14,11 @@ ifneq ($(wildcard config-host.mak),)
 all:
 include config-host.mak
 
+.PHONY: gitignore
+ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
+all $(MAKECMDGOALS): gitignore
+endif

As others have mentioned, can we make this conditional on being an in-tree build, so that a VPATH build isn't modifying non-local files (after all, .gitignore only matters for an in-tree build)?

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org