Skip to contentSkip to conversation

Makefile: simplify qapi-py definition with wildcard

PATCH In review Wei Yang 3 participants 7 messages May 21, 2019 – May 22, 2019 Kbuild

lore
Share & tools
lore

Wei Yang

author
#0 lore raw

PATCH 1/1 Makefile: simplify qapi-py definition with wildcard

All the python script in scripts/qapi is used to generate qapi code. Use wildcard to simplify it.

---
 Makefile | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
Makefile +1 -7
index 155f066a20..38b74782d9 100644
@@ -541,13 +541,7 @@ qemu-ga$(EXESUF): QEMU_CFLAGS += -I qga/qapi-generated
 qemu-keymap$(EXESUF): LIBS += $(XKBCOMMON_LIBS)
 qemu-keymap$(EXESUF): QEMU_CFLAGS += $(XKBCOMMON_CFLAGS)
 
-qapi-py = $(SRC_PATH)/scripts/qapi/commands.py \
-$(SRC_PATH)/scripts/qapi/events.py \
-$(SRC_PATH)/scripts/qapi/introspect.py \
-$(SRC_PATH)/scripts/qapi/types.py \
-$(SRC_PATH)/scripts/qapi/visit.py \
-$(SRC_PATH)/scripts/qapi/common.py \
-$(SRC_PATH)/scripts/qapi/doc.py \
+qapi-py = $(wildcard $(SRC_PATH)/scripts/qapi/*.py) \
 $(SRC_PATH)/scripts/qapi-gen.py
 
 qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h \
Signature · 1 line
2.19.1
#1 lore raw
Quoted 7 lines · Wei Yang

All the python script in scripts/qapi is used to generate qapi code. Use wildcard to simplify it.

---
 Makefile | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

I'm not a fan of $(wildcard). It makes your tarball creation non-deterministic - if there is a leftover file from development that is no longer part of the build, wildcard will still pick it up. Explicit lists are better. I'm inclined to NACK this, but Markus has final say since he maintains the qapi generator.

Quoted 21 lines
Makefile +1 -7
index 155f066a20..38b74782d9 100644
@@ -541,13 +541,7 @@ qemu-ga$(EXESUF): QEMU_CFLAGS += -I qga/qapi-generated
 qemu-keymap$(EXESUF): LIBS += $(XKBCOMMON_LIBS)
 qemu-keymap$(EXESUF): QEMU_CFLAGS += $(XKBCOMMON_CFLAGS)
 
-qapi-py = $(SRC_PATH)/scripts/qapi/commands.py \
-$(SRC_PATH)/scripts/qapi/events.py \
-$(SRC_PATH)/scripts/qapi/introspect.py \
-$(SRC_PATH)/scripts/qapi/types.py \
-$(SRC_PATH)/scripts/qapi/visit.py \
-$(SRC_PATH)/scripts/qapi/common.py \
-$(SRC_PATH)/scripts/qapi/doc.py \
+qapi-py = $(wildcard $(SRC_PATH)/scripts/qapi/*.py) \
 $(SRC_PATH)/scripts/qapi-gen.py
 
 qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h \
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#2 lore raw
Quoted 4 lines · Eric Blake
Quoted 3 lines · Wei Yang

All the python script in scripts/qapi is used to generate qapi code. Use wildcard to simplify it.

Quoted 8 lines
Quoted 4 lines
---
 Makefile | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

I'm not a fan of $(wildcard). It makes your tarball creation non-deterministic - if there is a leftover file from development that is no longer part of the build, wildcard will still pick it up. Explicit

Actually, in this case can "only" adds spurious prerequisites.

Quoted 2 lines

lists are better. I'm inclined to NACK this, but Markus has final say since he maintains the qapi generator.

I consider use of $(wildcard) for the purpose of collecting sources a lazy mistake.

author
#3 lore raw
Quoted 11 lines · Markus Armbruster
Quoted 9 lines · Eric Blake
Quoted 7 lines · Wei Yang

All the python script in scripts/qapi is used to generate qapi code. Use wildcard to simplify it.

---
 Makefile | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
Quoted 5 lines
Quoted 3 lines

I'm not a fan of $(wildcard). It makes your tarball creation non-deterministic - if there is a leftover file from development that is no longer part of the build, wildcard will still pick it up. Explicit

Actually, in this case can "only" adds spurious prerequisites.

Hmm... which spurious prerequisites will be added? I may miss something here.

Quoted 6 lines
Quoted 3 lines

lists are better. I'm inclined to NACK this, but Markus has final say since he maintains the qapi generator.

I consider use of $(wildcard) for the purpose of collecting sources a lazy mistake.

Signature · 2 lines
Wei Yang
Help you, Help me
#4 lore raw
Quoted 12 lines · Wei Yang
Quoted 11 lines · Markus Armbruster
Quoted 9 lines · Eric Blake
Quoted 7 lines · Wei Yang

All the python script in scripts/qapi is used to generate qapi code. Use wildcard to simplify it.

---
 Makefile | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

I'm not a fan of $(wildcard). It makes your tarball creation non-deterministic - if there is a leftover file from development that is no longer part of the build, wildcard will still pick it up. Explicit

Actually, in this case can "only" adds spurious prerequisites.

Hmm... which spurious prerequisites will be added? I may miss something here.

If I touch the file scripts/qapi/foo.py, then that becomes a prerequisite, and will rebuild my files even though it doesn't need to. And if the definition of $(qapi-py) is ever applied to determining which files to include in a tarball, then my tarball will include foo.py, even though it is not essential to the tarball, while the next person, who does not have foo.py lying around in their directory, produces a different tarball. Non-deterministic results are bad, hence our rule of thumb to avoid $(wildcard) when listing files in a Makefile.

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

lists are better. I'm inclined to NACK this, but Markus has final say since he maintains the qapi generator.

I consider use of $(wildcard) for the purpose of collecting sources a lazy mistake.

Which is another polite way of saying that this patch should not be applied.

If you WANT to factor things for less typing, you could use something like:

var=commands.py events.py introspect.py types.py visit.py common.py doc.py $(addprefix $(SRC_PATH)/scripts/qapi/,$(var))

for some suitably-named var. Or even factor out the .py suffix as well. That doesn't use the problematic $(wildcard), but still lets you get away with easier maintenance of adding a new file to the explicit list should we add a file in the future.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
author
#5 lore raw
Quoted 21 lines · Eric Blake
Quoted 12 lines · Wei Yang
Quoted 11 lines · Markus Armbruster
Quoted 9 lines · Eric Blake
Quoted 7 lines · Wei Yang

All the python script in scripts/qapi is used to generate qapi code. Use wildcard to simplify it.

---
 Makefile | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

I'm not a fan of $(wildcard). It makes your tarball creation non-deterministic - if there is a leftover file from development that is no longer part of the build, wildcard will still pick it up. Explicit

Actually, in this case can "only" adds spurious prerequisites.

Hmm... which spurious prerequisites will be added? I may miss something here.

Quoted 9 lines

If I touch the file scripts/qapi/foo.py, then that becomes a prerequisite, and will rebuild my files even though it doesn't need to. And if the definition of $(qapi-py) is ever applied to determining which files to include in a tarball, then my tarball will include foo.py, even though it is not essential to the tarball, while the next person, who does not have foo.py lying around in their directory, produces a different tarball. Non-deterministic results are bad, hence our rule of thumb to avoid $(wildcard) when listing files in a Makefile.

Ok, so $(wildcard) should be avoided in Makefile. Will not try to do this next time.

Quoted 25 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

lists are better. I'm inclined to NACK this, but Markus has final say since he maintains the qapi generator.

I consider use of $(wildcard) for the purpose of collecting sources a lazy mistake.

Which is another polite way of saying that this patch should not be applied.

If you WANT to factor things for less typing, you could use something like:

var=commands.py events.py introspect.py types.py visit.py common.py doc.py $(addprefix $(SRC_PATH)/scripts/qapi/,$(var))

for some suitably-named var. Or even factor out the .py suffix as well. That doesn't use the problematic $(wildcard), but still lets you get away with easier maintenance of adding a new file to the explicit list should we add a file in the future.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
Signature · 2 lines
Wei Yang
Help you, Help me
author
#6 lore raw
In reply to Eric Blake
Quoted 9 lines · Eric Blake
Quoted 7 lines · Wei Yang

All the python script in scripts/qapi is used to generate qapi code. Use wildcard to simplify it.

---
 Makefile | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
Quoted 6 lines

I'm not a fan of $(wildcard). It makes your tarball creation non-deterministic - if there is a leftover file from development that is no longer part of the build, wildcard will still pick it up. Explicit lists are better. I'm inclined to NACK this, but Markus has final say since he maintains the qapi generator.

Thanks for comment.

Yes, for tarball, the order is a problem. But those python scripts are not used in tarballs.

For leftover files, you mean those files not used and should be deleted?

Signature · 2 lines
Wei Yang
Help you, Help me