qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: marcandre.lureau@redhat.com
Cc: qemu-devel@nongnu.org, "Daniel P. Berrangé" <berrange@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Ed Maste" <emaste@freebsd.org>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Cornelia Huck" <cohuck@redhat.com>,
	"Eric Farman" <farman@linux.ibm.com>,
	"John Snow" <jsnow@redhat.com>,
	"Halil Pasic" <pasic@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Thomas Huth" <thuth@redhat.com>,
	"Cleber Rosa" <crosa@redhat.com>,
	"Beraldo Leal" <bleal@redhat.com>,
	"Li-Wen Hsu" <lwhsu@freebsd.org>,
	"David Hildenbrand" <david@redhat.com>,
	kraxel@redhat.com,
	"Richard Henderson" <richard.henderson@linaro.org>,
	qemu-s390x@nongnu.org,
	"Wainer dos Santos Moschetta" <wainersm@redhat.com>,
	"Michael Roth" <michael.roth@amd.com>
Subject: Re: [PATCH v2 4/5] meson: replace Perl usage with Python
Date: Mon, 9 Jan 2023 18:51:49 +0000	[thread overview]
Message-ID: <CAFEAcA_YHvJWJMwxSQAQRphCgDNOSf2arbqMY8_T7VCByXCVsA@mail.gmail.com> (raw)
In-Reply-To: <20230109181447.235989-5-marcandre.lureau@redhat.com>

On Mon, 9 Jan 2023 at 18:16, <marcandre.lureau@redhat.com> wrote:
>
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Let's try to remove Perl usage during build time.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  tests/qapi-schema/meson.build | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/tests/qapi-schema/meson.build b/tests/qapi-schema/meson.build
> index 9dfe98bc9a..d85b14f28c 100644
> --- a/tests/qapi-schema/meson.build
> +++ b/tests/qapi-schema/meson.build
> @@ -259,22 +259,23 @@ if build_docs
>    # Fix possible inconsistency in line endings in generated output and
>    # in the golden reference (which could otherwise cause test failures
>    # on Windows hosts). Unfortunately diff --strip-trailing-cr
> -  # is GNU-diff only. The odd-looking perl is because we must avoid
> +  # is GNU-diff only. The odd-looking python is because we must avoid
>    # using an explicit '\' character in the command arguments to
>    # a custom_target(), as Meson will unhelpfully replace it with a '/'
>    # (https://github.com/mesonbuild/meson/issues/1564)

This comment is not applicable to your Python rewrite of this.
It's talking about the way that the Perl code has to create
a variable with a '\r' value in a weird way (using "$x = chr 13")
and then do a substitution using that variable, rather than the obvious
direct s// command ("s/\r//"), to work around a meson bug if the code
has a literal \ character in it. Your python has no '\'s in it.

> +  remove_cr = [python, '-c', 'import sys;[sys.stdout.write(line.replace(chr(13), "")) for line in sys.stdin]']
>    qapi_doc_out_nocr = custom_target('QAPI rST doc newline-sanitized',
>                                      output: ['doc-good.txt.nocr'],
>                                      input: qapi_doc_out[0],
>                                      build_by_default: true,
> -                                    command: ['perl', '-pe', '$x = chr 13; s/$x$//', '@INPUT@'],
> +                                    command: [remove_cr, '@INPUT@'],
>                                      capture: true)
>
>    qapi_doc_ref_nocr = custom_target('QAPI rST doc reference newline-sanitized',
>                                      output: ['doc-good.ref.nocr'],
>                                      input: files('doc-good.txt'),
>                                      build_by_default: true,
> -                                    command: ['perl', '-pe', '$x = chr 13; s/$x$//', '@INPUT@'],
> +                                    command: [remove_cr, '@INPUT@'],
>                                      capture: true)
>
>    test('QAPI rST doc', diff, args: ['-u', qapi_doc_ref_nocr[0], qapi_doc_out_nocr[0]],
> --
> 2.39.0

Maybe we should consider putting the Python into a script in
scripts/ ? "Remove \r characters" is pretty trivial, but on the
other hand I think this is the only Meson custom_target() we
have where we directly invoke a script interpreter with a
bit of inline script, and inline bits of script doesn't really
seem to be a style Meson encourages (unlike Make).

thanks
-- PMM


  reply	other threads:[~2023-01-09 18:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-09 18:14 [PATCH v2 0/5] Fix win32/msys2 shader compilation & drop perl marcandre.lureau
2023-01-09 18:14 ` [PATCH v2 1/5] build-sys: fix crlf-ending C code marcandre.lureau
2023-01-09 19:02   ` John Snow
2023-01-09 18:14 ` [PATCH v2 2/5] .gitlab-ci.d/windows: do not disable opengl marcandre.lureau
2023-01-09 18:14 ` [PATCH v2 3/5] configure: replace Perl usage with sed marcandre.lureau
2023-01-09 18:42   ` Peter Maydell
2023-01-09 18:14 ` [PATCH v2 4/5] meson: replace Perl usage with Python marcandre.lureau
2023-01-09 18:51   ` Peter Maydell [this message]
2023-01-09 18:55     ` Marc-André Lureau
2023-01-09 18:14 ` [PATCH v2 5/5] Draft: Update lcitool marcandre.lureau
2023-01-09 18:27   ` Daniel P. Berrangé
2023-01-09 18:30     ` Marc-André Lureau
2023-01-09 18:42       ` Daniel P. Berrangé

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=CAFEAcA_YHvJWJMwxSQAQRphCgDNOSf2arbqMY8_T7VCByXCVsA@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=bleal@redhat.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=crosa@redhat.com \
    --cc=david@redhat.com \
    --cc=emaste@freebsd.org \
    --cc=farman@linux.ibm.com \
    --cc=jsnow@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=lwhsu@freebsd.org \
    --cc=marcandre.lureau@redhat.com \
    --cc=michael.roth@amd.com \
    --cc=pasic@linux.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=thuth@redhat.com \
    --cc=wainersm@redhat.com \
    /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).