2020-01-10 21:52:04 +00:00
|
|
|
#! /usr/bin/env python3
|
|
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
# Copyright(c) 2019 Intel Corporation
|
|
|
|
#
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
from os.path import join
|
2020-06-22 14:00:02 +00:00
|
|
|
from subprocess import run, PIPE, STDOUT
|
2020-01-10 21:52:04 +00:00
|
|
|
from distutils.version import StrictVersion
|
|
|
|
|
2020-10-01 11:14:01 +00:00
|
|
|
# assign parameters to variables
|
|
|
|
(sphinx, version, src, dst, *extra_args) = sys.argv[1:]
|
2020-09-03 15:26:58 +00:00
|
|
|
|
|
|
|
# set the version in environment for sphinx to pick up
|
|
|
|
os.environ['DPDK_VERSION'] = version
|
2020-01-10 21:52:04 +00:00
|
|
|
|
|
|
|
# for sphinx version >= 1.7 add parallelism using "-j auto"
|
2020-06-22 14:00:02 +00:00
|
|
|
ver = run([sphinx, '--version'], stdout=PIPE,
|
|
|
|
stderr=STDOUT).stdout.decode().split()[-1]
|
2020-10-01 11:14:01 +00:00
|
|
|
sphinx_cmd = [sphinx] + extra_args
|
2020-01-10 21:52:04 +00:00
|
|
|
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
|
2020-09-29 16:55:00 +00:00
|
|
|
with open(join(dst, 'sphinx_html.out'), 'w') as out:
|
|
|
|
process = run(sphinx_cmd + ['-b', 'html', src, join(dst, 'html')],
|
|
|
|
stdout=out)
|
2020-01-10 21:52:04 +00:00
|
|
|
|
|
|
|
# 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')
|
2020-10-01 11:14:01 +00:00
|
|
|
|
|
|
|
sys.exit(process.returncode)
|