On 27/09/21 11:54, Peter Maydell wrote:
True, but "meson.build is evaluated but just does nothing or
adds files to a sourceset that isn't used" is pretty common
(hw/pci/meson.build is evaluated even if we're not building
a system with PCI support, for example).
Selection of files from hw/pci/meson.build is based on per-target
definitions, so there's no way around when:/if_true:. (Technically,
hw/pci/meson.build also as an if_false, so there's *really* no way
around parsing it).
Instead, when the definition is constant across all targets, it is
possible to use either when:/if_true: or an "if" as in
if have_user
util_ss.add(files('selfmap.c'))
endif
or the various "if m[0].found()" found in directories that build shared
modules. In this case I personally lean more towards the latter, but
when:/if_true: is a little more compact so both are acceptable.
Paolo