diff mbox series

[v2,1/4] docs: Fixes build docs on msys2/mingw

Message ID 20201015201035.1964-2-luoyonggang@gmail.com
State Superseded
Headers show
Series Fixes docs building on msys2/mingw | expand

Commit Message

罗勇刚(Yonggang Luo) Oct. 15, 2020, 8:10 p.m. UTC
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 docs/conf.py                  |  2 +-
 docs/sphinx/kerneldoc.py      |  2 +-
 scripts/rst-sanitize.py       | 21 +++++++++++++++++++++
 tests/qapi-schema/meson.build |  5 +++--
 4 files changed, 26 insertions(+), 4 deletions(-)
 create mode 100644 scripts/rst-sanitize.py

Comments

Peter Maydell Oct. 15, 2020, 8:30 p.m. UTC | #1
On Thu, 15 Oct 2020 at 21:13, Yonggang Luo <luoyonggang@gmail.com> wrote:
>

> Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>

> ---

>  docs/conf.py                  |  2 +-

>  docs/sphinx/kerneldoc.py      |  2 +-

>  scripts/rst-sanitize.py       | 21 +++++++++++++++++++++

>  tests/qapi-schema/meson.build |  5 +++--

>  4 files changed, 26 insertions(+), 4 deletions(-)

>  create mode 100644 scripts/rst-sanitize.py

>

> diff --git a/scripts/rst-sanitize.py b/scripts/rst-sanitize.py

> new file mode 100644

> index 0000000000..26060f1208

> --- /dev/null

> +++ b/scripts/rst-sanitize.py

> @@ -0,0 +1,21 @@

> +#!/usr/bin/env python3

> +

> +#

> +# Script for remove cr line ending in file

> +#

> +# Authors:

> +#  Yonggang Luo <luoyonggang@gmail.com>

> +#

> +# This work is licensed under the terms of the GNU GPL, version 2

> +# or, at your option, any later version.  See the COPYING file in

> +# the top-level directory.

> +

> +import sys

> +

> +def main(_program, file, *unused):

> +    with open(file, 'rb') as content_file:

> +        content = content_file.read()

> +        sys.stdout.buffer.write(content.replace(b'\r', b''))

> +

> +if __name__ == "__main__":

> +    main(*sys.argv)


Why doesn't the perl rune work? Your commit message doesn't say.

> diff --git a/tests/qapi-schema/meson.build b/tests/qapi-schema/meson.build

> index 1f222a7a13..20a7641af8 100644

> --- a/tests/qapi-schema/meson.build

> +++ b/tests/qapi-schema/meson.build

> @@ -251,18 +251,19 @@ qapi_doc_out = custom_target('QAPI rST doc',

>  # 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)

> +rst_sanitize_cmd = [find_program('../../scripts/rst-sanitize.py'), '@INPUT@']

>  qapi_doc_out_nocr = custom_target('QAPI rST doc newline-sanitized',

>                                    output: ['doc-good.txt.nocr'],

>                                    input: qapi_doc_out[0],

>                                    build_by_default: build_docs,

> -                                  command: ['perl', '-pe', '$x = chr 13; s/$x$//', '@INPUT@'],

> +                                  command: rst_sanitize_cmd,

>                                    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: build_docs,

> -                                  command: ['perl', '-pe', '$x = chr 13; s/$x$//', '@INPUT@'],

> +                                  command: rst_sanitize_cmd,

>                                    capture: true)


thanks
-- PMM
罗勇刚(Yonggang Luo) Oct. 15, 2020, 8:38 p.m. UTC | #2
On Fri, Oct 16, 2020 at 4:30 AM Peter Maydell <peter.maydell@linaro.org>
wrote:
>

> On Thu, 15 Oct 2020 at 21:13, Yonggang Luo <luoyonggang@gmail.com> wrote:

> >

> > Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>

> > ---

> >  docs/conf.py                  |  2 +-

> >  docs/sphinx/kerneldoc.py      |  2 +-

> >  scripts/rst-sanitize.py       | 21 +++++++++++++++++++++

> >  tests/qapi-schema/meson.build |  5 +++--

> >  4 files changed, 26 insertions(+), 4 deletions(-)

> >  create mode 100644 scripts/rst-sanitize.py

> >

> > diff --git a/scripts/rst-sanitize.py b/scripts/rst-sanitize.py

> > new file mode 100644

> > index 0000000000..26060f1208

> > --- /dev/null

> > +++ b/scripts/rst-sanitize.py

> > @@ -0,0 +1,21 @@

> > +#!/usr/bin/env python3

> > +

> > +#

> > +# Script for remove cr line ending in file

> > +#

> > +# Authors:

> > +#  Yonggang Luo <luoyonggang@gmail.com>

> > +#

> > +# This work is licensed under the terms of the GNU GPL, version 2

> > +# or, at your option, any later version.  See the COPYING file in

> > +# the top-level directory.

> > +

> > +import sys

> > +

> > +def main(_program, file, *unused):

> > +    with open(file, 'rb') as content_file:

> > +        content = content_file.read()

> > +        sys.stdout.buffer.write(content.replace(b'\r', b''))

> > +

> > +if __name__ == "__main__":

> > +    main(*sys.argv)

>

> Why doesn't the perl rune work? Your commit message doesn't say.



PASS 3 test-qdev-global-props /qdev/properties/dynamic/global
PASS 4 test-qdev-global-props /qdev/properties/global/subclass
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}
 ../../../../../CI-Tools/msys64/usr/bin/sh.EXE
C:/work/xemu/qemu/build/../tests/decode/check.sh python3 -B
C:/work/xemu/qemu/build/../tests/../scripts/decodetree.py
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}
PYTHONPATH=C:/work/xemu/qemu/scripts PYTHONIOENCODING=utf-8
../../../../CI-Tools/msys64/mingw64/bin/python3.exe
C:/work/xemu/qemu/build/../tests/qapi-schema/test-qapi.py
C:/work/xemu/qemu/build/../tests/qapi-schema/alternate-any.json
C:/work/xemu/qemu/build/../tests/qapi-schema/alternate-array.json
C:/work/xemu/qemu/build/../tests/qapi-schema/alternate-base.json
C:/work/xemu/qemu/build/../tests/qapi-schema/alternate-branch-if-invalid.json
C:/work/xemu/qemu/build/../tests/qapi-schema/alternate-clash.json
C:/work/xemu/qemu/build/../tests/qapi-schema/alternate-conflict-dict.json
C:/work/xemu/qemu/build/../tests/qapi-schema/alternate-conflict-enum-bool.json
C:/work/xemu/qemu/build/../tests/qapi-schema/alternate-conflict-enum-int.json
C:/work/xemu/qemu/build/../tests/qapi-schema/alternate-conflict-string.json
C:/work/xemu/qemu/build/../tests/qapi-schema/alternate-conflict-bool-string.json
C:/work/xemu/qemu/build/../tests/qapi-schema/alternate-conflict-num-string.json
C:/work/xemu/qemu/build/../tests/qapi-schema/alternate-empty.json
C:/work/xemu/qemu/build/../tests/qapi-schema/alternate-invalid-dict.json
C:/work/xemu/qemu/build/../tests/qapi-schema/alternate-nested.json
C:/work/xemu/qemu/build/../tests/qapi-schema/alternate-unknown.json
C:/work/xemu/qemu/build/../tests/qapi-schema/args-alternate.json
C:/work/xemu/qemu/build/../tests/qapi-schema/args-any.json
C:/work/xemu/qemu/build/../tests/qapi-schema/args-array-empty.json
C:/work/xemu/qemu/build/../tests/qapi-schema/args-array-unknown.json
C:/work/xemu/qemu/build/../tests/qapi-schema/args-bad-boxed.json
C:/work/xemu/qemu/build/../tests/qapi-schema/args-boxed-anon.json
C:/work/xemu/qemu/build/../tests/qapi-schema/args-boxed-string.json
C:/work/xemu/qemu/build/../tests/qapi-schema/args-int.json
C:/work/xemu/qemu/build/../tests/qapi-schema/args-invalid.json
C:/work/xemu/qemu/build/../tests/qapi-schema/args-member-array-bad.json
C:/work/xemu/qemu/build/../tests/qapi-schema/args-member-case.json
C:/work/xemu/qemu/build/../tests/qapi-schema/args-member-unknown.json
C:/work/xemu/qemu/build/../tests/qapi-schema/args-name-clash.json
C:/work/xemu/qemu/build/../tests/qapi-schema/args-union.json
C:/work/xemu/qemu/build/../tests/qapi-schema/args-unknown.json
C:/work/xemu/qemu/build/../tests/qapi-schema/bad-base.json
C:/work/xemu/qemu/build/../tests/qapi-schema/bad-data.json
C:/work/xemu/qemu/build/../tests/qapi-schema/bad-ident.json
C:/work/xemu/qemu/build/../tests/qapi-schema/bad-if.json
C:/work/xemu/qemu/build/../tests/qapi-schema/bad-if-empty.json
C:/work/xemu/qemu/build/../tests/qapi-schema/bad-if-empty-list.json
C:/work/xemu/qemu/build/../tests/qapi-schema/bad-if-list.json
C:/work/xemu/qemu/build/../tests/qapi-schema/bad-type-bool.json
C:/work/xemu/qemu/build/../tests/qapi-schema/bad-type-dict.json
C:/work/xemu/qemu/build/../tests/qapi-schema/bad-type-int.json
C:/work/xemu/qemu/build/../tests/qapi-schema/base-cycle-direct.json
C:/work/xemu/qemu/build/../tests/qapi-schema/base-cycle-indirect.json
C:/work/xemu/qemu/build/../tests/qapi-schema/command-int.json
C:/work/xemu/qemu/build/../tests/qapi-schema/comments.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-bad-alternate-member.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-bad-boxed-command-arg.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-bad-command-arg.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-bad-enum-member.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-bad-event-arg.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-bad-feature.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-bad-indent.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-bad-section.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-bad-symbol.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-bad-union-member.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-before-include.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-before-pragma.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-duplicated-arg.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-duplicated-return.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-duplicated-since.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-empty-arg.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-empty-section.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-empty-symbol.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-good.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-interleaved-section.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-invalid-end.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-invalid-end2.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-invalid-return.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-invalid-section.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-invalid-start.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-missing-colon.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-missing-expr.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-missing-space.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-missing.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-no-symbol.json
C:/work/xemu/qemu/build/../tests/qapi-schema/doc-undoc-feature.json
C:/work/xemu/qemu/build/../tests/qapi-schema/double-type.json
C:/work/xemu/qemu/build/../tests/qapi-schema/duplicate-key.json
C:/work/xemu/qemu/build/../tests/qapi-schema/empty.json
C:/work/xemu/qemu/build/../tests/qapi-schema/enum-bad-member.json
C:/work/xemu/qemu/build/../tests/qapi-schema/enum-bad-name.json
C:/work/xemu/qemu/build/../tests/qapi-schema/enum-bad-prefix.json
C:/work/xemu/qemu/build/../tests/qapi-schema/enum-clash-member.json
C:/work/xemu/qemu/build/../tests/qapi-schema/enum-dict-member-unknown.json
C:/work/xemu/qemu/build/../tests/qapi-schema/enum-if-invalid.json
C:/work/xemu/qemu/build/../tests/qapi-schema/enum-int-member.json
C:/work/xemu/qemu/build/../tests/qapi-schema/enum-member-case.json
C:/work/xemu/qemu/build/../tests/qapi-schema/enum-missing-data.json
C:/work/xemu/qemu/build/../tests/qapi-schema/enum-wrong-data.json
C:/work/xemu/qemu/build/../tests/qapi-schema/event-boxed-empty.json
C:/work/xemu/qemu/build/../tests/qapi-schema/event-case.json
C:/work/xemu/qemu/build/../tests/qapi-schema/event-member-invalid-dict.json
C:/work/xemu/qemu/build/../tests/qapi-schema/event-nest-struct.json
C:/work/xemu/qemu/build/../tests/qapi-schema/features-bad-type.json
C:/work/xemu/qemu/build/../tests/qapi-schema/features-deprecated-type.json
C:/work/xemu/qemu/build/../tests/qapi-schema/features-duplicate-name.json
C:/work/xemu/qemu/build/../tests/qapi-schema/features-if-invalid.json
C:/work/xemu/qemu/build/../tests/qapi-schema/features-missing-name.json
C:/work/xemu/qemu/build/../tests/qapi-schema/features-name-bad-type.json
C:/work/xemu/qemu/build/../tests/qapi-schema/features-no-list.json
C:/work/xemu/qemu/build/../tests/qapi-schema/features-unknown-key.json
C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-array-branch.json
C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-bad-base.json
C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-bad-discriminator.json
C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-base-any.json
C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-base-union.json
C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-clash-member.json
C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-discriminator-bad-name.json
C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-empty.json
C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-inline.json
C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-inline-invalid-dict.json
C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-int-branch.json
C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-invalid-branch-key.json
C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-invalid-discriminator.json
C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-invalid-if-discriminator.json
C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-no-base.json
C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-optional-discriminator.json
C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-string-discriminator.json
C:/work/xemu/qemu/build/../tests/qapi-schema/funny-char.json
C:/work/xemu/qemu/build/../tests/qapi-schema/funny-word.json
C:/work/xemu/qemu/build/../tests/qapi-schema/ident-with-escape.json
C:/work/xemu/qemu/build/../tests/qapi-schema/include-before-err.json
C:/work/xemu/qemu/build/../tests/qapi-schema/include-cycle.json
C:/work/xemu/qemu/build/../tests/qapi-schema/include-extra-junk.json
C:/work/xemu/qemu/build/../tests/qapi-schema/include-nested-err.json
C:/work/xemu/qemu/build/../tests/qapi-schema/include-no-file.json
C:/work/xemu/qemu/build/../tests/qapi-schema/include-non-file.json
C:/work/xemu/qemu/build/../tests/qapi-schema/include-repetition.json
C:/work/xemu/qemu/build/../tests/qapi-schema/include-self-cycle.json
C:/work/xemu/qemu/build/../tests/qapi-schema/include-simple.json
C:/work/xemu/qemu/build/../tests/qapi-schema/indented-expr.json
C:/work/xemu/qemu/build/../tests/qapi-schema/leading-comma-list.json
C:/work/xemu/qemu/build/../tests/qapi-schema/leading-comma-object.json
C:/work/xemu/qemu/build/../tests/qapi-schema/missing-colon.json
C:/work/xemu/qemu/build/../tests/qapi-schema/missing-comma-list.json
C:/work/xemu/qemu/build/../tests/qapi-schema/missing-comma-object.json
C:/work/xemu/qemu/build/../tests/qapi-schema/missing-type.json
C:/work/xemu/qemu/build/../tests/qapi-schema/nested-struct-data.json
C:/work/xemu/qemu/build/../tests/qapi-schema/nested-struct-data-invalid-dict.json
C:/work/xemu/qemu/build/../tests/qapi-schema/non-objects.json
C:/work/xemu/qemu/build/../tests/qapi-schema/oob-coroutine.json
C:/work/xemu/qemu/build/../tests/qapi-schema/oob-test.json
C:/work/xemu/qemu/build/../tests/qapi-schema/allow-preconfig-test.json
C:/work/xemu/qemu/build/../tests/qapi-schema/pragma-doc-required-crap.json
C:/work/xemu/qemu/build/../tests/qapi-schema/pragma-extra-junk.json
C:/work/xemu/qemu/build/../tests/qapi-schema/pragma-name-case-whitelist-crap.json
C:/work/xemu/qemu/build/../tests/qapi-schema/pragma-non-dict.json
C:/work/xemu/qemu/build/../tests/qapi-schema/pragma-unknown.json
C:/work/xemu/qemu/build/../tests/qapi-schema/pragma-returns-whitelist-crap.json
C:/work/xemu/qemu/build/../tests/qapi-schema/qapi-schema-test.json
C:/work/xemu/qemu/build/../tests/qapi-schema/quoted-structural-chars.json
C:/work/xemu/qemu/build/../tests/qapi-schema/redefined-builtin.json
C:/work/xemu/qemu/build/../tests/qapi-schema/redefined-command.json
C:/work/xemu/qemu/build/../tests/qapi-schema/redefined-event.json
C:/work/xemu/qemu/build/../tests/qapi-schema/redefined-type.json
C:/work/xemu/qemu/build/../tests/qapi-schema/reserved-command-q.json
C:/work/xemu/qemu/build/../tests/qapi-schema/reserved-enum-q.json
C:/work/xemu/qemu/build/../tests/qapi-schema/reserved-member-has.json
C:/work/xemu/qemu/build/../tests/qapi-schema/reserved-member-q.json
C:/work/xemu/qemu/build/../tests/qapi-schema/reserved-member-u.json
C:/work/xemu/qemu/build/../tests/qapi-schema/reserved-member-underscore.json
C:/work/xemu/qemu/build/../tests/qapi-schema/reserved-type-kind.json
C:/work/xemu/qemu/build/../tests/qapi-schema/reserved-type-list.json
C:/work/xemu/qemu/build/../tests/qapi-schema/returns-alternate.json
C:/work/xemu/qemu/build/../tests/qapi-schema/returns-array-bad.json
C:/work/xemu/qemu/build/../tests/qapi-schema/returns-dict.json
C:/work/xemu/qemu/build/../tests/qapi-schema/returns-unknown.json
C:/work/xemu/qemu/build/../tests/qapi-schema/returns-whitelist.json
C:/work/xemu/qemu/build/../tests/qapi-schema/string-code-point-31.json
C:/work/xemu/qemu/build/../tests/qapi-schema/string-code-point-127.json
C:/work/xemu/qemu/build/../tests/qapi-schema/struct-base-clash-deep.json
C:/work/xemu/qemu/build/../tests/qapi-schema/struct-base-clash.json
C:/work/xemu/qemu/build/../tests/qapi-schema/struct-data-invalid.json
C:/work/xemu/qemu/build/../tests/qapi-schema/struct-member-if-invalid.json
C:/work/xemu/qemu/build/../tests/qapi-schema/struct-member-invalid-dict.json
C:/work/xemu/qemu/build/../tests/qapi-schema/struct-member-invalid.json
C:/work/xemu/qemu/build/../tests/qapi-schema/trailing-comma-list.json
C:/work/xemu/qemu/build/../tests/qapi-schema/trailing-comma-object.json
C:/work/xemu/qemu/build/../tests/qapi-schema/type-bypass-bad-gen.json
C:/work/xemu/qemu/build/../tests/qapi-schema/unclosed-list.json
C:/work/xemu/qemu/build/../tests/qapi-schema/unclosed-object.json
C:/work/xemu/qemu/build/../tests/qapi-schema/unclosed-string.json
C:/work/xemu/qemu/build/../tests/qapi-schema/union-base-empty.json
C:/work/xemu/qemu/build/../tests/qapi-schema/union-base-no-discriminator.json
C:/work/xemu/qemu/build/../tests/qapi-schema/union-branch-case.json
C:/work/xemu/qemu/build/../tests/qapi-schema/union-branch-if-invalid.json
C:/work/xemu/qemu/build/../tests/qapi-schema/union-branch-invalid-dict.json
C:/work/xemu/qemu/build/../tests/qapi-schema/union-clash-branches.json
C:/work/xemu/qemu/build/../tests/qapi-schema/union-empty.json
C:/work/xemu/qemu/build/../tests/qapi-schema/union-invalid-base.json
C:/work/xemu/qemu/build/../tests/qapi-schema/union-optional-branch.json
C:/work/xemu/qemu/build/../tests/qapi-schema/union-unknown.json
C:/work/xemu/qemu/build/../tests/qapi-schema/unknown-escape.json
C:/work/xemu/qemu/build/../tests/qapi-schema/unknown-expr-key.json
"C:/CI-Tools/msys64/mingw64/bin/python3.exe"
"C:/work/xemu/qemu/meson/meson.py" "--internal" "exe" "--capture"
"tests/qapi-schema/doc-good.ref.nocr" "--" "perl" "-pe" "$x = chr 13;
s/$x$//" "../tests/qapi-schema/doc-good.txt" && if test -e
tests/qapi-schema/doc-good.ref.nocr; then printf '%s\n'
tests/qapi-schema/doc-good.ref.nocr >
tests/qapi-schema/doc-good.ref.nocr.stamp; fi
syntax error at -e line 1, near "="
Execution of -e aborted due to compilation errors.
make: *** [Makefile.ninja:2572:tests/qapi-schema/doc-good.ref.nocr.stamp]
错误 255
>

> > diff --git a/tests/qapi-schema/meson.build

b/tests/qapi-schema/meson.build
> > index 1f222a7a13..20a7641af8 100644

> > --- a/tests/qapi-schema/meson.build

> > +++ b/tests/qapi-schema/meson.build

> > @@ -251,18 +251,19 @@ qapi_doc_out = custom_target('QAPI rST doc',

> >  # 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)

> > +rst_sanitize_cmd = [find_program('../../scripts/rst-sanitize.py'),

'@INPUT@']
> >  qapi_doc_out_nocr = custom_target('QAPI rST doc newline-sanitized',

> >                                    output: ['doc-good.txt.nocr'],

> >                                    input: qapi_doc_out[0],

> >                                    build_by_default: build_docs,

> > -                                  command: ['perl', '-pe', '$x = chr

13; s/$x$//', '@INPUT@'],
> > +                                  command: rst_sanitize_cmd,

> >                                    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: build_docs,

> > -                                  command: ['perl', '-pe', '$x = chr

13; s/$x$//', '@INPUT@'],
> > +                                  command: rst_sanitize_cmd,

> >                                    capture: true)

>

> thanks

> -- PMM




--
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
<div dir="ltr"><br><br>On Fri, Oct 16, 2020 at 4:30 AM Peter Maydell &lt;<a href="mailto:peter.maydell@linaro.org">peter.maydell@linaro.org</a>&gt; wrote:<br>&gt;<br>&gt; On Thu, 15 Oct 2020 at 21:13, Yonggang Luo &lt;<a href="mailto:luoyonggang@gmail.com">luoyonggang@gmail.com</a>&gt; wrote:<br>&gt; &gt;<br>&gt; &gt; Signed-off-by: Yonggang Luo &lt;<a href="mailto:luoyonggang@gmail.com">luoyonggang@gmail.com</a>&gt;<br>&gt; &gt; ---<br>&gt; &gt;  docs/conf.py                  |  2 +-<br>&gt; &gt;  docs/sphinx/kerneldoc.py      |  2 +-<br>&gt; &gt;  scripts/rst-sanitize.py       | 21 +++++++++++++++++++++<br>&gt; &gt;  tests/qapi-schema/meson.build |  5 +++--<br>&gt; &gt;  4 files changed, 26 insertions(+), 4 deletions(-)<br>&gt; &gt;  create mode 100644 scripts/rst-sanitize.py<br>&gt; &gt;<br>&gt; &gt; diff --git a/scripts/rst-sanitize.py b/scripts/rst-sanitize.py<br>&gt; &gt; new file mode 100644<br>&gt; &gt; index 0000000000..26060f1208<br>&gt; &gt; --- /dev/null<br>&gt; &gt; +++ b/scripts/rst-sanitize.py<br>&gt; &gt; @@ -0,0 +1,21 @@<br>&gt; &gt; +#!/usr/bin/env python3<br>&gt; &gt; +<br>&gt; &gt; +#<br>&gt; &gt; +# Script for remove cr line ending in file<br>&gt; &gt; +#<br>&gt; &gt; +# Authors:<br>&gt; &gt; +#  Yonggang Luo &lt;<a href="mailto:luoyonggang@gmail.com">luoyonggang@gmail.com</a>&gt;<br>&gt; &gt; +#<br>&gt; &gt; +# This work is licensed under the terms of the GNU GPL, version 2<br>&gt; &gt; +# or, at your option, any later version.  See the COPYING file in<br>&gt; &gt; +# the top-level directory.<br>&gt; &gt; +<br>&gt; &gt; +import sys<br>&gt; &gt; +<br>&gt; &gt; +def main(_program, file, *unused):<br>&gt; &gt; +    with open(file, &#39;rb&#39;) as content_file:<br>&gt; &gt; +        content = content_file.read()<br>&gt; &gt; +        sys.stdout.buffer.write(content.replace(b&#39;\r&#39;, b&#39;&#39;))<br>&gt; &gt; +<br>&gt; &gt; +if __name__ == &quot;__main__&quot;:<br>&gt; &gt; +    main(*sys.argv)<br>&gt;<br>&gt; Why doesn&#39;t the perl rune work? Your commit message doesn&#39;t say.<div><br></div><div><br>PASS 3 test-qdev-global-props /qdev/properties/dynamic/global<br>PASS 4 test-qdev-global-props /qdev/properties/global/subclass<br>MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  ../../../../../CI-Tools/msys64/usr/bin/sh.EXE C:/work/xemu/qemu/build/../tests/decode/check.sh python3 -B C:/work/xemu/qemu/build/../tests/../scripts/decodetree.py<br>MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))} PYTHONPATH=C:/work/xemu/qemu/scripts PYTHONIOENCODING=utf-8 ../../../../CI-Tools/msys64/mingw64/bin/python3.exe C:/work/xemu/qemu/build/../tests/qapi-schema/test-qapi.py C:/work/xemu/qemu/build/../tests/qapi-schema/alternate-any.json C:/work/xemu/qemu/build/../tests/qapi-schema/alternate-array.json C:/work/xemu/qemu/build/../tests/qapi-schema/alternate-base.json C:/work/xemu/qemu/build/../tests/qapi-schema/alternate-branch-if-invalid.json C:/work/xemu/qemu/build/../tests/qapi-schema/alternate-clash.json C:/work/xemu/qemu/build/../tests/qapi-schema/alternate-conflict-dict.json C:/work/xemu/qemu/build/../tests/qapi-schema/alternate-conflict-enum-bool.json C:/work/xemu/qemu/build/../tests/qapi-schema/alternate-conflict-enum-int.json C:/work/xemu/qemu/build/../tests/qapi-schema/alternate-conflict-string.json C:/work/xemu/qemu/build/../tests/qapi-schema/alternate-conflict-bool-string.json C:/work/xemu/qemu/build/../tests/qapi-schema/alternate-conflict-num-string.json C:/work/xemu/qemu/build/../tests/qapi-schema/alternate-empty.json C:/work/xemu/qemu/build/../tests/qapi-schema/alternate-invalid-dict.json C:/work/xemu/qemu/build/../tests/qapi-schema/alternate-nested.json C:/work/xemu/qemu/build/../tests/qapi-schema/alternate-unknown.json C:/work/xemu/qemu/build/../tests/qapi-schema/args-alternate.json C:/work/xemu/qemu/build/../tests/qapi-schema/args-any.json C:/work/xemu/qemu/build/../tests/qapi-schema/args-array-empty.json C:/work/xemu/qemu/build/../tests/qapi-schema/args-array-unknown.json C:/work/xemu/qemu/build/../tests/qapi-schema/args-bad-boxed.json C:/work/xemu/qemu/build/../tests/qapi-schema/args-boxed-anon.json C:/work/xemu/qemu/build/../tests/qapi-schema/args-boxed-string.json C:/work/xemu/qemu/build/../tests/qapi-schema/args-int.json C:/work/xemu/qemu/build/../tests/qapi-schema/args-invalid.json C:/work/xemu/qemu/build/../tests/qapi-schema/args-member-array-bad.json C:/work/xemu/qemu/build/../tests/qapi-schema/args-member-case.json C:/work/xemu/qemu/build/../tests/qapi-schema/args-member-unknown.json C:/work/xemu/qemu/build/../tests/qapi-schema/args-name-clash.json C:/work/xemu/qemu/build/../tests/qapi-schema/args-union.json C:/work/xemu/qemu/build/../tests/qapi-schema/args-unknown.json C:/work/xemu/qemu/build/../tests/qapi-schema/bad-base.json C:/work/xemu/qemu/build/../tests/qapi-schema/bad-data.json C:/work/xemu/qemu/build/../tests/qapi-schema/bad-ident.json C:/work/xemu/qemu/build/../tests/qapi-schema/bad-if.json C:/work/xemu/qemu/build/../tests/qapi-schema/bad-if-empty.json C:/work/xemu/qemu/build/../tests/qapi-schema/bad-if-empty-list.json C:/work/xemu/qemu/build/../tests/qapi-schema/bad-if-list.json C:/work/xemu/qemu/build/../tests/qapi-schema/bad-type-bool.json C:/work/xemu/qemu/build/../tests/qapi-schema/bad-type-dict.json C:/work/xemu/qemu/build/../tests/qapi-schema/bad-type-int.json C:/work/xemu/qemu/build/../tests/qapi-schema/base-cycle-direct.json C:/work/xemu/qemu/build/../tests/qapi-schema/base-cycle-indirect.json C:/work/xemu/qemu/build/../tests/qapi-schema/command-int.json C:/work/xemu/qemu/build/../tests/qapi-schema/comments.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-bad-alternate-member.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-bad-boxed-command-arg.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-bad-command-arg.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-bad-enum-member.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-bad-event-arg.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-bad-feature.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-bad-indent.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-bad-section.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-bad-symbol.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-bad-union-member.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-before-include.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-before-pragma.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-duplicated-arg.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-duplicated-return.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-duplicated-since.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-empty-arg.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-empty-section.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-empty-symbol.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-good.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-interleaved-section.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-invalid-end.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-invalid-end2.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-invalid-return.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-invalid-section.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-invalid-start.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-missing-colon.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-missing-expr.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-missing-space.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-missing.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-no-symbol.json C:/work/xemu/qemu/build/../tests/qapi-schema/doc-undoc-feature.json C:/work/xemu/qemu/build/../tests/qapi-schema/double-type.json C:/work/xemu/qemu/build/../tests/qapi-schema/duplicate-key.json C:/work/xemu/qemu/build/../tests/qapi-schema/empty.json C:/work/xemu/qemu/build/../tests/qapi-schema/enum-bad-member.json C:/work/xemu/qemu/build/../tests/qapi-schema/enum-bad-name.json C:/work/xemu/qemu/build/../tests/qapi-schema/enum-bad-prefix.json C:/work/xemu/qemu/build/../tests/qapi-schema/enum-clash-member.json C:/work/xemu/qemu/build/../tests/qapi-schema/enum-dict-member-unknown.json C:/work/xemu/qemu/build/../tests/qapi-schema/enum-if-invalid.json C:/work/xemu/qemu/build/../tests/qapi-schema/enum-int-member.json C:/work/xemu/qemu/build/../tests/qapi-schema/enum-member-case.json C:/work/xemu/qemu/build/../tests/qapi-schema/enum-missing-data.json C:/work/xemu/qemu/build/../tests/qapi-schema/enum-wrong-data.json C:/work/xemu/qemu/build/../tests/qapi-schema/event-boxed-empty.json C:/work/xemu/qemu/build/../tests/qapi-schema/event-case.json C:/work/xemu/qemu/build/../tests/qapi-schema/event-member-invalid-dict.json C:/work/xemu/qemu/build/../tests/qapi-schema/event-nest-struct.json C:/work/xemu/qemu/build/../tests/qapi-schema/features-bad-type.json C:/work/xemu/qemu/build/../tests/qapi-schema/features-deprecated-type.json C:/work/xemu/qemu/build/../tests/qapi-schema/features-duplicate-name.json C:/work/xemu/qemu/build/../tests/qapi-schema/features-if-invalid.json C:/work/xemu/qemu/build/../tests/qapi-schema/features-missing-name.json C:/work/xemu/qemu/build/../tests/qapi-schema/features-name-bad-type.json C:/work/xemu/qemu/build/../tests/qapi-schema/features-no-list.json C:/work/xemu/qemu/build/../tests/qapi-schema/features-unknown-key.json C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-array-branch.json C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-bad-base.json C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-bad-discriminator.json C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-base-any.json C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-base-union.json C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-clash-member.json C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-discriminator-bad-name.json C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-empty.json C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-inline.json C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-inline-invalid-dict.json C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-int-branch.json C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-invalid-branch-key.json C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-invalid-discriminator.json C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-invalid-if-discriminator.json C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-no-base.json C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-optional-discriminator.json C:/work/xemu/qemu/build/../tests/qapi-schema/flat-union-string-discriminator.json C:/work/xemu/qemu/build/../tests/qapi-schema/funny-char.json C:/work/xemu/qemu/build/../tests/qapi-schema/funny-word.json C:/work/xemu/qemu/build/../tests/qapi-schema/ident-with-escape.json C:/work/xemu/qemu/build/../tests/qapi-schema/include-before-err.json C:/work/xemu/qemu/build/../tests/qapi-schema/include-cycle.json C:/work/xemu/qemu/build/../tests/qapi-schema/include-extra-junk.json C:/work/xemu/qemu/build/../tests/qapi-schema/include-nested-err.json C:/work/xemu/qemu/build/../tests/qapi-schema/include-no-file.json C:/work/xemu/qemu/build/../tests/qapi-schema/include-non-file.json C:/work/xemu/qemu/build/../tests/qapi-schema/include-repetition.json C:/work/xemu/qemu/build/../tests/qapi-schema/include-self-cycle.json C:/work/xemu/qemu/build/../tests/qapi-schema/include-simple.json C:/work/xemu/qemu/build/../tests/qapi-schema/indented-expr.json C:/work/xemu/qemu/build/../tests/qapi-schema/leading-comma-list.json C:/work/xemu/qemu/build/../tests/qapi-schema/leading-comma-object.json C:/work/xemu/qemu/build/../tests/qapi-schema/missing-colon.json C:/work/xemu/qemu/build/../tests/qapi-schema/missing-comma-list.json C:/work/xemu/qemu/build/../tests/qapi-schema/missing-comma-object.json C:/work/xemu/qemu/build/../tests/qapi-schema/missing-type.json C:/work/xemu/qemu/build/../tests/qapi-schema/nested-struct-data.json C:/work/xemu/qemu/build/../tests/qapi-schema/nested-struct-data-invalid-dict.json C:/work/xemu/qemu/build/../tests/qapi-schema/non-objects.json C:/work/xemu/qemu/build/../tests/qapi-schema/oob-coroutine.json C:/work/xemu/qemu/build/../tests/qapi-schema/oob-test.json C:/work/xemu/qemu/build/../tests/qapi-schema/allow-preconfig-test.json C:/work/xemu/qemu/build/../tests/qapi-schema/pragma-doc-required-crap.json C:/work/xemu/qemu/build/../tests/qapi-schema/pragma-extra-junk.json C:/work/xemu/qemu/build/../tests/qapi-schema/pragma-name-case-whitelist-crap.json C:/work/xemu/qemu/build/../tests/qapi-schema/pragma-non-dict.json C:/work/xemu/qemu/build/../tests/qapi-schema/pragma-unknown.json C:/work/xemu/qemu/build/../tests/qapi-schema/pragma-returns-whitelist-crap.json C:/work/xemu/qemu/build/../tests/qapi-schema/qapi-schema-test.json C:/work/xemu/qemu/build/../tests/qapi-schema/quoted-structural-chars.json C:/work/xemu/qemu/build/../tests/qapi-schema/redefined-builtin.json C:/work/xemu/qemu/build/../tests/qapi-schema/redefined-command.json C:/work/xemu/qemu/build/../tests/qapi-schema/redefined-event.json C:/work/xemu/qemu/build/../tests/qapi-schema/redefined-type.json C:/work/xemu/qemu/build/../tests/qapi-schema/reserved-command-q.json C:/work/xemu/qemu/build/../tests/qapi-schema/reserved-enum-q.json C:/work/xemu/qemu/build/../tests/qapi-schema/reserved-member-has.json C:/work/xemu/qemu/build/../tests/qapi-schema/reserved-member-q.json C:/work/xemu/qemu/build/../tests/qapi-schema/reserved-member-u.json C:/work/xemu/qemu/build/../tests/qapi-schema/reserved-member-underscore.json C:/work/xemu/qemu/build/../tests/qapi-schema/reserved-type-kind.json C:/work/xemu/qemu/build/../tests/qapi-schema/reserved-type-list.json C:/work/xemu/qemu/build/../tests/qapi-schema/returns-alternate.json C:/work/xemu/qemu/build/../tests/qapi-schema/returns-array-bad.json C:/work/xemu/qemu/build/../tests/qapi-schema/returns-dict.json C:/work/xemu/qemu/build/../tests/qapi-schema/returns-unknown.json C:/work/xemu/qemu/build/../tests/qapi-schema/returns-whitelist.json C:/work/xemu/qemu/build/../tests/qapi-schema/string-code-point-31.json C:/work/xemu/qemu/build/../tests/qapi-schema/string-code-point-127.json C:/work/xemu/qemu/build/../tests/qapi-schema/struct-base-clash-deep.json C:/work/xemu/qemu/build/../tests/qapi-schema/struct-base-clash.json C:/work/xemu/qemu/build/../tests/qapi-schema/struct-data-invalid.json C:/work/xemu/qemu/build/../tests/qapi-schema/struct-member-if-invalid.json C:/work/xemu/qemu/build/../tests/qapi-schema/struct-member-invalid-dict.json C:/work/xemu/qemu/build/../tests/qapi-schema/struct-member-invalid.json C:/work/xemu/qemu/build/../tests/qapi-schema/trailing-comma-list.json C:/work/xemu/qemu/build/../tests/qapi-schema/trailing-comma-object.json C:/work/xemu/qemu/build/../tests/qapi-schema/type-bypass-bad-gen.json C:/work/xemu/qemu/build/../tests/qapi-schema/unclosed-list.json C:/work/xemu/qemu/build/../tests/qapi-schema/unclosed-object.json C:/work/xemu/qemu/build/../tests/qapi-schema/unclosed-string.json C:/work/xemu/qemu/build/../tests/qapi-schema/union-base-empty.json C:/work/xemu/qemu/build/../tests/qapi-schema/union-base-no-discriminator.json C:/work/xemu/qemu/build/../tests/qapi-schema/union-branch-case.json C:/work/xemu/qemu/build/../tests/qapi-schema/union-branch-if-invalid.json C:/work/xemu/qemu/build/../tests/qapi-schema/union-branch-invalid-dict.json C:/work/xemu/qemu/build/../tests/qapi-schema/union-clash-branches.json C:/work/xemu/qemu/build/../tests/qapi-schema/union-empty.json C:/work/xemu/qemu/build/../tests/qapi-schema/union-invalid-base.json C:/work/xemu/qemu/build/../tests/qapi-schema/union-optional-branch.json C:/work/xemu/qemu/build/../tests/qapi-schema/union-unknown.json C:/work/xemu/qemu/build/../tests/qapi-schema/unknown-escape.json C:/work/xemu/qemu/build/../tests/qapi-schema/unknown-expr-key.json<br>&quot;C:/CI-Tools/msys64/mingw64/bin/python3.exe&quot; &quot;C:/work/xemu/qemu/meson/meson.py&quot; &quot;--internal&quot; &quot;exe&quot; &quot;--capture&quot; &quot;tests/qapi-schema/doc-good.ref.nocr&quot; &quot;--&quot; &quot;perl&quot; &quot;-pe&quot; &quot;$x = chr 13; s/$x$//&quot; &quot;../tests/qapi-schema/doc-good.txt&quot; &amp;&amp; if test -e tests/qapi-schema/doc-good.ref.nocr; then printf &#39;%s\n&#39; tests/qapi-schema/doc-good.ref.nocr &gt; tests/qapi-schema/doc-good.ref.nocr.stamp; fi<br>syntax error at -e line 1, near &quot;=&quot;<br>Execution of -e aborted due to compilation errors.<br>make: *** [Makefile.ninja:2572:tests/qapi-schema/doc-good.ref.nocr.stamp] 错误 255<br>&gt;<br>&gt; &gt; diff --git a/tests/qapi-schema/meson.build b/tests/qapi-schema/meson.build<br>&gt; &gt; index 1f222a7a13..20a7641af8 100644<br>&gt; &gt; --- a/tests/qapi-schema/meson.build<br>&gt; &gt; +++ b/tests/qapi-schema/meson.build<br>&gt; &gt; @@ -251,18 +251,19 @@ qapi_doc_out = custom_target(&#39;QAPI rST doc&#39;,<br>&gt; &gt;  # using an explicit &#39;\&#39; character in the command arguments to<br>&gt; &gt;  # a custom_target(), as Meson will unhelpfully replace it with a &#39;/&#39;<br>&gt; &gt;  # (<a href="https://github.com/mesonbuild/meson/issues/1564">https://github.com/mesonbuild/meson/issues/1564</a>)<br>&gt; &gt; +rst_sanitize_cmd = [find_program(&#39;../../scripts/rst-sanitize.py&#39;), &#39;@INPUT@&#39;]<br>&gt; &gt;  qapi_doc_out_nocr = custom_target(&#39;QAPI rST doc newline-sanitized&#39;,<br>&gt; &gt;                                    output: [&#39;doc-good.txt.nocr&#39;],<br>&gt; &gt;                                    input: qapi_doc_out[0],<br>&gt; &gt;                                    build_by_default: build_docs,<br>&gt; &gt; -                                  command: [&#39;perl&#39;, &#39;-pe&#39;, &#39;$x = chr 13; s/$x$//&#39;, &#39;@INPUT@&#39;],<br>&gt; &gt; +                                  command: rst_sanitize_cmd,<br>&gt; &gt;                                    capture: true)<br>&gt; &gt;<br>&gt; &gt;  qapi_doc_ref_nocr = custom_target(&#39;QAPI rST doc reference newline-sanitized&#39;,<br>&gt; &gt;                                    output: [&#39;doc-good.ref.nocr&#39;],<br>&gt; &gt;                                    input: files(&#39;doc-good.txt&#39;),<br>&gt; &gt;                                    build_by_default: build_docs,<br>&gt; &gt; -                                  command: [&#39;perl&#39;, &#39;-pe&#39;, &#39;$x = chr 13; s/$x$//&#39;, &#39;@INPUT@&#39;],<br>&gt; &gt; +                                  command: rst_sanitize_cmd,<br>&gt; &gt;                                    capture: true)<br>&gt;<br>&gt; thanks<br>&gt; -- PMM<br><br><br><br>--<br>         此致<br>礼<br>罗勇刚<br>Yours<br>    sincerely,<br>Yonggang Luo</div></div>
Paolo Bonzini Oct. 15, 2020, 9:22 p.m. UTC | #3
Il gio 15 ott 2020, 22:30 Peter Maydell <peter.maydell@linaro.org> ha
scritto:

> On Thu, 15 Oct 2020 at 21:13, Yonggang Luo <luoyonggang@gmail.com> wrote:

> >

> > Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>

> > ---

> >  docs/conf.py                  |  2 +-

> >  docs/sphinx/kerneldoc.py      |  2 +-

> >  scripts/rst-sanitize.py       | 21 +++++++++++++++++++++

> >  tests/qapi-schema/meson.build |  5 +++--

> >  4 files changed, 26 insertions(+), 4 deletions(-)

> >  create mode 100644 scripts/rst-sanitize.py

> >

> > diff --git a/scripts/rst-sanitize.py b/scripts/rst-sanitize.py

> > new file mode 100644

> > index 0000000000..26060f1208

> > --- /dev/null

> > +++ b/scripts/rst-sanitize.py

> > @@ -0,0 +1,21 @@

> > +#!/usr/bin/env python3

> > +

> > +#

> > +# Script for remove cr line ending in file

> > +#

> > +# Authors:

> > +#  Yonggang Luo <luoyonggang@gmail.com>

> > +#

> > +# This work is licensed under the terms of the GNU GPL, version 2

> > +# or, at your option, any later version.  See the COPYING file in

> > +# the top-level directory.

> > +

> > +import sys

> > +

> > +def main(_program, file, *unused):

> > +    with open(file, 'rb') as content_file:

> > +        content = content_file.read()

> > +        sys.stdout.buffer.write(content.replace(b'\r', b''))

> > +

> > +if __name__ == "__main__":

> > +    main(*sys.argv)

>

> Why doesn't the perl rune work? Your commit message doesn't say.

>


Ninjatool gets confused by Windows escapes. So it's a QEMU-ism and
switching to ninja fixes it. There's no need to use a separate script for
this.

Paolo


> > diff --git a/tests/qapi-schema/meson.build

> b/tests/qapi-schema/meson.build

> > index 1f222a7a13..20a7641af8 100644

> > --- a/tests/qapi-schema/meson.build

> > +++ b/tests/qapi-schema/meson.build

> > @@ -251,18 +251,19 @@ qapi_doc_out = custom_target('QAPI rST doc',

> >  # 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)

> > +rst_sanitize_cmd = [find_program('../../scripts/rst-sanitize.py'),

> '@INPUT@']

> >  qapi_doc_out_nocr = custom_target('QAPI rST doc newline-sanitized',

> >                                    output: ['doc-good.txt.nocr'],

> >                                    input: qapi_doc_out[0],

> >                                    build_by_default: build_docs,

> > -                                  command: ['perl', '-pe', '$x = chr

> 13; s/$x$//', '@INPUT@'],

> > +                                  command: rst_sanitize_cmd,

> >                                    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: build_docs,

> > -                                  command: ['perl', '-pe', '$x = chr

> 13; s/$x$//', '@INPUT@'],

> > +                                  command: rst_sanitize_cmd,

> >                                    capture: true)

>

> thanks

> -- PMM

>

>
<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Il gio 15 ott 2020, 22:30 Peter Maydell &lt;<a href="mailto:peter.maydell@linaro.org">peter.maydell@linaro.org</a>&gt; ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Thu, 15 Oct 2020 at 21:13, Yonggang Luo &lt;<a href="mailto:luoyonggang@gmail.com" target="_blank" rel="noreferrer">luoyonggang@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; Signed-off-by: Yonggang Luo &lt;<a href="mailto:luoyonggang@gmail.com" target="_blank" rel="noreferrer">luoyonggang@gmail.com</a>&gt;<br>
&gt; ---<br>
&gt;  docs/conf.py                  |  2 +-<br>
&gt;  docs/sphinx/kerneldoc.py      |  2 +-<br>
&gt;  scripts/rst-sanitize.py       | 21 +++++++++++++++++++++<br>
&gt;  tests/qapi-schema/meson.build |  5 +++--<br>
&gt;  4 files changed, 26 insertions(+), 4 deletions(-)<br>
&gt;  create mode 100644 scripts/rst-sanitize.py<br>
&gt;<br>
&gt; diff --git a/scripts/rst-sanitize.py b/scripts/rst-sanitize.py<br>
&gt; new file mode 100644<br>
&gt; index 0000000000..26060f1208<br>
&gt; --- /dev/null<br>
&gt; +++ b/scripts/rst-sanitize.py<br>
&gt; @@ -0,0 +1,21 @@<br>
&gt; +#!/usr/bin/env python3<br>
&gt; +<br>
&gt; +#<br>
&gt; +# Script for remove cr line ending in file<br>
&gt; +#<br>
&gt; +# Authors:<br>
&gt; +#  Yonggang Luo &lt;<a href="mailto:luoyonggang@gmail.com" target="_blank" rel="noreferrer">luoyonggang@gmail.com</a>&gt;<br>
&gt; +#<br>
&gt; +# This work is licensed under the terms of the GNU GPL, version 2<br>
&gt; +# or, at your option, any later version.  See the COPYING file in<br>
&gt; +# the top-level directory.<br>
&gt; +<br>
&gt; +import sys<br>
&gt; +<br>
&gt; +def main(_program, file, *unused):<br>
&gt; +    with open(file, &#39;rb&#39;) as content_file:<br>
&gt; +        content = content_file.read()<br>
&gt; +        sys.stdout.buffer.write(content.replace(b&#39;\r&#39;, b&#39;&#39;))<br>
&gt; +<br>
&gt; +if __name__ == &quot;__main__&quot;:<br>
&gt; +    main(*sys.argv)<br>
<br>
Why doesn&#39;t the perl rune work? Your commit message doesn&#39;t say.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Ninjatool gets confused by Windows escapes. So it&#39;s a QEMU-ism and switching to ninja fixes it. There&#39;s no need to use a separate script for this.</div><div dir="auto"><br></div><div dir="auto">Paolo</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
&gt; diff --git a/tests/qapi-schema/meson.build b/tests/qapi-schema/meson.build<br>
&gt; index 1f222a7a13..20a7641af8 100644<br>
&gt; --- a/tests/qapi-schema/meson.build<br>
&gt; +++ b/tests/qapi-schema/meson.build<br>
&gt; @@ -251,18 +251,19 @@ qapi_doc_out = custom_target(&#39;QAPI rST doc&#39;,<br>
&gt;  # using an explicit &#39;\&#39; character in the command arguments to<br>
&gt;  # a custom_target(), as Meson will unhelpfully replace it with a &#39;/&#39;<br>
&gt;  # (<a href="https://github.com/mesonbuild/meson/issues/1564" rel="noreferrer noreferrer" target="_blank">https://github.com/mesonbuild/meson/issues/1564</a>)<br>
&gt; +rst_sanitize_cmd = [find_program(&#39;../../scripts/rst-sanitize.py&#39;), &#39;@INPUT@&#39;]<br>
&gt;  qapi_doc_out_nocr = custom_target(&#39;QAPI rST doc newline-sanitized&#39;,<br>
&gt;                                    output: [&#39;doc-good.txt.nocr&#39;],<br>
&gt;                                    input: qapi_doc_out[0],<br>
&gt;                                    build_by_default: build_docs,<br>
&gt; -                                  command: [&#39;perl&#39;, &#39;-pe&#39;, &#39;$x = chr 13; s/$x$//&#39;, &#39;@INPUT@&#39;],<br>
&gt; +                                  command: rst_sanitize_cmd,<br>
&gt;                                    capture: true)<br>
&gt;<br>
&gt;  qapi_doc_ref_nocr = custom_target(&#39;QAPI rST doc reference newline-sanitized&#39;,<br>
&gt;                                    output: [&#39;doc-good.ref.nocr&#39;],<br>
&gt;                                    input: files(&#39;doc-good.txt&#39;),<br>
&gt;                                    build_by_default: build_docs,<br>
&gt; -                                  command: [&#39;perl&#39;, &#39;-pe&#39;, &#39;$x = chr 13; s/$x$//&#39;, &#39;@INPUT@&#39;],<br>
&gt; +                                  command: rst_sanitize_cmd,<br>
&gt;                                    capture: true)<br>
<br>
thanks<br>
-- PMM<br>
<br>
</blockquote></div></div></div>
罗勇刚(Yonggang Luo) Oct. 15, 2020, 9:33 p.m. UTC | #4
It's tests, running by make

On Fri, Oct 16, 2020 at 5:23 AM Paolo Bonzini <pbonzini@redhat.com> wrote:
>

>

>

> Il gio 15 ott 2020, 22:30 Peter Maydell <peter.maydell@linaro.org> ha

scritto:
>>

>> On Thu, 15 Oct 2020 at 21:13, Yonggang Luo <luoyonggang@gmail.com> wrote:

>> >

>> > Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>

>> > ---

>> >  docs/conf.py                  |  2 +-

>> >  docs/sphinx/kerneldoc.py      |  2 +-

>> >  scripts/rst-sanitize.py       | 21 +++++++++++++++++++++

>> >  tests/qapi-schema/meson.build |  5 +++--

>> >  4 files changed, 26 insertions(+), 4 deletions(-)

>> >  create mode 100644 scripts/rst-sanitize.py

>> >

>> > diff --git a/scripts/rst-sanitize.py b/scripts/rst-sanitize.py

>> > new file mode 100644

>> > index 0000000000..26060f1208

>> > --- /dev/null

>> > +++ b/scripts/rst-sanitize.py

>> > @@ -0,0 +1,21 @@

>> > +#!/usr/bin/env python3

>> > +

>> > +#

>> > +# Script for remove cr line ending in file

>> > +#

>> > +# Authors:

>> > +#  Yonggang Luo <luoyonggang@gmail.com>

>> > +#

>> > +# This work is licensed under the terms of the GNU GPL, version 2

>> > +# or, at your option, any later version.  See the COPYING file in

>> > +# the top-level directory.

>> > +

>> > +import sys

>> > +

>> > +def main(_program, file, *unused):

>> > +    with open(file, 'rb') as content_file:

>> > +        content = content_file.read()

>> > +        sys.stdout.buffer.write(content.replace(b'\r', b''))

>> > +

>> > +if __name__ == "__main__":

>> > +    main(*sys.argv)

>>

>> Why doesn't the perl rune work? Your commit message doesn't say.

>

>

> Ninjatool gets confused by Windows escapes. So it's a QEMU-ism and

switching to ninja fixes it. There's no need to use a separate script for
this.
>

> Paolo

>

>>

>> > diff --git a/tests/qapi-schema/meson.build

b/tests/qapi-schema/meson.build
>> > index 1f222a7a13..20a7641af8 100644

>> > --- a/tests/qapi-schema/meson.build

>> > +++ b/tests/qapi-schema/meson.build

>> > @@ -251,18 +251,19 @@ qapi_doc_out = custom_target('QAPI rST doc',

>> >  # 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)

>> > +rst_sanitize_cmd = [find_program('../../scripts/rst-sanitize.py'),

'@INPUT@']
>> >  qapi_doc_out_nocr = custom_target('QAPI rST doc newline-sanitized',

>> >                                    output: ['doc-good.txt.nocr'],

>> >                                    input: qapi_doc_out[0],

>> >                                    build_by_default: build_docs,

>> > -                                  command: ['perl', '-pe', '$x = chr

13; s/$x$//', '@INPUT@'],
>> > +                                  command: rst_sanitize_cmd,

>> >                                    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: build_docs,

>> > -                                  command: ['perl', '-pe', '$x = chr

13; s/$x$//', '@INPUT@'],
>> > +                                  command: rst_sanitize_cmd,

>> >                                    capture: true)

>>

>> thanks

>> -- PMM

>>



--
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
<div dir="ltr">It&#39;s tests, running by make<br><br>On Fri, Oct 16, 2020 at 5:23 AM Paolo Bonzini &lt;<a href="mailto:pbonzini@redhat.com">pbonzini@redhat.com</a>&gt; wrote:<br>&gt;<br>&gt;<br>&gt;<br>&gt; Il gio 15 ott 2020, 22:30 Peter Maydell &lt;<a href="mailto:peter.maydell@linaro.org">peter.maydell@linaro.org</a>&gt; ha scritto:<br>&gt;&gt;<br>&gt;&gt; On Thu, 15 Oct 2020 at 21:13, Yonggang Luo &lt;<a href="mailto:luoyonggang@gmail.com">luoyonggang@gmail.com</a>&gt; wrote:<br>&gt;&gt; &gt;<br>&gt;&gt; &gt; Signed-off-by: Yonggang Luo &lt;<a href="mailto:luoyonggang@gmail.com">luoyonggang@gmail.com</a>&gt;<br>&gt;&gt; &gt; ---<br>&gt;&gt; &gt;  docs/conf.py                  |  2 +-<br>&gt;&gt; &gt;  docs/sphinx/kerneldoc.py      |  2 +-<br>&gt;&gt; &gt;  scripts/rst-sanitize.py       | 21 +++++++++++++++++++++<br>&gt;&gt; &gt;  tests/qapi-schema/meson.build |  5 +++--<br>&gt;&gt; &gt;  4 files changed, 26 insertions(+), 4 deletions(-)<br>&gt;&gt; &gt;  create mode 100644 scripts/rst-sanitize.py<br>&gt;&gt; &gt;<br>&gt;&gt; &gt; diff --git a/scripts/rst-sanitize.py b/scripts/rst-sanitize.py<br>&gt;&gt; &gt; new file mode 100644<br>&gt;&gt; &gt; index 0000000000..26060f1208<br>&gt;&gt; &gt; --- /dev/null<br>&gt;&gt; &gt; +++ b/scripts/rst-sanitize.py<br>&gt;&gt; &gt; @@ -0,0 +1,21 @@<br>&gt;&gt; &gt; +#!/usr/bin/env python3<br>&gt;&gt; &gt; +<br>&gt;&gt; &gt; +#<br>&gt;&gt; &gt; +# Script for remove cr line ending in file<br>&gt;&gt; &gt; +#<br>&gt;&gt; &gt; +# Authors:<br>&gt;&gt; &gt; +#  Yonggang Luo &lt;<a href="mailto:luoyonggang@gmail.com">luoyonggang@gmail.com</a>&gt;<br>&gt;&gt; &gt; +#<br>&gt;&gt; &gt; +# This work is licensed under the terms of the GNU GPL, version 2<br>&gt;&gt; &gt; +# or, at your option, any later version.  See the COPYING file in<br>&gt;&gt; &gt; +# the top-level directory.<br>&gt;&gt; &gt; +<br>&gt;&gt; &gt; +import sys<br>&gt;&gt; &gt; +<br>&gt;&gt; &gt; +def main(_program, file, *unused):<br>&gt;&gt; &gt; +    with open(file, &#39;rb&#39;) as content_file:<br>&gt;&gt; &gt; +        content = content_file.read()<br>&gt;&gt; &gt; +        sys.stdout.buffer.write(content.replace(b&#39;\r&#39;, b&#39;&#39;))<br>&gt;&gt; &gt; +<br>&gt;&gt; &gt; +if __name__ == &quot;__main__&quot;:<br>&gt;&gt; &gt; +    main(*sys.argv)<br>&gt;&gt;<br>&gt;&gt; Why doesn&#39;t the perl rune work? Your commit message doesn&#39;t say.<br>&gt;<br>&gt;<br>&gt; Ninjatool gets confused by Windows escapes. So it&#39;s a QEMU-ism and switching to ninja fixes it. There&#39;s no need to use a separate script for this.<br>&gt;<br>&gt; Paolo<br>&gt;<br>&gt;&gt;<br>&gt;&gt; &gt; diff --git a/tests/qapi-schema/meson.build b/tests/qapi-schema/meson.build<br>&gt;&gt; &gt; index 1f222a7a13..20a7641af8 100644<br>&gt;&gt; &gt; --- a/tests/qapi-schema/meson.build<br>&gt;&gt; &gt; +++ b/tests/qapi-schema/meson.build<br>&gt;&gt; &gt; @@ -251,18 +251,19 @@ qapi_doc_out = custom_target(&#39;QAPI rST doc&#39;,<br>&gt;&gt; &gt;  # using an explicit &#39;\&#39; character in the command arguments to<br>&gt;&gt; &gt;  # a custom_target(), as Meson will unhelpfully replace it with a &#39;/&#39;<br>&gt;&gt; &gt;  # (<a href="https://github.com/mesonbuild/meson/issues/1564">https://github.com/mesonbuild/meson/issues/1564</a>)<br>&gt;&gt; &gt; +rst_sanitize_cmd = [find_program(&#39;../../scripts/rst-sanitize.py&#39;), &#39;@INPUT@&#39;]<br>&gt;&gt; &gt;  qapi_doc_out_nocr = custom_target(&#39;QAPI rST doc newline-sanitized&#39;,<br>&gt;&gt; &gt;                                    output: [&#39;doc-good.txt.nocr&#39;],<br>&gt;&gt; &gt;                                    input: qapi_doc_out[0],<br>&gt;&gt; &gt;                                    build_by_default: build_docs,<br>&gt;&gt; &gt; -                                  command: [&#39;perl&#39;, &#39;-pe&#39;, &#39;$x = chr 13; s/$x$//&#39;, &#39;@INPUT@&#39;],<br>&gt;&gt; &gt; +                                  command: rst_sanitize_cmd,<br>&gt;&gt; &gt;                                    capture: true)<br>&gt;&gt; &gt;<br>&gt;&gt; &gt;  qapi_doc_ref_nocr = custom_target(&#39;QAPI rST doc reference newline-sanitized&#39;,<br>&gt;&gt; &gt;                                    output: [&#39;doc-good.ref.nocr&#39;],<br>&gt;&gt; &gt;                                    input: files(&#39;doc-good.txt&#39;),<br>&gt;&gt; &gt;                                    build_by_default: build_docs,<br>&gt;&gt; &gt; -                                  command: [&#39;perl&#39;, &#39;-pe&#39;, &#39;$x = chr 13; s/$x$//&#39;, &#39;@INPUT@&#39;],<br>&gt;&gt; &gt; +                                  command: rst_sanitize_cmd,<br>&gt;&gt; &gt;                                    capture: true)<br>&gt;&gt;<br>&gt;&gt; thanks<br>&gt;&gt; -- PMM<br>&gt;&gt;<br><br><br>--<br>         此致<br>礼<br>罗勇刚<br>Yours<br>    sincerely,<br>Yonggang Luo</div>
diff mbox series

Patch

diff --git a/docs/conf.py b/docs/conf.py
index 00e1b750e2..e584f68393 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -241,7 +241,7 @@  texinfo_documents = [
 # We use paths starting from qemu_docdir here so that you can run
 # sphinx-build from anywhere and the kerneldoc extension can still
 # find everything.
-kerneldoc_bin = os.path.join(qemu_docdir, '../scripts/kernel-doc')
+kerneldoc_bin = ['perl', os.path.join(qemu_docdir, '../scripts/kernel-doc')]
 kerneldoc_srctree = os.path.join(qemu_docdir, '..')
 hxtool_srctree = os.path.join(qemu_docdir, '..')
 qapidoc_srctree = os.path.join(qemu_docdir, '..')
diff --git a/docs/sphinx/kerneldoc.py b/docs/sphinx/kerneldoc.py
index 3e87940206..3ac277d162 100644
--- a/docs/sphinx/kerneldoc.py
+++ b/docs/sphinx/kerneldoc.py
@@ -67,7 +67,7 @@  class KernelDocDirective(Directive):
 
     def run(self):
         env = self.state.document.settings.env
-        cmd = [env.config.kerneldoc_bin, '-rst', '-enable-lineno']
+        cmd = env.config.kerneldoc_bin + ['-rst', '-enable-lineno']
 
         filename = env.config.kerneldoc_srctree + '/' + self.arguments[0]
         export_file_patterns = []
diff --git a/scripts/rst-sanitize.py b/scripts/rst-sanitize.py
new file mode 100644
index 0000000000..26060f1208
--- /dev/null
+++ b/scripts/rst-sanitize.py
@@ -0,0 +1,21 @@ 
+#!/usr/bin/env python3
+
+#
+# Script for remove cr line ending in file
+#
+# Authors:
+#  Yonggang Luo <luoyonggang@gmail.com>
+#
+# This work is licensed under the terms of the GNU GPL, version 2
+# or, at your option, any later version.  See the COPYING file in
+# the top-level directory.
+
+import sys
+
+def main(_program, file, *unused):
+    with open(file, 'rb') as content_file:
+        content = content_file.read()
+        sys.stdout.buffer.write(content.replace(b'\r', b''))
+
+if __name__ == "__main__":
+    main(*sys.argv)
diff --git a/tests/qapi-schema/meson.build b/tests/qapi-schema/meson.build
index 1f222a7a13..20a7641af8 100644
--- a/tests/qapi-schema/meson.build
+++ b/tests/qapi-schema/meson.build
@@ -251,18 +251,19 @@  qapi_doc_out = custom_target('QAPI rST doc',
 # 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)
+rst_sanitize_cmd = [find_program('../../scripts/rst-sanitize.py'), '@INPUT@']
 qapi_doc_out_nocr = custom_target('QAPI rST doc newline-sanitized',
                                   output: ['doc-good.txt.nocr'],
                                   input: qapi_doc_out[0],
                                   build_by_default: build_docs,
-                                  command: ['perl', '-pe', '$x = chr 13; s/$x$//', '@INPUT@'],
+                                  command: rst_sanitize_cmd,
                                   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: build_docs,
-                                  command: ['perl', '-pe', '$x = chr 13; s/$x$//', '@INPUT@'],
+                                  command: rst_sanitize_cmd,
                                   capture: true)
 
 if build_docs