From: Paolo Bonzini <pbonzini@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [PATCH] meson.build: Don't look for libudev for static builds
Date: Fri, 2 Oct 2020 17:14:39 +0200 [thread overview]
Message-ID: <a1ef11fc-7652-056e-bfcc-db0f8fcfc13f@redhat.com> (raw)
In-Reply-To: <CAFEAcA9vr+HKe3HnNECo8=pP7KcdjZXr1cJqg8HTbYKbaNDY3A@mail.gmail.com>
On 02/10/20 16:18, Peter Maydell wrote:
>> No, there's no functions at all. You can of course put the detection and
>> test in a single loop:
>>
>> dependencies = {}
>> ...
>> if targetos == 'linux' and (have_system or have_tools)
>> dependencies += {'libudev': 'mpath'}
>> endif
>> ...
>> skeleton = 'int main(void) { return 0; }'
>> foreach var, option: dependencies
>> dep = dependency(var,
>> required: get_option(option).enabled(),
>> static: enable_static)
>> if dep.found() and enable_static and not cc.links(skeleton, dependencies: get_variable(var))
>> if get_option(option).enabled()
>> error('Cannot link with @0@'.format(var))
>> else
>> warning('Cannot link with @0@, disabling'.format(skeleton))
>> set_variable(var, not_found)
>> endif
>> endif
>> endif
>> endforeach
> That is a lot uglier.
The code above is ugly but it is also botched; it should be more like:
dependencies = {}
...
if targetos == 'linux' and (have_system or have_tools)
dependencies += {'libudev': get_option('mpath')}
else
libudev = not_found
endif
...
skeleton = 'int main(void) { return 0; }'
foreach var, opt: dependencies
dep = dependency(var,
required: opt.enabled(),
static: enable_static)
if dep.found() and enable_static and not cc.links(skeleton, dependencies: dep)
# Meson should have already warned about the lack of a static library
if opt.enabled()
error('Cannot link with @0@'.format(var))
else
dep = not_found
endif
set_variable(var, dep)
endforeach
which both shorter and more readable.
Or is it loops vs. functions that you find ugly?
Paolo
next prev parent reply other threads:[~2020-10-02 15:28 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-02 10:52 [PATCH] meson.build: Don't look for libudev for static builds Peter Maydell
2020-10-02 11:15 ` 罗勇刚(Yonggang Luo)
2020-10-02 12:03 ` Paolo Bonzini
2020-10-02 12:02 ` Paolo Bonzini
2020-10-02 12:35 ` Peter Maydell
2020-10-02 12:36 ` Peter Maydell
2020-10-02 12:43 ` Paolo Bonzini
2020-10-02 13:01 ` Peter Maydell
2020-10-02 13:05 ` Paolo Bonzini
2020-10-02 13:09 ` Peter Maydell
2020-10-02 14:08 ` Paolo Bonzini
2020-10-02 14:18 ` Peter Maydell
2020-10-02 15:14 ` Paolo Bonzini [this message]
2020-10-02 15:28 ` Peter Maydell
2020-10-03 7:24 ` 罗勇刚(Yonggang Luo)
2020-10-03 7:50 ` Paolo Bonzini
2020-10-03 8:28 ` 罗勇刚(Yonggang Luo)
2020-10-03 8:42 ` Paolo Bonzini
2020-10-03 8:29 ` 罗勇刚(Yonggang Luo)
2020-10-03 8:43 ` Paolo Bonzini
2020-10-03 9:32 ` 罗勇刚(Yonggang Luo)
2020-10-12 15:33 [PATCH 00/10] target/arm: Various v8.1M minor features Peter Maydell
2020-10-12 15:33 ` [PATCH] meson.build: Don't look for libudev for static builds Peter Maydell
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=a1ef11fc-7652-056e-bfcc-db0f8fcfc13f@redhat.com \
--to=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.