Skip to contentSkip to conversation

Improve cirrus msys2

PATCH In review Yonggang Luo 3 participants 9 messages Oct 12, 2020 – Oct 13, 2020 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

v7 cover Improve cirrus msys2

Fixes the broken msys2/mingw ci and speed it up.

V6-V7
* cirrus: Enable doc build on msys2/mingw
* docs: Fixes build docs on msys2/mingw
* gitignore: ignore a bit more
* scripts: Convert qemu-version.sh to qemu-version.py

V5-V6
Remove the university mirror, the main repo are back. rename to setup_script.
Add fixes for msys2/mingw rST document fixes

V4-V5
Now the cache are usefull by using 7zip to archive msys64 Saved about 18min, compare
https://cirrus-ci.com/task/5093551157542912
https://cirrus-ci.com/task/6177196538593280

V3-V4
Using cirrus cache to speed up msys2 ci instead of downloading archive file

V2-V3
Add one more patch:
cirrus: msys2/mingw speed is up, add excluded target back Do not build sphinx on windows, that's failing set the number of parallel count to fixed number 8

V1-V2
Resolve the cirrus conflict

Yonggang Luo (4):
scripts: Convert qemu-version.sh to qemu-version.py
gitignore: ignore a bit more
docs: Fixes build docs on msys2/mingw
cirrus: Enable doc build on msys2/mingw

 .cirrus.yml                   |  6 +++++-
 .gitignore                    |  4 +++-
 docs/conf.py                  |  2 +-
 docs/sphinx/kerneldoc.py      |  2 +-
 meson.build                   |  2 +-
 scripts/qemu-version.py       | 37 +++++++++++++++++++++++++++++++++++
 scripts/qemu-version.sh       | 25 -----------------------
 scripts/rst-sanitize.py       | 21 ++++++++++++++++++++
 tests/qapi-schema/meson.build |  5 +++--
 9 files changed, 72 insertions(+), 32 deletions(-)
 create mode 100644 scripts/qemu-version.py
 delete mode 100755 scripts/qemu-version.sh
 create mode 100644 scripts/rst-sanitize.py
Signature · 1 line
2.28.0.windows.1
#1 lore raw

PATCH v7 1/4 scripts: Convert qemu-version.sh to qemu-version.py

The sh script are harder to maintain for compatible different xsh environment so convert it to python script
Also incorporate the fixes in
https://patchew.org/QEMU/[email protected]/

According to https://github.com/msys2/MSYS2-packages/issues/2176
We need use CYGWIN=noglob and MSYS=noglob in the environment variable for disable wildcard expanding in msys or cygwin git, and setting the shell=False

Message-Id: <[email protected]>

---
 meson.build             |  2 +-
 scripts/qemu-version.py | 37 +++++++++++++++++++++++++++++++++++++
 scripts/qemu-version.sh | 25 -------------------------
 3 files changed, 38 insertions(+), 26 deletions(-)
 create mode 100644 scripts/qemu-version.py
 delete mode 100755 scripts/qemu-version.sh
meson.build +1 -1
index 17c89c87c6..c23167c61b 100644
@@ -1132,7 +1132,7 @@ tracetool = [
    '--backend=' + config_host['TRACE_BACKENDS']
 ]
 
-qemu_version_cmd = [find_program('scripts/qemu-version.sh'),
+qemu_version_cmd = [find_program('scripts/qemu-version.py'),
                     meson.current_source_dir(),
                     config_host['PKGVERSION'], meson.project_version()]
 qemu_version = custom_target('qemu-version.h',
scripts/qemu-version.py new file +37 -0
new file mode 100644
index 0000000000..cf97b2bbb5
@@ -0,0 +1,37 @@
+#!/usr/bin/env python3
+
+#
+# Script for retrieve qemu git version information
+#
+# 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
+import subprocess
+import os
+import os.path
+
+def main(_program, dir, pkgversion, version, *unused):
+    os.chdir(dir)
+    if not pkgversion and os.path.exists('.git'):
+        pc = subprocess.run(
+            ['git', 'describe', '--match', 'v*', '--dirty', '--always'],
+            env=dict(os.environ, CYGWIN="noglob", MSYS='noglob'),
+            stdout=subprocess.PIPE, stderr=subprocess.DEVNULL,
+            encoding='utf8', shell=False)
+        if pc.returncode == 0:
+            pkgversion = pc.stdout.strip()
+
+    fullversion = version
+    if pkgversion:
+        fullversion = "{} ({})".format(version, pkgversion)
+
+    print('#define QEMU_PKGVERSION "%s"' % pkgversion)
+    print('#define QEMU_FULL_VERSION "%s"' % fullversion)
+
+if __name__ == "__main__":
+    main(*sys.argv)
scripts/qemu-version.sh deleted +0 -25
deleted file mode 100755
index 03128c56a2..0000000000
@@ -1,25 +0,0 @@
-#!/bin/sh
-
-set -eu
-
-dir="$1"
-pkgversion="$2"
-version="$3"
-
-if [ -z "$pkgversion" ]; then
-    cd "$dir"
-    if [ -e .git ]; then
-        pkgversion=$(git describe --match 'v*' --dirty | echo "")
-    fi
-fi
-
-if [ -n "$pkgversion" ]; then
-    fullversion="$version ($pkgversion)"
-else
-    fullversion="$version"
-fi
-
-cat <<EOF
-#define QEMU_PKGVERSION "$pkgversion"
-#define QEMU_FULL_VERSION "$fullversion"
-EOF
Signature · 1 line
2.28.0.windows.1
#2 lore raw

PATCH v7 2/4 gitignore: ignore a bit more

In reply to Yonggang Luo

Enable the creating multiple build directory at the source root. Ignore /meson/ and /roms/ for better search experience.

---
 .gitignore | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
.gitignore +3 -1
index b32bca1315..f78ee9f297 100644
@@ -1,5 +1,5 @@
 /GNUmakefile
-/build/
+/build*/
 *.pyc
 .sdk
 .stgit-*
@@ -10,3 +10,5 @@ TAGS
 *~
 *.ast_raw
 *.depend_raw
+/meson/
+/roms/**/*
Signature · 1 line
2.28.0.windows.1
#3 lore raw

Re: [PATCH v7 2/4] gitignore: ignore a bit more

Quoted 20 lines · Yonggang Luo

Enable the creating multiple build directory at the source root. Ignore /meson/ and /roms/ for better search experience.

---
  .gitignore | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
.gitignore +1 -1
index b32bca1315..f78ee9f297 100644
@@ -1,5 +1,5 @@
  /GNUmakefile
-/build/
+/build*/
  *.pyc
  .sdk
  .stgit-*

.gitignore TAGS · line 14

Quoted 5 lines
.gitignore +2 -0
@@ -10,3 +10,5 @@ TAGS
  *~
  *.ast_raw
  *.depend_raw
+/meson/
+/roms/**/*

Why?

#4 lore raw

Re: [PATCH v7 2/4] gitignore: ignore a bit more

Quoted 21 lines · Philippe Mathieu-Daudé
Quoted 19 lines · Yonggang Luo

Enable the creating multiple build directory at the source root. Ignore /meson/ and /roms/ for better search experience.

---
  .gitignore | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
.gitignore +1 -1
index b32bca1315..f78ee9f297 100644
@@ -1,5 +1,5 @@
  /GNUmakefile
-/build/
+/build*/
  *.pyc
  .sdk
  .stgit-*
Quoted 8 lines

.gitignore TAGS · line 14

Quoted 6 lines
.gitignore +2 -0
@@ -10,3 +10,5 @@ TAGS
  *~
  *.ast_raw
  *.depend_raw
+/meson/
+/roms/**/*

Why?

As I said, help for searching tool ignore it, meson and roms are thirdparty packages.

Quoted 1 line

--
此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo

#5 lore raw

Re: [PATCH v7 2/4] gitignore: ignore a bit more

Quoted 15 lines · 罗勇刚(Yonggang Luo)
Quoted 6 lines · On Tue, Oct 13, 2020 at 4:38 PM Philippe Mathieu-Daudé <[email protected]…
Quoted 4 lines · Yonggang Luo

Enable the creating multiple build directory at the source root. Ignore /meson/ and /roms/ for better search experience.

<mailto:[email protected]>>

Quoted 4 lines
Quoted 4 lines

---
  .gitignore | 4 +++-

  1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 8 lines
Quoted 8 lines

.gitignore line 2

Quoted 8 lines
.gitignore +0 -0
index b32bca1315..f78ee9f297 100644
@@ -1,5 +1,5 @@

  /GNUmakefile

.gitignore +1 -1
-/build/
+/build*/

The naming of your private build directories is IMHO something that should not be part of the public .gitignore file. I think you can use your ~/.gitignore file for that.

Quoted 11 lines
Quoted 11 lines

.gitignore TAGS · line 14

Quoted 9 lines

  *.pyc
  .sdk
  .stgit-*

.gitignore +2 -0
@@ -10,3 +10,5 @@ TAGS
   *~
   *.ast_raw
   *.depend_raw
+/meson/
+/roms/**/*

Why?

Quoted 2 lines

As I said, help for searching tool ignore it, meson and roms are thirdparty packages.

Hmm, but "git status" should still show whether there are modifications in the subdirectories, so IMHO this should not be ignored?

Thomas

#6 lore raw

Re: [PATCH v7 2/4] gitignore: ignore a bit more

Quoted 5 lines · Thomas Huth
Quoted 3 lines · 罗勇刚(Yonggang Luo)

On Tue, Oct 13, 2020 at 4:38 PM Philippe Mathieu-Daudé <

[email protected]

Quoted 12 lines
Quoted 12 lines
Quoted 6 lines · <mailto:[email protected]>> wrote:
Quoted 4 lines · Yonggang Luo

Enable the creating multiple build directory at the source root. Ignore /meson/ and /roms/ for better search experience.

<mailto:[email protected]>>

Quoted 4 lines
Quoted 4 lines
---
  .gitignore | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 25 lines
Quoted 8 lines
Quoted 8 lines

.gitignore line 2

Quoted 8 lines
.gitignore +1 -1
index b32bca1315..f78ee9f297 100644
@@ -1,5 +1,5 @@
  /GNUmakefile
-/build/
+/build*/

The naming of your private build directories is IMHO something that should not be part of the public .gitignore file. I think you can use your ~/.gitignore file for that.

Quoted 12 lines
Quoted 11 lines

.gitignore TAGS · line 14

Quoted 9 lines
.gitignore +2 -0
  *.pyc
  .sdk
  .stgit-*
@@ -10,3 +10,5 @@ TAGS
  *~
  *.ast_raw
  *.depend_raw
+/meson/
+/roms/**/*

Why?

As I said, help for searching tool ignore it, meson and roms are

thirdparty

Quoted 4 lines
Quoted 1 line

packages.

Hmm, but "git status" should still show whether there are modifications in the subdirectories, so IMHO this should not be ignored?

Yeap, it's doens't affect git, just affect search tools. If this is improper, skip it, I can use it locally

Quoted 3 lines

Thomas

--
此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo

#7 lore raw

PATCH v7 3/4 docs: Fixes build docs on msys2/mingw

In reply to Yonggang Luo
---
 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 1f222a7a13..20a7641af8 100644
@@ -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
Signature · 1 line
2.28.0.windows.1
#8 lore raw

PATCH v7 4/4 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.
Remove the need of university mirror, the main repo are recovered.

---
 .cirrus.yml | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
.cirrus.yml +5 -1
index 99d118239c..f42ccb956a 100644
@@ -76,7 +76,6 @@ windows_msys2_task:
         ((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"
-        C:\tools\msys64\usr\bin\bash.exe -lc "grep -rl 'repo.msys2.org/' /etc/pacman.d/mirrorlist.* | xargs sed -i 's/repo.msys2.org\//mirrors.tuna.tsinghua.edu.cn\/msys2\//g'"
         C:\tools\msys64\usr\bin\pacman.exe --noconfirm -Sy
         echo Y | C:\tools\msys64\usr\bin\pacman.exe --noconfirm -Suu --overwrite=*
         taskkill /F /FI "MODULES eq msys-2.0.dll"
@@ -111,6 +110,11 @@ windows_msys2_task:
           mingw-w64-x86_64-curl \
           mingw-w64-x86_64-gnutls \
           "
+        bitsadmin /transfer msys_download /dynamic /download /priority FOREGROUND `
+          https://repo.msys2.org/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