> +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
> +
> +# Check if tools are available to build documentation.
> +build_docs = false
> +if sphinx_build.found()
> + SPHINX_ARGS = [sphinx_build]
> + # If we're making warnings fatal, apply this to Sphinx runs as well
> + if get_option('werror')
> + SPHINX_ARGS += [ '-W' ]
> + endif
> +
> + # 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(),
> + '-b', 'html', tmpdir / 'sphinx',
> + tmpdir / 'sphinx/out'])
> + build_docs = (sphinx_build_test_out.returncode() == 0)
> +
> + if not build_docs
> + warning('@0@ exists but it is either too old or uses too old a Python version'.format(sphinx_build_option))
Here need to be
get_option('sphinx_build')
> + if get_option('docs').enabled()
> + error('Install a Python 3 version of python-sphinx')
> + endif
> + endif
> +endif
> +
> if build_docs
> + SPHINX_ARGS += ['-Dversion=' + meson.project_version(), '-Drelease=' + config_host['PKGVERSION']]
> +
> + sphinx_extn_depends = [ meson.source_root() / 'docs/sphinx/depfile.py',
> + meson.source_root() / 'docs/sphinx/hxtool.py',
> + meson.source_root() / 'docs/sphinx/kerneldoc.py',
> + meson.source_root() / 'docs/sphinx/kernellog.py',
> + meson.source_root() / 'docs/sphinx/qapidoc.py',
> + meson.source_root() / 'docs/sphinx/qmp_lexer.py',
> + qapi_gen_depends ]
> +
> configure_file(output: 'index.html',
> input: files('
index.html.in'),
> configuration: {'VERSION': meson.project_version()},
> diff --git a/meson.build b/meson.build
> index 15732f4701..05fb59a00b 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -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() / 'meson-private/temp'
>
> if get_option('qemu_suffix').startswith('/')
> error('qemu_suffix cannot start with a /')
> @@ -1266,22 +1272,6 @@ foreach d : hx_headers
> endforeach
> genh += hxdep
>
> -SPHINX_ARGS = [config_host['SPHINX_BUILD'],
> - '-Dversion=' + meson.project_version(),
> - '-Drelease=' + config_host['PKGVERSION']]
> -
> -if get_option('werror')
> - SPHINX_ARGS += [ '-W' ]
> -endif
> -
> -sphinx_extn_depends = [ meson.source_root() / 'docs/sphinx/depfile.py',
> - meson.source_root() / 'docs/sphinx/hxtool.py',
> - meson.source_root() / 'docs/sphinx/kerneldoc.py',
> - meson.source_root() / 'docs/sphinx/kernellog.py',
> - meson.source_root() / 'docs/sphinx/qapidoc.py',
> - meson.source_root() / 'docs/sphinx/qmp_lexer.py',
> - qapi_gen_depends ]
> -
> ###################
> # Collect sources #
> ###################
> @@ -1866,8 +1856,8 @@ endif
> subdir('scripts')
> subdir('tools')
> subdir('pc-bios')
> -subdir('tests')
> subdir('docs')
> +subdir('tests')
> if 'CONFIG_GTK' in config_host
> subdir('po')
> endif
> @@ -1949,7 +1939,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}
> @@ -2017,7 +2007,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')}
> diff --git a/meson_options.txt b/meson_options.txt
> index 77b3fabd00..967229b66e 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -2,7 +2,11 @@ option('qemu_suffix', type : 'string', value: 'qemu',
> description: 'Suffix for QEMU data/modules/config directories (can be empty)')
> 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('docs', type : 'feature', value : 'auto',
> + description: 'Documentations build support')
> option('gettext', type : 'boolean', value : true,
> description: 'Localization of the GTK+ user interface')
> option('sparse', type : 'feature', value : 'auto',
> --
> 2.26.2
>
>
--
此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo