dpdk-fm10k/buildtools/call-sphinx-build.py
Bruce Richardson 0e28cca82a doc: fix build when sphinx reports version to stderr
When sphinx-build reports its version information to stderr rather
than stdout, the wrapper script misses it, and then fails to run.
We can fix this by redirecting stderr to stdout for the version
query call.

Fixes: f5ab2074cf ("doc: rebuild with meson whenever a file changes")
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Tested-by: Ciara Power <ciara.power@intel.com>
Tested-by: David Marchand <david.marchand@redhat.com>
2020-07-31 01:09:26 +02:00

33 lines
1.1 KiB
Python
Executable file

#! /usr/bin/env python3
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2019 Intel Corporation
#
import sys
import os
from os.path import join
from subprocess import run, PIPE, STDOUT
from distutils.version import StrictVersion
(sphinx, src, dst) = sys.argv[1:] # assign parameters to variables
# for sphinx version >= 1.7 add parallelism using "-j auto"
ver = run([sphinx, '--version'], stdout=PIPE,
stderr=STDOUT).stdout.decode().split()[-1]
sphinx_cmd = [sphinx]
if StrictVersion(ver) >= StrictVersion('1.7'):
sphinx_cmd += ['-j', 'auto']
# find all the files sphinx will process so we can write them as dependencies
srcfiles = []
for root, dirs, files in os.walk(src):
srcfiles.extend([join(root, f) for f in files])
# run sphinx, putting the html output in a "html" directory
process = run(sphinx_cmd + ['-b', 'html', src, join(dst, 'html')], check=True)
print(str(process.args) + ' Done OK')
# create a gcc format .d file giving all the dependencies of this doc build
with open(join(dst, '.html.d'), 'w') as d:
d.write('html: ' + ' '.join(srcfiles) + '\n')