[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 7/6] Makefile: Make Makefile depend on generated qga files, t
From: |
Eric Blake |
Subject: |
Re: [PATCH 7/6] Makefile: Make Makefile depend on generated qga files, too |
Date: |
Wed, 4 Dec 2019 06:58:16 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 |
On 12/4/19 12:56 AM, Markus Armbruster wrote:
+++ b/Makefile
@@ -130,6 +130,15 @@ GENERATED_QAPI_FILES += qapi/qapi-doc.texi
generated-files-y += $(GENERATED_QAPI_FILES)
+GENERATED_QGA_FILES := qga-qapi-types.c qga-qapi-types.h
+GENERATED_QGA_FILES += qga-qapi-visit.c qga-qapi-visit.h
+GENERATED_QGA_FILES += qga-qapi-commands.h qga-qapi-commands.c
+GENERATED_QGA_FILES += qga-qapi-init-commands.h qga-qapi-init-commands.c
+GENERATED_QGA_FILES += qga-qapi-doc.texi
+GENERATED_QGA_FILES := $(addprefix qga/qapi-generated/, $(GENERATED_QGA_FILES))
Would it be worth using two separate variable names (maybe
GENERATED_QGA_BASEFILES for the first list) rather than exploiting the
arcane knowledge that consecutive use of := causes GNU make to rewrite
an existing variable with new contents?
Our rules.mak relies on this already. It's full of magic, which
admittedly diminishes its suitability to serve as a good example.
Your worry might be rooted in old "=" burns. "=" makes the variable
recursively expanded, and
GENERATED_QGA_FILES = $(addprefix qga/qapi-generated/,
$(GENERATED_QGA_FILES))
Indeed, but I have to refer to the manual to remind myself of whether =
or := is what I want in a given situation.
would be an infinite loop. ":=" makes it simply expanded; there's not
even a loop, let alone an infinite one. The GNU Make manual explains
this clearly at
https://www.gnu.org/software/make/manual/html_node/Flavors.html
Aside: there's a reason one of the two flavors is called "simple". It
could additionally be called "not as slow". One of my pet makefile
peeves: unthinking use of recursively expanded variables, complicating
semantics and slowing down builds.
Back to this patch. I had started to write the thing in longhand, but
got tired of repeating qga/qapi-generated/, so I factored that out.
Would longhand be easier to understand?
It's more verbose. My suggestion was more:
GENERATED_QGA_BASENAMES := qga-qapi-types.c qga-qapi-types.h
GENERATED_QGA_BASENAMES += qga-qapi-visit.c qga-qapi-visit.h
...
GENERATED_QGA_FILES := $(addprefix qga/qapi-generated/,
$(GENERATED_QGA_BASENAMES))
to avoid the reassignment-to-self issue altogether, while still
remaining concise compared to longhand.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org