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"""
19 for x
in env
.found_docs
:
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
:
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
:
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
)
43 app
.add_config_value('depfile', None, 'env')
44 app
.add_config_value('depfile_stamp', None, 'env')
45 app
.connect('env-updated', write_depfile
)
48 version
= __version__
,
49 parallel_read_safe
= True,
50 parallel_write_safe
= True