diff mbox series

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

Message ID 20201015201035.1964-2-luoyonggang@gmail.com (mailing list archive)
State New, archived
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
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
>
>
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
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