meson.build: drop duplicate 'sparc64' entry
[qemu/ar7.git] / docs / sphinx / depfile.py
blob277fdf0f56806d2fc58dbdf65200bdbb29c11194
1 # coding=utf-8
3 # QEMU depfile generation extension
5 # Copyright (c) 2020 Red Hat, Inc.
7 # This work is licensed under the terms of the GNU GPLv2 or later.
8 # See the COPYING file in the top-level directory.
10 """depfile is a Sphinx extension that writes a dependency file for
11 an external build system"""
13 import os
14 import sphinx
16 __version__ = '1.0'
18 def get_infiles(env):
19 for x in env.found_docs:
20 yield env.doc2path(x)
21 yield from ((os.path.join(env.srcdir, dep)
22 for dep in env.dependencies[x]))
24 def write_depfile(app, env):
25 if not env.config.depfile:
26 return
28 # Using a directory as the output file does not work great because
29 # its timestamp does not necessarily change when the contents change.
30 # So create a timestamp file.
31 if env.config.depfile_stamp:
32 with open(env.config.depfile_stamp, 'w') as f:
33 pass
35 with open(env.config.depfile, 'w') as f:
36 print((env.config.depfile_stamp or app.outdir) + ": \\", file=f)
37 print(*get_infiles(env), file=f)
38 for x in get_infiles(env):
39 print(x + ":", file=f)
42 def setup(app):
43 app.add_config_value('depfile', None, 'env')
44 app.add_config_value('depfile_stamp', None, 'env')
45 app.connect('env-updated', write_depfile)
47 return dict(
48 version = __version__,
49 parallel_read_safe = True,
50 parallel_write_safe = True