]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | #! /usr/bin/env python3 |
2 | # SPDX-License-Identifier: BSD-3-Clause | |
3 | # Copyright(c) 2019 Intel Corporation | |
4 | # | |
5 | ||
6 | import sys | |
7 | import os | |
8 | from os.path import join | |
9 | from subprocess import run, PIPE | |
10 | from distutils.version import StrictVersion | |
11 | ||
12 | (sphinx, src, dst) = sys.argv[1:] # assign parameters to variables | |
13 | ||
14 | # for sphinx version >= 1.7 add parallelism using "-j auto" | |
15 | ver = run([sphinx, '--version'], stdout=PIPE).stdout.decode().split()[-1] | |
16 | sphinx_cmd = [sphinx] | |
17 | if StrictVersion(ver) >= StrictVersion('1.7'): | |
18 | sphinx_cmd += ['-j', 'auto'] | |
19 | ||
20 | # find all the files sphinx will process so we can write them as dependencies | |
21 | srcfiles = [] | |
22 | for root, dirs, files in os.walk(src): | |
23 | srcfiles.extend([join(root, f) for f in files]) | |
24 | ||
25 | # run sphinx, putting the html output in a "html" directory | |
26 | process = run(sphinx_cmd + ['-b', 'html', src, join(dst, 'html')], check=True) | |
27 | print(str(process.args) + ' Done OK') | |
28 | ||
29 | # create a gcc format .d file giving all the dependencies of this doc build | |
30 | with open(join(dst, '.html.d'), 'w') as d: | |
31 | d.write('html: ' + ' '.join(srcfiles) + '\n') |