From: Markus Armbruster <armbru@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com
Subject: Re: [PATCH 7/6] Makefile: Make Makefile depend on generated qga files, too
Date: Wed, 04 Dec 2019 14:19:14 +0100 [thread overview]
Message-ID: <87blso9qjx.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <42dbda81-f1a0-bb15-cee6-3040f41f38ef@redhat.com> (Eric Blake's message of "Wed, 4 Dec 2019 06:58:16 -0600")
Eric Blake <eblake@redhat.com> writes:
> 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.
Trust me, you're either sure you want "=", or you want ":=".
On a green field, I recommend a hard rule "no = without a comment
explaining why".
>> 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.
Either way, we use multiple assignments to build GENERATED_QGA_FILES.
The only difference is that the version using two variables would also
work with recursive expansion, due to the magic of +=.
next prev parent reply other threads:[~2019-12-04 13:20 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-20 18:25 [PATCH 0/6] qapi: Module fixes and cleanups Markus Armbruster
2019-11-20 18:25 ` [PATCH 1/6] qapi: Tweak "command returns a nice type" check for clarity Markus Armbruster
2019-11-20 19:08 ` Eric Blake
2019-11-20 18:25 ` [PATCH 2/6] tests/Makefile.include: Fix missing test-qapi-emit-events.[ch] Markus Armbruster
2019-11-20 19:16 ` Eric Blake
2019-11-20 18:25 ` [PATCH 3/6] qapi: Generate command registration stuff into separate files Markus Armbruster
2019-11-20 19:26 ` Eric Blake
2019-11-27 16:12 ` Markus Armbruster
2019-11-20 18:25 ` [PATCH 4/6] qapi: Proper intermediate representation for modules Markus Armbruster
2019-11-20 20:31 ` Eric Blake
2019-11-20 18:25 ` [PATCH 5/6] qapi: Fix code generation for empty modules Markus Armbruster
2019-11-20 20:35 ` Eric Blake
2019-11-20 18:25 ` [PATCH 6/6] qapi: Simplify QAPISchemaModularCVisitor Markus Armbruster
2019-11-20 20:54 ` Eric Blake
2019-11-20 19:40 ` [PATCH 0/6] qapi: Module fixes and cleanups Markus Armbruster
2019-11-20 23:58 ` no-reply
2019-11-21 6:27 ` Markus Armbruster
2019-11-29 9:59 ` [PATCH 7/6] Makefile: Make Makefile depend on generated qga files, too Markus Armbruster
2019-12-03 22:33 ` Eric Blake
2019-12-04 6:56 ` Markus Armbruster
2019-12-04 12:58 ` Eric Blake
2019-12-04 13:19 ` Markus Armbruster [this message]
2019-12-03 9:01 ` [PATCH 0/6] qapi: Module fixes and cleanups Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87blso9qjx.fsf@dusky.pond.sub.org \
--to=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).