1#! /usr/bin/env python3 2# SPDX-License-Identifier: BSD-3-Clause 3# Copyright(c) 2019 Intel Corporation 4# 5 6import sys 7import os 8from os.path import join 9from subprocess import run 10 11# assign parameters to variables 12(sphinx, version, src, dst, *extra_args) = sys.argv[1:] 13 14# set the version in environment for sphinx to pick up 15os.environ['DPDK_VERSION'] = version 16 17sphinx_cmd = [sphinx] + extra_args 18 19# find all the files sphinx will process so we can write them as dependencies 20srcfiles = [] 21for root, dirs, files in os.walk(src): 22 srcfiles.extend([join(root, f) for f in files]) 23 24# run sphinx, putting the html output in a "html" directory 25with open(join(dst, 'sphinx_html.out'), 'w') as out: 26 process = run(sphinx_cmd + ['-b', 'html', src, join(dst, 'html')], 27 stdout=out) 28 29# create a gcc format .d file giving all the dependencies of this doc build 30with open(join(dst, '.html.d'), 'w') as d: 31 d.write('html: ' + ' '.join(srcfiles) + '\n') 32 33sys.exit(process.returncode) 34