Skip to contentSkip to conversation

Fixes docs building on msys2/mingw

PATCH Superseded Yonggang Luo 2 participants 14 messages Oct 15, 2020 – Oct 16, 2020 Arm/Amlogic Meson SoC support

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover Fixes docs building on msys2/mingw

V3-V4
Quic fixes of
python style
if xxx:

tested locally

V2-V3
No need convert perl trick to python script anymore after Paolo's removal of ninjatool.
Revise Meson: Move the detection logic for sphinx to meson for pass other platform by letting SPHINX_ARGS to be empty when build_docs are false

v1 - v2
Also move the docs configure part from
configure to meson, this also fixed the pending
ninjatool removal caused issue that docs can
not be build under msys2/mingw

Yonggang Luo (4):
docs: Fixes build docs on msys2/mingw
configure: the docdir option should passed to meson as is.
meson: Move the detection logic for sphinx to meson
cirrus: Enable doc build on msys2/mingw

 .cirrus.yml                   |  6 +++-
 configure                     | 62 +++--------------------------------
 docs/conf.py                  |  2 +-
 docs/meson.build              |  4 +--
 docs/sphinx/kerneldoc.py      |  2 +-
 meson.build                   | 60 +++++++++++++++++++++++++++++----
 meson_options.txt             |  5 ++-
 tests/qapi-schema/meson.build |  2 +-
 8 files changed, 72 insertions(+), 71 deletions(-)
Signature · 1 line
2.28.0.windows.1
#1 lore raw

PATCH v4 1/4 docs: Fixes build docs on msys2/mingw

meson didn't support running ../scripts/kernel-do directly

---
 docs/conf.py             | 2 +-
 docs/sphinx/kerneldoc.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
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 = []
Signature · 1 line
2.28.0.windows.1
#2 lore raw

Re: [PATCH v4 1/4] docs: Fixes build docs on msys2/mingw

Il ven 16 ott 2020, 00:06 Yonggang Luo <[email protected]> ha scritto:

Quoted 2 lines

meson didn't support running ../scripts/kernel-do directly

Can you explain why this matters? Meson does not look at docs/conf.py.

Paolo

Quoted 37 lines
---
 docs/conf.py             | 2 +-
 docs/sphinx/kerneldoc.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
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 -2
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 = []
--

2.28.0.windows.1

#3 lore raw

Re: [PATCH v4 1/4] docs: Fixes build docs on msys2/mingw

Quoted 19 lines · Paolo Bonzini

Il ven 16 ott 2020, 00:06 Yonggang Luo <[email protected]> ha scritto:

Quoted 2 lines

meson didn't support running ../scripts/kernel-do directly

Can you explain why this matters? Meson does not look at docs/conf.py.

Paolo

Quoted 7 lines
---
 docs/conf.py             | 2 +-
 docs/sphinx/kerneldoc.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Quoted 10 lines

docs/conf.py texinfo_documents = [ · line 244

Quoted 10 lines
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')]

Quoted 9 lines
Quoted 9 lines
docs/conf.py +0 -0
 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 +0 -0
index 3e87940206..3ac277d162 100644
@@ -67,7 +67,7 @@ class KernelDocDirective(Directive):
 
Quoted 4 lines

docs/sphinx/kerneldoc.py class KernelDocDirective(Directive): · line 70

Quoted 4 lines
docs/sphinx/kerneldoc.py +1 -1
     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']

meson use the conf directly

Quoted 2 lines

docs/sphinx/kerneldoc.py class KernelDocDirective(Directive): · line 71

Quoted 2 lines
docs/sphinx/kerneldoc.py +0 -0
         filename = env.config.kerneldoc_srctree + '/' +

self.arguments[0]

Quoted 4 lines
Quoted 4 lines
docs/sphinx/kerneldoc.py +0 -1
         export_file_patterns = []
--

2.28.0.windows.1

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

#4 lore raw

PATCH v4 2/4 configure: the docdir option should passed to meson as is.

In reply to Yonggang Luo
---
 configure | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
configure +1 -2
index f839c2a557..1ce31f97b4 100755
@@ -971,7 +971,7 @@ for opt do
   ;;
   --with-suffix=*) qemu_suffix="$optarg"
   ;;
-  --docdir=*) qemu_docdir="$optarg"
+  --docdir=*) docdir="$optarg"
   ;;
   --sysconfdir=*) sysconfdir="$optarg"
   ;;
@@ -5770,7 +5770,6 @@ fi
 qemu_confdir="$sysconfdir/$qemu_suffix"
 qemu_moddir="$libdir/$qemu_suffix"
 qemu_datadir="$datadir/$qemu_suffix"
-qemu_docdir="$docdir/$qemu_suffix"
 qemu_localedir="$datadir/locale"
 qemu_icondir="$datadir/icons"
 qemu_desktopdir="$datadir/applications"
Signature · 1 line
2.28.0.windows.1
#5 lore raw

PATCH v4 3/4 meson: Move the detection logic for sphinx to meson

In reply to Yonggang Luo
---
 configure                     | 59 +++-------------------------------
 docs/meson.build              |  4 +--
 meson.build                   | 60 +++++++++++++++++++++++++++++++----
 meson_options.txt             |  5 ++-
 tests/qapi-schema/meson.build |  2 +-
 5 files changed, 64 insertions(+), 66 deletions(-)
configure +4 -55
index 1ce31f97b4..ff593a8542 100755
@@ -297,7 +297,7 @@ brlapi=""
 curl=""
 iconv="auto"
 curses="auto"
-docs=""
+docs="auto"
 fdt="auto"
 netmap="no"
 sdl="auto"
@@ -822,15 +822,6 @@ do
     fi
 done
 
-sphinx_build=
-for binary in sphinx-build-3 sphinx-build
-do
-    if has "$binary"
-    then
-        sphinx_build=$(command -v "$binary")
-        break
-    fi
-done
 
 # Check for ancillary tools used in testing
 genisoimage=
@@ -1226,9 +1217,9 @@ for opt do
   ;;
   --disable-crypto-afalg) crypto_afalg="no"
   ;;
-  --disable-docs) docs="no"
+  --disable-docs) docs="disabled"
   ;;
-  --enable-docs) docs="yes"
+  --enable-docs) docs="enabled"
   ;;
   --disable-vhost-net) vhost_net="no"
   ;;
@@ -4413,45 +4404,6 @@ if check_include linux/btrfs.h ; then
     btrfs=yes
 fi
 
-# If we're making warnings fatal, apply this to Sphinx runs as well
-sphinx_werror=""
-if test "$werror" = "yes"; then
-    sphinx_werror="-W"
-fi
-
-# Check we have a new enough version of sphinx-build
-has_sphinx_build() {
-    # This is a bit awkward but works: create a trivial document and
-    # try to run it with our configuration file (which enforces a
-    # version requirement). This will fail if either
-    # sphinx-build doesn't exist at all or if it is too old.
-    mkdir -p "$TMPDIR1/sphinx"
-    touch "$TMPDIR1/sphinx/index.rst"
-    "$sphinx_build" $sphinx_werror -c "$source_path/docs" \
-                    -b html "$TMPDIR1/sphinx" \
-                    "$TMPDIR1/sphinx/out"  >> config.log 2>&1
-}
-
-# Check if tools are available to build documentation.
-if test "$docs" != "no" ; then
-  if has_sphinx_build; then
-    sphinx_ok=yes
-  else
-    sphinx_ok=no
-  fi
-  if test "$sphinx_ok" = "yes"; then
-    docs=yes
-  else
-    if test "$docs" = "yes" ; then
-      if has $sphinx_build && test "$sphinx_ok" != "yes"; then
-        echo "Warning: $sphinx_build exists but it is either too old or uses too old a Python version" >&2
-      fi
-      feature_not_found "docs" "Install a Python 3 version of python-sphinx"
-    fi
-    docs=no
-  fi
-fi
-
 # Search for bswap_32 function
 byteswap_h=no
 cat > $TMPC << EOF
@@ -6087,9 +6039,6 @@ qemu_version=$(head $source_path/VERSION)
 echo "PKGVERSION=$pkgversion" >>$config_host_mak
 echo "SRC_PATH=$source_path" >> $config_host_mak
 echo "TARGET_DIRS=$target_list" >> $config_host_mak
-if [ "$docs" = "yes" ] ; then
-  echo "BUILD_DOCS=yes" >> $config_host_mak
-fi
 if test "$modules" = "yes"; then
   # $shacmd can generate a hash started with digit, which the compiler doesn't
   # like as an symbol. So prefix it with an underscore
@@ -6794,7 +6743,6 @@ fi
 echo "ROMS=$roms" >> $config_host_mak
 echo "MAKE=$make" >> $config_host_mak
 echo "PYTHON=$python" >> $config_host_mak
-echo "SPHINX_BUILD=$sphinx_build" >> $config_host_mak
 echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
 echo "MESON=$meson" >> $config_host_mak
 echo "CC=$cc" >> $config_host_mak
@@ -7076,6 +7024,7 @@ NINJA=${ninja:-$PWD/ninjatool} $meson setup \
         -Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f \
         -Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt \
         -Diconv=$iconv -Dcurses=$curses \
+        -Ddocs=$docs -Dsphinx_build=$sphinx_build \
         $cross_arg \
         "$PWD" "$source_path"
 
docs/meson.build +2 -2
index 0340d489ac..f566809a6a 100644
@@ -37,7 +37,7 @@ if build_docs
                 input: [files('conf.py'), files(manual / 'conf.py')],
                 depfile: manual + '.d',
                 depend_files: sphinx_extn_depends,
-                command: [SPHINX_ARGS, '-Ddepfile=@DEPFILE@',
+                command: SPHINX_ARGS + ['-Ddepfile=@DEPFILE@',
                           '-Ddepfile_stamp=@OUTPUT0@',
                           '-b', 'html', '-d', private_dir,
                           input_dir, output_dir])
@@ -59,7 +59,7 @@ if build_docs
                          input: this_manual,
                          install: build_docs,
                          install_dir: install_dirs,
-                         command: [SPHINX_ARGS, '-b', 'man', '-d', private_dir,
+                         command: SPHINX_ARGS + ['-b', 'man', '-d', private_dir,
                                    input_dir, meson.current_build_dir()])
     endif
   endforeach
meson.build +53 -7

86 lines not on this page · raw message

meson_options.txt +4 -1
index e6cb1e589b..0e3fa7136b 100644
@@ -1,8 +1,11 @@
 option('qemu_suffix', type : 'string', value: 'qemu',
        description: 'Suffix for QEMU data/modules/config directories (can be empty)')
+option('docs', type : 'feature', value : 'auto',
+       description: 'Documentations build support')
 option('docdir', type : 'string', value : 'doc',
        description: 'Base directory for documentation installation (can be empty)')
-
+option('sphinx_build', type : 'string', value : '',
+       description: 'Use specified sphinx-build [$sphinx_build] for building document (default to be empty)')
 option('gettext', type : 'boolean', value : true,
        description: 'Localization of the GTK+ user interface')
 option('sparse', type : 'feature', value : 'auto',
tests/qapi-schema/meson.build +1 -1
index 1f222a7a13..961b8367a9 100644
@@ -237,7 +237,7 @@ qapi_doc_out = custom_target('QAPI rST doc',
                              # we want it to always really run the QAPI doc
                              # generation code. It also means we don't
                              # clutter up the build dir with the cache.
-                             command: [SPHINX_ARGS,
+                             command:  SPHINX_ARGS + [
                                        '-b', 'text', '-E',
                                        '-c', meson.source_root() / 'docs',
                                        '-D', 'master_doc=doc-good',
Signature · 1 line
2.28.0.windows.1
#6 lore raw

Re: [PATCH v4 3/4] meson: Move the detection logic for sphinx to meson

Here is a better way to write the meson test:

if get_option('sphinx_build') == ''
sphinx_build = find_program(['sphinx-build-3', 'sphinx-build'],
required: get_option('docs'))
else
sphinx_build = find_program(get_option('sphinx_build'),
required: get_option('docs'))
endif

SPHINX_ARGS = [sphinx_build]
# If we're making warnings fatal, apply this to Sphinx runs as well if get_option('werror')
SPHINX_TEST_ARGS += [ '-W' ]
endif

# Check if tools are available to build documentation. build_docs = false
if sphinx_build.found()
# This is a bit awkward but works: create a trivial document and

  # try to run it with our configuration file (which enforces a
  # version requirement). This will fail if sphinx-build is too old.
  run_command('mkdir', ['-p', tmpdir / 'sphinx'])
  run_command('touch', [tmpdir / 'sphinx/index.rst'])
  sphinx_build_test_out = run_command(SPHINX_ARGS + [
    '-c', meson.current_source_dir() / 'docs',
    '-b', 'html', tmpdir / 'sphinx',
    tmpdir / 'sphinx/out'])
  build_docs = (sphinx_build_test_out.returncode() == 0)
endif

if not build_docs
if sphinx_build_option != ''
warning('@0@ exists but it is either too old or uses too old a Python version'.format(sphinx_build_option))
endif
if get_option('docs').enabled()
error('Install a Python 3 version of python-sphinx')
endif
endif

Quoted 269 lines · Yonggang Luo
---
 configure                     | 59 +++-------------------------------
 docs/meson.build              |  4 +--
 meson.build                   | 60 +++++++++++++++++++++++++++++++----
 meson_options.txt             |  5 ++-
 tests/qapi-schema/meson.build |  2 +-
 5 files changed, 64 insertions(+), 66 deletions(-)
configure +4 -55
index 1ce31f97b4..ff593a8542 100755
@@ -297,7 +297,7 @@ brlapi=""
 curl=""
 iconv="auto"
 curses="auto"
-docs=""
+docs="auto"
 fdt="auto"
 netmap="no"
 sdl="auto"
@@ -822,15 +822,6 @@ do
     fi
 done
 
-sphinx_build=
-for binary in sphinx-build-3 sphinx-build
-do
-    if has "$binary"
-    then
-        sphinx_build=$(command -v "$binary")
-        break
-    fi
-done
 
 # Check for ancillary tools used in testing
 genisoimage=
@@ -1226,9 +1217,9 @@ for opt do
   ;;
   --disable-crypto-afalg) crypto_afalg="no"
   ;;
-  --disable-docs) docs="no"
+  --disable-docs) docs="disabled"
   ;;
-  --enable-docs) docs="yes"
+  --enable-docs) docs="enabled"
   ;;
   --disable-vhost-net) vhost_net="no"
   ;;
@@ -4413,45 +4404,6 @@ if check_include linux/btrfs.h ; then
     btrfs=yes
 fi
 
-# If we're making warnings fatal, apply this to Sphinx runs as well
-sphinx_werror=""
-if test "$werror" = "yes"; then
-    sphinx_werror="-W"
-fi
-
-# Check we have a new enough version of sphinx-build
-has_sphinx_build() {
-    # This is a bit awkward but works: create a trivial document and
-    # try to run it with our configuration file (which enforces a
-    # version requirement). This will fail if either
-    # sphinx-build doesn't exist at all or if it is too old.
-    mkdir -p "$TMPDIR1/sphinx"
-    touch "$TMPDIR1/sphinx/index.rst"
-    "$sphinx_build" $sphinx_werror -c "$source_path/docs" \
-                    -b html "$TMPDIR1/sphinx" \
-                    "$TMPDIR1/sphinx/out"  >> config.log 2>&1
-}
-
-# Check if tools are available to build documentation.
-if test "$docs" != "no" ; then
-  if has_sphinx_build; then
-    sphinx_ok=yes
-  else
-    sphinx_ok=no
-  fi
-  if test "$sphinx_ok" = "yes"; then
-    docs=yes
-  else
-    if test "$docs" = "yes" ; then
-      if has $sphinx_build && test "$sphinx_ok" != "yes"; then
-        echo "Warning: $sphinx_build exists but it is either too old or uses too old a Python version" >&2
-      fi
-      feature_not_found "docs" "Install a Python 3 version of python-sphinx"
-    fi
-    docs=no
-  fi
-fi
-
 # Search for bswap_32 function
 byteswap_h=no
 cat > $TMPC << EOF
@@ -6087,9 +6039,6 @@ qemu_version=$(head $source_path/VERSION)
 echo "PKGVERSION=$pkgversion" >>$config_host_mak
 echo "SRC_PATH=$source_path" >> $config_host_mak
 echo "TARGET_DIRS=$target_list" >> $config_host_mak
-if [ "$docs" = "yes" ] ; then
-  echo "BUILD_DOCS=yes" >> $config_host_mak
-fi
 if test "$modules" = "yes"; then
   # $shacmd can generate a hash started with digit, which the compiler doesn't
   # like as an symbol. So prefix it with an underscore
@@ -6794,7 +6743,6 @@ fi
 echo "ROMS=$roms" >> $config_host_mak
 echo "MAKE=$make" >> $config_host_mak
 echo "PYTHON=$python" >> $config_host_mak
-echo "SPHINX_BUILD=$sphinx_build" >> $config_host_mak
 echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
 echo "MESON=$meson" >> $config_host_mak
 echo "CC=$cc" >> $config_host_mak
@@ -7076,6 +7024,7 @@ NINJA=${ninja:-$PWD/ninjatool} $meson setup \
         -Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f \
         -Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt \
         -Diconv=$iconv -Dcurses=$curses \
+        -Ddocs=$docs -Dsphinx_build=$sphinx_build \
         $cross_arg \
         "$PWD" "$source_path"
 
docs/meson.build +2 -2
index 0340d489ac..f566809a6a 100644
@@ -37,7 +37,7 @@ if build_docs
                 input: [files('conf.py'), files(manual / 'conf.py')],
                 depfile: manual + '.d',
                 depend_files: sphinx_extn_depends,
-                command: [SPHINX_ARGS, '-Ddepfile=@DEPFILE@',
+                command: SPHINX_ARGS + ['-Ddepfile=@DEPFILE@',
                           '-Ddepfile_stamp=@OUTPUT0@',
                           '-b', 'html', '-d', private_dir,
                           input_dir, output_dir])
@@ -59,7 +59,7 @@ if build_docs
                          input: this_manual,
                          install: build_docs,
                          install_dir: install_dirs,
-                         command: [SPHINX_ARGS, '-b', 'man', '-d', private_dir,
+                         command: SPHINX_ARGS + ['-b', 'man', '-d', private_dir,
                                    input_dir, meson.current_build_dir()])
     endif
   endforeach
meson.build +53 -7
index 8156df8b71..8940468208 100644
@@ -17,7 +17,13 @@ cc = meson.get_compiler('c')
 config_host = keyval.load(meson.current_build_dir() / 'config-host.mak')
 enable_modules = 'CONFIG_MODULES' in config_host
 enable_static = 'CONFIG_STATIC' in config_host
-build_docs = 'BUILD_DOCS' in config_host
+
+# Temporary directory used for files created while
+# configure runs. Since it is in the build directory
+# we can safely blow away any previous version of it
+# (and we need not jump through hoops to try to delete
+# it when configure exits.)
+tmpdir = meson.current_build_dir() / 'config-temp'
 
 if get_option('qemu_suffix').startswith('/')
   error('qemu_suffix cannot start with a /')
@@ -1235,12 +1241,52 @@ foreach d : hx_headers
 endforeach
 genh += hxdep
 
-SPHINX_ARGS = [config_host['SPHINX_BUILD'],
-               '-Dversion=' + meson.project_version(),
-               '-Drelease=' + config_host['PKGVERSION']]
+sphinx_build = not_found
+sphinx_build_option = get_option('sphinx_build')
+if sphinx_build_option == ''
+  sphinx_build = find_program('sphinx-build', required: false)
+else
+  sphinx_build = find_program(sphinx_build_option, required: false)
+endif
 
+SPHINX_TEST_ARGS = []
+# If we're making warnings fatal, apply this to Sphinx runs as well
 if get_option('werror')
-  SPHINX_ARGS += [ '-W' ]
+  SPHINX_TEST_ARGS += [ '-W' ]
+endif
+
+build_docs = false
+docs_option = get_option('docs')
+# Check if tools are available to build documentation.
+if sphinx_build.found() and not docs_option.disabled()
+    # This is a bit awkward but works: create a trivial document and
+    # try to run it with our configuration file (which enforces a
+    # version requirement). This will fail if either
+    # sphinx-build doesn't exist at all or if it is too old.
+    run_command('mkdir', ['-p', tmpdir / 'sphinx'])
+    run_command('touch', [tmpdir / 'sphinx/index.rst'])
+    sphinx_build_test_out = run_command(sphinx_build, SPHINX_TEST_ARGS + [
+      '-c', meson.current_source_dir() / 'docs',
+      '-b', 'html', tmpdir / 'sphinx',
+      tmpdir / 'sphinx/out'])
+    if sphinx_build_test_out.returncode() == 0
+      build_docs = true
+    else
+      if docs_option.enabled()
+        if sphinx_build_option != ''
+          warning('Warning: @0@ exists but it is either too old or uses too old a Python version'.format(sphinx_build_option))
+        endif
+        error('Warning: Install a Python 3 version of python-sphinx')
+      endif
+      # do not building docs
+    endif
+endif
+
+SPHINX_ARGS = []
+if build_docs
+  SPHINX_ARGS = [sphinx_build]
+  SPHINX_ARGS += SPHINX_TEST_ARGS
+  SPHINX_ARGS += ['-Dversion=' + meson.project_version(), '-Drelease=' + config_host['PKGVERSION']]
 endif
 
 sphinx_extn_depends = [ meson.source_root() / 'docs/sphinx/depfile.py',
@@ -1918,7 +1964,7 @@ summary_info += {'QEMU_CFLAGS':       config_host['QEMU_CFLAGS']}
 summary_info += {'QEMU_LDFLAGS':      config_host['QEMU_LDFLAGS']}
 summary_info += {'make':              config_host['MAKE']}
 summary_info += {'python':            '@0@ (version: @1@)'.format(python.full_path(), python.language_version())}
-summary_info += {'sphinx-build':      config_host['SPHINX_BUILD']}
+summary_info += {'sphinx-build':      sphinx_build.found()}
 summary_info += {'genisoimage':       config_host['GENISOIMAGE']}
 # TODO: add back version
 summary_info += {'slirp support':     slirp_opt == 'disabled' ? false : slirp_opt}
@@ -1986,7 +2032,7 @@ if config_host.has_key('CONFIG_XEN_BACKEND')
   summary_info += {'xen ctrl version':  config_host['CONFIG_XEN_CTRL_INTERFACE_VERSION']}
 endif
 summary_info += {'brlapi support':    config_host.has_key('CONFIG_BRLAPI')}
-summary_info += {'Documentation':     config_host.has_key('BUILD_DOCS')}
+summary_info += {'Documentation':     build_docs}
 summary_info += {'PIE':               get_option('b_pie')}
 summary_info += {'vde support':       config_host.has_key('CONFIG_VDE')}
 summary_info += {'netmap support':    config_host.has_key('CONFIG_NETMAP')}
meson_options.txt +4 -1
index e6cb1e589b..0e3fa7136b 100644
@@ -1,8 +1,11 @@
 option('qemu_suffix', type : 'string', value: 'qemu',
        description: 'Suffix for QEMU data/modules/config directories (can be empty)')
+option('docs', type : 'feature', value : 'auto',
+       description: 'Documentations build support')
 option('docdir', type : 'string', value : 'doc',
        description: 'Base directory for documentation installation (can be empty)')
-
+option('sphinx_build', type : 'string', value : '',
+       description: 'Use specified sphinx-build [$sphinx_build] for building document (default to be empty)')
 option('gettext', type : 'boolean', value : true,
        description: 'Localization of the GTK+ user interface')
 option('sparse', type : 'feature', value : 'auto',
tests/qapi-schema/meson.build +1 -1
index 1f222a7a13..961b8367a9 100644
@@ -237,7 +237,7 @@ qapi_doc_out = custom_target('QAPI rST doc',
                              # we want it to always really run the QAPI doc
                              # generation code. It also means we don't
                              # clutter up the build dir with the cache.
-                             command: [SPHINX_ARGS,
+                             command:  SPHINX_ARGS + [
                                        '-b', 'text', '-E',
                                        '-c', meson.source_root() / 'docs',
                                        '-D', 'master_doc=doc-good',
#7 lore raw

Re: [PATCH v4 3/4] meson: Move the detection logic for sphinx to meson

Quoted 21 lines · Paolo Bonzini

Here is a better way to write the meson test:

if get_option('sphinx_build') == ''
sphinx_build = find_program(['sphinx-build-3', 'sphinx-build'],
required: get_option('docs'))
else
sphinx_build = find_program(get_option('sphinx_build'),
required: get_option('docs'))
endif

SPHINX_ARGS = [sphinx_build]
# If we're making warnings fatal, apply this to Sphinx runs as well if get_option('werror')
SPHINX_TEST_ARGS += [ '-W' ]
endif

# Check if tools are available to build documentation. build_docs = false
if sphinx_build.found()
# This is a bit awkward but works: create a trivial document and

Quoted 10 lines
  # try to run it with our configuration file (which enforces a
  # version requirement). This will fail if sphinx-build is too old.
  run_command('mkdir', ['-p', tmpdir / 'sphinx'])
  run_command('touch', [tmpdir / 'sphinx/index.rst'])
  sphinx_build_test_out = run_command(SPHINX_ARGS + [
    '-c', meson.current_source_dir() / 'docs',
    '-b', 'html', tmpdir / 'sphinx',
    tmpdir / 'sphinx/out'])
  build_docs = (sphinx_build_test_out.returncode() == 0)
endif

There is subtle error here, when sphinx_build not found, there is SPHINX_ARGS should be [],
otherwise, latter place using SPHINX_ARGS have not found sphinx_build will cause error by meson
..
I'll add

else
SPHINX_ARGS = []
endif

Quoted 4 lines

if not build_docs
if sphinx_build_option != ''
warning('@0@ exists but it is either too old or uses too old a Python

version'.format(sphinx_build_option))

Quoted 87 lines

endif
if get_option('docs').enabled()
error('Install a Python 3 version of python-sphinx')
endif
endif

Quoted 78 lines · Yonggang Luo
---
 configure                     | 59 +++-------------------------------
 docs/meson.build              |  4 +--
 meson.build                   | 60 +++++++++++++++++++++++++++++++----
 meson_options.txt             |  5 ++-
 tests/qapi-schema/meson.build |  2 +-
 5 files changed, 64 insertions(+), 66 deletions(-)
configure +3 -36
index 1ce31f97b4..ff593a8542 100755
@@ -297,7 +297,7 @@ brlapi=""
 curl=""
 iconv="auto"
 curses="auto"
-docs=""
+docs="auto"
 fdt="auto"
 netmap="no"
 sdl="auto"
@@ -822,15 +822,6 @@ do
     fi
 done
 
-sphinx_build=
-for binary in sphinx-build-3 sphinx-build
-do
-    if has "$binary"
-    then
-        sphinx_build=$(command -v "$binary")
-        break
-    fi
-done
 
 # Check for ancillary tools used in testing
 genisoimage=
@@ -1226,9 +1217,9 @@ for opt do
   ;;
   --disable-crypto-afalg) crypto_afalg="no"
   ;;
-  --disable-docs) docs="no"
+  --disable-docs) docs="disabled"
   ;;
-  --enable-docs) docs="yes"
+  --enable-docs) docs="enabled"
   ;;
   --disable-vhost-net) vhost_net="no"
   ;;
@@ -4413,45 +4404,6 @@ if check_include linux/btrfs.h ; then
     btrfs=yes
 fi
 
-# If we're making warnings fatal, apply this to Sphinx runs as well
-sphinx_werror=""
-if test "$werror" = "yes"; then
-    sphinx_werror="-W"
-fi
-
-# Check we have a new enough version of sphinx-build
-has_sphinx_build() {
-    # This is a bit awkward but works: create a trivial document and
-    # try to run it with our configuration file (which enforces a
-    # version requirement). This will fail if either
-    # sphinx-build doesn't exist at all or if it is too old.
-    mkdir -p "$TMPDIR1/sphinx"
-    touch "$TMPDIR1/sphinx/index.rst"
-    "$sphinx_build" $sphinx_werror -c "$source_path/docs" \
-                    -b html "$TMPDIR1/sphinx" \
-                    "$TMPDIR1/sphinx/out"  >> config.log 2>&1
-}
-
-# Check if tools are available to build documentation.
-if test "$docs" != "no" ; then
-  if has_sphinx_build; then
-    sphinx_ok=yes
-  else
Quoted 8 lines

configure if check_include linux/btrfs.h ; then

Quoted 8 lines
configure +0 -8
-    sphinx_ok=no
-  fi
-  if test "$sphinx_ok" = "yes"; then
-    docs=yes
-  else
-    if test "$docs" = "yes" ; then
-      if has $sphinx_build && test "$sphinx_ok" != "yes"; then
-        echo "Warning: $sphinx_build exists but it is either too old

or uses too old a Python version" >&2

Quoted 2 lines

configure if check_include linux/btrfs.h ; then · line 4449

Quoted 2 lines
configure +0 -2
-      fi
-      feature_not_found "docs" "Install a Python 3 version of

python-sphinx"

Quoted 9 lines
Quoted 9 lines
configure +0 -5
-    fi
-    docs=no
-  fi
-fi
-
 # Search for bswap_32 function
 byteswap_h=no
 cat > $TMPC << EOF
@@ -6087,9 +6039,6 @@ qemu_version=$(head $source_path/VERSION)
Quoted 8 lines

configure qemu_version=$(head $source_path/VERSION)

Quoted 8 lines
configure +0 -3
 echo "PKGVERSION=$pkgversion" >>$config_host_mak
 echo "SRC_PATH=$source_path" >> $config_host_mak
 echo "TARGET_DIRS=$target_list" >> $config_host_mak
-if [ "$docs" = "yes" ] ; then
-  echo "BUILD_DOCS=yes" >> $config_host_mak
-fi
 if test "$modules" = "yes"; then
   # $shacmd can generate a hash started with digit, which the compiler

doesn't

Quoted 27 lines
Quoted 27 lines
configure +1 -1
   # like as an symbol. So prefix it with an underscore
@@ -6794,7 +6743,6 @@ fi
 echo "ROMS=$roms" >> $config_host_mak
 echo "MAKE=$make" >> $config_host_mak
 echo "PYTHON=$python" >> $config_host_mak
-echo "SPHINX_BUILD=$sphinx_build" >> $config_host_mak
 echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
 echo "MESON=$meson" >> $config_host_mak
 echo "CC=$cc" >> $config_host_mak
@@ -7076,6 +7024,7 @@ NINJA=${ninja:-$PWD/ninjatool} $meson setup \
         -Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f \
         -Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt \
         -Diconv=$iconv -Dcurses=$curses \
+        -Ddocs=$docs -Dsphinx_build=$sphinx_build \
         $cross_arg \
         "$PWD" "$source_path"
 
docs/meson.build +1 -1
index 0340d489ac..f566809a6a 100644
@@ -37,7 +37,7 @@ if build_docs
                 input: [files('conf.py'), files(manual / 'conf.py')],
                 depfile: manual + '.d',
                 depend_files: sphinx_extn_depends,
-                command: [SPHINX_ARGS, '-Ddepfile=@DEPFILE@',
+                command: SPHINX_ARGS + ['-Ddepfile=@DEPFILE@',
Quoted 8 lines

docs/meson.build if build_docs · line 62

Quoted 8 lines
docs/meson.build +0 -1
                           '-Ddepfile_stamp=@OUTPUT0@',
                           '-b', 'html', '-d', private_dir,
                           input_dir, output_dir])
@@ -59,7 +59,7 @@ if build_docs
                          input: this_manual,
                          install: build_docs,
                          install_dir: install_dirs,
-                         command: [SPHINX_ARGS, '-b', 'man', '-d',

private_dir,

Quoted 1 line

docs/meson.build if build_docs · line 62

Quoted 1 line
docs/meson.build +1 -0
+                         command: SPHINX_ARGS + ['-b', 'man', '-d',

private_dir,

Quoted 1 line

docs/meson.build if build_docs · line 63

Quoted 1 line
docs/meson.build +0 -0
                                    input_dir,

meson.current_build_dir()])

Quoted 8 lines

meson.build cc = meson.get_compiler('c') · line 17

Quoted 8 lines
docs/meson.build +0 -0
     endif
   endforeach
meson.build +0 -0
index 8156df8b71..8940468208 100644
@@ -17,7 +17,13 @@ cc = meson.get_compiler('c')
 config_host = keyval.load(meson.current_build_dir() /

'config-host.mak')

Quoted 38 lines
Quoted 38 lines
meson.build +22 -5
 enable_modules = 'CONFIG_MODULES' in config_host
 enable_static = 'CONFIG_STATIC' in config_host
-build_docs = 'BUILD_DOCS' in config_host
+
+# Temporary directory used for files created while
+# configure runs. Since it is in the build directory
+# we can safely blow away any previous version of it
+# (and we need not jump through hoops to try to delete
+# it when configure exits.)
+tmpdir = meson.current_build_dir() / 'config-temp'
 
 if get_option('qemu_suffix').startswith('/')
   error('qemu_suffix cannot start with a /')
@@ -1235,12 +1241,52 @@ foreach d : hx_headers
 endforeach
 genh += hxdep
 
-SPHINX_ARGS = [config_host['SPHINX_BUILD'],
-               '-Dversion=' + meson.project_version(),
-               '-Drelease=' + config_host['PKGVERSION']]
+sphinx_build = not_found
+sphinx_build_option = get_option('sphinx_build')
+if sphinx_build_option == ''
+  sphinx_build = find_program('sphinx-build', required: false)
+else
+  sphinx_build = find_program(sphinx_build_option, required: false)
+endif
 
+SPHINX_TEST_ARGS = []
+# If we're making warnings fatal, apply this to Sphinx runs as well
 if get_option('werror')
-  SPHINX_ARGS += [ '-W' ]
+  SPHINX_TEST_ARGS += [ '-W' ]
+endif
+
+build_docs = false
+docs_option = get_option('docs')
+# Check if tools are available to build documentation.
Quoted 8 lines

meson.build foreach d : hx_headers

Quoted 8 lines
meson.build +8 -0
+if sphinx_build.found() and not docs_option.disabled()
+    # This is a bit awkward but works: create a trivial document and
+    # try to run it with our configuration file (which enforces a
+    # version requirement). This will fail if either
+    # sphinx-build doesn't exist at all or if it is too old.
+    run_command('mkdir', ['-p', tmpdir / 'sphinx'])
+    run_command('touch', [tmpdir / 'sphinx/index.rst'])
+    sphinx_build_test_out = run_command(sphinx_build, SPHINX_TEST_ARGS

+ [

Quoted 9 lines

meson.build foreach d : hx_headers

Quoted 9 lines
meson.build +9 -0
+      '-c', meson.current_source_dir() / 'docs',
+      '-b', 'html', tmpdir / 'sphinx',
+      tmpdir / 'sphinx/out'])
+    if sphinx_build_test_out.returncode() == 0
+      build_docs = true
+    else
+      if docs_option.enabled()
+        if sphinx_build_option != ''
+          warning('Warning: @0@ exists but it is either too old or

uses too old a Python version'.format(sphinx_build_option))

Quoted 4 lines
Quoted 4 lines
meson.build +4 -0
+        endif
+        error('Warning: Install a Python 3 version of python-sphinx')
+      endif
+      # do not building docs
Quoted 8 lines

meson.build foreach d : hx_headers

Quoted 8 lines
meson.build +8 -0
+    endif
+endif
+
+SPHINX_ARGS = []
+if build_docs
+  SPHINX_ARGS = [sphinx_build]
+  SPHINX_ARGS += SPHINX_TEST_ARGS
+  SPHINX_ARGS += ['-Dversion=' + meson.project_version(), '-Drelease='

+ config_host['PKGVERSION']]

Quoted 4 lines

meson.build summary_info += {'QEMU_CFLAGS':

Quoted 4 lines
meson.build +0 -0
 endif
 
 sphinx_extn_depends = [ meson.source_root() / 'docs/sphinx/depfile.py',
@@ -1918,7 +1964,7 @@ summary_info += {'QEMU_CFLAGS':

config_host['QEMU_CFLAGS']}

Quoted 3 lines

meson.build summary_info += {'QEMU_CFLAGS': config_host['QEMU_CFLAGS']}

Quoted 3 lines
meson.build +0 -0
 summary_info += {'QEMU_LDFLAGS':      config_host['QEMU_LDFLAGS']}
 summary_info += {'make':              config_host['MAKE']}
 summary_info += {'python':            '@0@ (version: @1@)'.format(python.full_path(),

python.language_version())}

Quoted 5 lines

meson.build summary_info += {'QEMU_CFLAGS': config_host['QEMU_CFLAGS']}

Quoted 5 lines
meson.build +1 -1
-summary_info += {'sphinx-build':      config_host['SPHINX_BUILD']}
+summary_info += {'sphinx-build':      sphinx_build.found()}
 summary_info += {'genisoimage':       config_host['GENISOIMAGE']}
 # TODO: add back version
 summary_info += {'slirp support':     slirp_opt == 'disabled' ? false

: slirp_opt}

Quoted 2 lines

meson.build if config_host.has_key('CONFIG_XEN_BACKEND') · line 2032

Quoted 2 lines
meson.build +0 -0
@@ -1986,7 +2032,7 @@ if config_host.has_key('CONFIG_XEN_BACKEND')
   summary_info += {'xen ctrl version':

config_host['CONFIG_XEN_CTRL_INTERFACE_VERSION']}

Quoted 2 lines

meson.build if config_host.has_key('CONFIG_XEN_BACKEND') · line 2034

Quoted 2 lines
meson.build +0 -0
 endif
 summary_info += {'brlapi support':

config_host.has_key('CONFIG_BRLAPI')}

Quoted 1 line

meson.build if config_host.has_key('CONFIG_XEN_BACKEND') · line 1989

Quoted 1 line
meson.build +0 -1
-summary_info += {'Documentation':

config_host.has_key('BUILD_DOCS')}

Quoted 3 lines

meson.build if config_host.has_key('CONFIG_XEN_BACKEND')

Quoted 3 lines
meson.build +1 -0
+summary_info += {'Documentation':     build_docs}
 summary_info += {'PIE':               get_option('b_pie')}
 summary_info += {'vde support':

config_host.has_key('CONFIG_VDE')}

Quoted 1 line

meson.build if config_host.has_key('CONFIG_XEN_BACKEND') · line 2038

Quoted 1 line
meson.build +0 -0
 summary_info += {'netmap support':

config_host.has_key('CONFIG_NETMAP')}

Quoted 7 lines

meson_options.txt line 2

Quoted 7 lines
meson_options.txt +0 -0
index e6cb1e589b..0e3fa7136b 100644
@@ -1,8 +1,11 @@
 option('qemu_suffix', type : 'string', value: 'qemu',
        description: 'Suffix for QEMU data/modules/config directories

(can be empty)')

Quoted 4 lines

meson_options.txt

Quoted 4 lines
meson_options.txt +2 -0
+option('docs', type : 'feature', value : 'auto',
+       description: 'Documentations build support')
 option('docdir', type : 'string', value : 'doc',
        description: 'Base directory for documentation installation

(can be empty)')

Quoted 3 lines

meson_options.txt

Quoted 3 lines
meson_options.txt +2 -1
-
+option('sphinx_build', type : 'string', value : '',
+       description: 'Use specified sphinx-build [$sphinx_build] for

building document (default to be empty)')

Quoted 4 lines

Review

Quoted 4 lines
meson_options.txt +0 -0
 option('gettext', type : 'boolean', value : true,
        description: 'Localization of the GTK+ user interface')
 option('sparse', type : 'feature', value : 'auto',
(quoted diff) +0 -0

b/tests/qapi-schema/meson.build

Quoted 5 lines

tests/qapi-schema/meson.build qapi_doc_out = custom_target('QAPI rST doc', · line 237

Quoted 5 lines

index 1f222a7a13..961b8367a9 100644

tests/qapi-schema/meson.build +0 -0
@@ -237,7 +237,7 @@ qapi_doc_out = custom_target('QAPI rST doc',
                              # we want it to always really run the

QAPI doc

Quoted 6 lines

tests/qapi-schema/meson.build qapi_doc_out = custom_target('QAPI rST doc',

Quoted 6 lines
tests/qapi-schema/meson.build +1 -1
                              # generation code. It also means we don't
                              # clutter up the build dir with the cache.
-                             command: [SPHINX_ARGS,
+                             command:  SPHINX_ARGS + [
                                        '-b', 'text', '-E',
                                        '-c', meson.source_root() /

'docs',

Quoted 3 lines

tests/qapi-schema/meson.build qapi_doc_out = custom_target('QAPI rST doc', · line 243

Quoted 2 lines
tests/qapi-schema/meson.build +0 -0
                                        '-D', 'master_doc=doc-good',

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

#8 lore raw

Re: [PATCH v4 3/4] meson: Move the detection logic for sphinx to meson

Quoted 21 lines · 罗勇刚(Yonggang Luo)
Quoted 4 lines

build_docs = false
if sphinx_build.found()
  # This is a bit awkward but works: create a trivial document and

Quoted 10 lines
  # try to run it with our configuration file (which enforces a
  # version requirement). This will fail if sphinx-build is too old.
  run_command('mkdir', ['-p', tmpdir / 'sphinx'])
  run_command('touch', [tmpdir / 'sphinx/index.rst'])
  sphinx_build_test_out = run_command(SPHINX_ARGS + [
    '-c', meson.current_source_dir() / 'docs',
    '-b', 'html', tmpdir / 'sphinx',
    tmpdir / 'sphinx/out'])
  build_docs = (sphinx_build_test_out.returncode() == 0)
endif

There is subtle error here, when  sphinx_build not found, there is SPHINX_ARGS  should be [],
otherwise, latter place using  SPHINX_ARGS  have not found sphinx_build will cause error by meson
..
I'll add

Quoted 3 lines

else
  SPHINX_ARGS  = []
endif

All uses of SPHINX_ARGS are protected by build_docs, and in turn build_docs is false if "not sphinx_build.found()". Am I missing something?

Paolo

#9 lore raw

Re: [PATCH v4 3/4] meson: Move the detection logic for sphinx to meson

Quoted 23 lines · Paolo Bonzini
Quoted 21 lines · 罗勇刚(Yonggang Luo)
Quoted 4 lines

build_docs = false
if sphinx_build.found()
# This is a bit awkward but works: create a trivial document and

Quoted 10 lines
  # try to run it with our configuration file (which enforces a
  # version requirement). This will fail if sphinx-build is too old.
  run_command('mkdir', ['-p', tmpdir / 'sphinx'])
  run_command('touch', [tmpdir / 'sphinx/index.rst'])
  sphinx_build_test_out = run_command(SPHINX_ARGS + [
    '-c', meson.current_source_dir() / 'docs',
    '-b', 'html', tmpdir / 'sphinx',
    tmpdir / 'sphinx/out'])
  build_docs = (sphinx_build_test_out.returncode() == 0)
endif

There is subtle error here, when sphinx_build not found, there is SPHINX_ARGS should be [],
otherwise, latter place using SPHINX_ARGS have not found sphinx_build will cause error by meson
..
I'll add

Quoted 6 lines
Quoted 3 lines

else
SPHINX_ARGS = []
endif

All uses of SPHINX_ARGS are protected by build_docs, and in turn build_docs is false if "not sphinx_build.found()". Am I missing

something?
Not all protected, missed in qapi/schema tests

Quoted 3 lines

Paolo

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

#10 lore raw

Re: [PATCH v4 3/4] meson: Move the detection logic for sphinx to meson

In reply to Paolo Bonzini
Quoted 23 lines · Paolo Bonzini
Quoted 21 lines · 罗勇刚(Yonggang Luo)
Quoted 4 lines

build_docs = false
if sphinx_build.found()
# This is a bit awkward but works: create a trivial document and

Quoted 10 lines
  # try to run it with our configuration file (which enforces a
  # version requirement). This will fail if sphinx-build is too old.
  run_command('mkdir', ['-p', tmpdir / 'sphinx'])
  run_command('touch', [tmpdir / 'sphinx/index.rst'])
  sphinx_build_test_out = run_command(SPHINX_ARGS + [
    '-c', meson.current_source_dir() / 'docs',
    '-b', 'html', tmpdir / 'sphinx',
    tmpdir / 'sphinx/out'])
  build_docs = (sphinx_build_test_out.returncode() == 0)
endif

There is subtle error here, when sphinx_build not found, there is SPHINX_ARGS should be [],
otherwise, latter place using SPHINX_ARGS have not found sphinx_build will cause error by meson
..
I'll add

Quoted 6 lines
Quoted 3 lines

else
SPHINX_ARGS = []
endif

All uses of SPHINX_ARGS are protected by build_docs, and in turn build_docs is false if "not sphinx_build.found()". Am I missing

something?

Quoted 3 lines

Paolo

Rfer to
https://github.com/lygstate/qemu/runs/1261141240?check_suite_focus=true

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

#11 lore raw

Re: [PATCH v4 3/4] meson: Move the detection logic for sphinx to meson

In reply to Paolo Bonzini
Quoted 22 lines · Paolo Bonzini
Quoted 21 lines · 罗勇刚(Yonggang Luo)
Quoted 4 lines

build_docs = false
if sphinx_build.found()
  # This is a bit awkward but works: create a trivial document and

Quoted 10 lines
  # try to run it with our configuration file (which enforces a
  # version requirement). This will fail if sphinx-build is too old.
  run_command('mkdir', ['-p', tmpdir / 'sphinx'])
  run_command('touch', [tmpdir / 'sphinx/index.rst'])
  sphinx_build_test_out = run_command(SPHINX_ARGS + [
    '-c', meson.current_source_dir() / 'docs',
    '-b', 'html', tmpdir / 'sphinx',
    tmpdir / 'sphinx/out'])
  build_docs = (sphinx_build_test_out.returncode() == 0)
endif

There is subtle error here, when  sphinx_build not found, there is SPHINX_ARGS  should be [],
otherwise, latter place using  SPHINX_ARGS  have not found sphinx_build will cause error by meson
..
I'll add

Quoted 6 lines
Quoted 3 lines

else
  SPHINX_ARGS  = []
endif

All uses of SPHINX_ARGS are protected by build_docs, and in turn build_docs is false if "not sphinx_build.found()". Am I missing something?

Ah there are uses in tests/ too, those should all be under "if build_docs" too.

Paolo

#12 lore raw

Re: [PATCH v4 3/4] meson: Move the detection logic for sphinx to meson

Quoted 24 lines · Paolo Bonzini
Quoted 22 lines · Paolo Bonzini
Quoted 21 lines · 罗勇刚(Yonggang Luo)
Quoted 4 lines

build_docs = false
if sphinx_build.found()
# This is a bit awkward but works: create a trivial document and

Quoted 10 lines
  # try to run it with our configuration file (which enforces a
  # version requirement). This will fail if sphinx-build is too old.
  run_command('mkdir', ['-p', tmpdir / 'sphinx'])
  run_command('touch', [tmpdir / 'sphinx/index.rst'])
  sphinx_build_test_out = run_command(SPHINX_ARGS + [
    '-c', meson.current_source_dir() / 'docs',
    '-b', 'html', tmpdir / 'sphinx',
    tmpdir / 'sphinx/out'])
  build_docs = (sphinx_build_test_out.returncode() == 0)
endif

There is subtle error here, when sphinx_build not found, there is SPHINX_ARGS should be [],
otherwise, latter place using SPHINX_ARGS have not found sphinx_build will cause error by meson
..
I'll add

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

else
SPHINX_ARGS = []
endif

All uses of SPHINX_ARGS are protected by build_docs, and in turn build_docs is false if "not sphinx_build.found()". Am I missing

something?

Quoted 3 lines

Ah there are uses in tests/ too, those should all be under "if build_docs" too.

Yeap, I did it before, but that changes a lot and not easy to review, you can do it in separate patch.
Anyway setting SPHINX_ARGS to [] are more robust.

Quoted 3 lines

Paolo

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

#13 lore raw

PATCH v4 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