Skip to contentSkip to conversation

Fixes docs building on msys2/mingw

PATCH Superseded Yonggang Luo 2 participants 4 messages Oct 8, 2020 – Oct 9, 2020 Arm/Amlogic Meson SoC support

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover Fixes docs building on msys2/mingw

The cirrus are based on non-merged patches

Yonggang Luo (2):
docs: Fixes build docs on msys2/mingw
cirrus: Enable doc build on msys2/mingw

 .cirrus.yml                   |  8 ++++++++
 docs/conf.py                  |  2 +-
 docs/sphinx/kerneldoc.py      |  2 +-
 scripts/rst-sanitize.py       | 21 +++++++++++++++++++++
 tests/qapi-schema/meson.build |  5 +++--
 5 files changed, 34 insertions(+), 4 deletions(-)
 create mode 100644 scripts/rst-sanitize.py
Signature · 1 line
2.28.0.windows.1
#1 lore raw

PATCH 1/2 docs: Fixes build docs on msys2/mingw

---
 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
docs/conf.py +1 -1
index 00e1b750e2..e584f68393 100644
@@ -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, '..')
docs/sphinx/kerneldoc.py +1 -1
index 3e87940206..3ac277d162 100644
@@ -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 = []
scripts/rst-sanitize.py new file +21 -0
new file mode 100644
index 0000000000..26060f1208
@@ -0,0 +1,21 @@
+#!/usr/bin/env python3
+
+#
+# Script for remove cr line ending in file
+#
+# Authors:
+#  Yonggang Luo <[email protected]>
+#
+# 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)
tests/qapi-schema/meson.build +3 -2
index f08c902911..a6832634b3 100644
@@ -250,18 +250,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
Signature · 1 line
2.28.0.windows.1
#2 lore raw

PATCH 2/2 cirrus: Enable doc build on msys2/mingw

In reply to Yonggang Luo

Currently rST depends on old version sphinx-2.x.
Install it by downloading it.

---
 .cirrus.yml | 8 ++++++++
 1 file changed, 8 insertions(+)
.cirrus.yml +8 -0
index 77cfd99afe..b1725bd0c1 100644
@@ -73,6 +73,7 @@ windows_msys2_task:
         bitsadmin /transfer msys_download /dynamic /download /priority FOREGROUND https://github.com/msys2/msys2-installer/releases/download/2020-09-03/msys2-base-x86_64-20200903.sfx.exe C:\tools\base.exe
         Write-Output "Download time taken: $((Get-Date).Subtract($start_time).Seconds) second(s)"
         C:\tools\base.exe -y
+        del C:\tools\base.exe
         ((Get-Content -path C:\tools\msys64\etc\\post-install\\07-pacman-key.post -Raw) -replace '--refresh-keys', '--version') | Set-Content -Path C:\tools\msys64\etc\\post-install\\07-pacman-key.post
         C:\tools\msys64\usr\bin\bash.exe -lc "sed -i 's/^CheckSpace/#CheckSpace/g' /etc/pacman.conf"
         C:\tools\msys64\usr\bin\bash.exe -lc "export"
@@ -112,6 +113,13 @@ windows_msys2_task:
           mingw-w64-x86_64-gnutls \
           mingw-w64-x86_64-libnfs \
           "
+        bitsadmin /transfer msys_download /dynamic /download /priority FOREGROUND `
+          https://mirrors.tuna.tsinghua.edu.cn/msys2/mingw/x86_64/mingw-w64-x86_64-python-sphinx-2.3.1-1-any.pkg.tar.xz `
+          C:\tools\mingw-w64-x86_64-python-sphinx-2.3.1-1-any.pkg.tar.xz
+        C:\tools\msys64\usr\bin\bash.exe -lc "pacman --noconfirm -U \
+          /c/tools/mingw-w64-x86_64-python-sphinx-2.3.1-1-any.pkg.tar.xz
+          "
+        del C:\tools\mingw-w64-x86_64-python-sphinx-2.3.1-1-any.pkg.tar.xz
         C:\tools\msys64\usr\bin\bash.exe -lc "rm -rf /var/cache/pacman/pkg/*"
         cd C:\tools\msys64
         echo "Start archive"
Signature · 1 line
2.28.0.windows.1
#3 lore raw

Re: [PATCH 2/2] cirrus: Enable doc build on msys2/mingw

Quoted 21 lines · Yonggang Luo

Currently rST depends on old version sphinx-2.x.
Install it by downloading it.

---
 .cirrus.yml | 8 ++++++++
 1 file changed, 8 insertions(+)
.cirrus.yml +1 -0
index 77cfd99afe..b1725bd0c1 100644
@@ -73,6 +73,7 @@ windows_msys2_task:
         bitsadmin /transfer msys_download /dynamic /download /priority FOREGROUND https://github.com/msys2/msys2-installer/releases/download/2020-09-03/msys2-base-x86_64-20200903.sfx.exe C:\tools\base.exe
         Write-Output "Download time taken: $((Get-Date).Subtract($start_time).Seconds) second(s)"
         C:\tools\base.exe -y
+        del C:\tools\base.exe
         ((Get-Content -path C:\tools\msys64\etc\\post-install\\07-pacman-key.post -Raw) -replace '--refresh-keys', '--version') | Set-Content -Path C:\tools\msys64\etc\\post-install\\07-pacman-key.post
         C:\tools\msys64\usr\bin\bash.exe -lc "sed -i 's/^CheckSpace/#CheckSpace/g' /etc/pacman.conf"
         C:\tools\msys64\usr\bin\bash.exe -lc "export"

.cirrus.yml windows_msys2_task: · line 117

Quoted 5 lines
.cirrus.yml +2 -0
@@ -112,6 +113,13 @@ windows_msys2_task:
           mingw-w64-x86_64-gnutls \
           mingw-w64-x86_64-libnfs \
           "
+        bitsadmin /transfer msys_download /dynamic /download /priority FOREGROUND `
+          https://mirrors.tuna.tsinghua.edu.cn/msys2/mingw/x86_64/mingw-w64-x86_64-python-sphinx-2.3.1-1-any.pkg.tar.xz `

Relying on some random university mirror site is not a nice approach IMHO. Why isn't this using the official msys2 site like the other packages ?

.cirrus.yml windows_msys2_task: · line 125

Quoted 8 lines
.cirrus.yml +5 -0
+          C:\tools\mingw-w64-x86_64-python-sphinx-2.3.1-1-any.pkg.tar.xz
+        C:\tools\msys64\usr\bin\bash.exe -lc "pacman --noconfirm -U \
+          /c/tools/mingw-w64-x86_64-python-sphinx-2.3.1-1-any.pkg.tar.xz
+          "
+        del C:\tools\mingw-w64-x86_64-python-sphinx-2.3.1-1-any.pkg.tar.xz
         C:\tools\msys64\usr\bin\bash.exe -lc "rm -rf /var/cache/pacman/pkg/*"
         cd C:\tools\msys64
         echo "Start archive"

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|