numam-dpdk/buildtools/call-sphinx-build.py
Bruce Richardson a4362f1502 doc: build without using make
When building the DPDK guide documents, the DPDK version information was
pulled using "make showversion", which meant there was a dependency on
the DPDK make-based build system. Change this to have the version info
passed in from meson itself.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2020-09-07 16:51:07 +02:00

36 lines
1.2 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, version, src, dst) = sys.argv[1:] # assign parameters to variables
# set the version in environment for sphinx to pick up
os.environ['DPDK_VERSION'] = version
# 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')