xref: /aosp_15_r20/external/mesa3d/docs/_exts/depfile.py (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1*61046927SAndroid Build Coastguard Worker# Copyright © 2021 Collabora Ltd
2*61046927SAndroid Build Coastguard Worker#
3*61046927SAndroid Build Coastguard Worker# Permission is hereby granted, free of charge, to any person obtaining a
4*61046927SAndroid Build Coastguard Worker# copy of this software and associated documentation files (the
5*61046927SAndroid Build Coastguard Worker# "Software"), to deal in the Software without restriction, including
6*61046927SAndroid Build Coastguard Worker# without limitation the rights to use, copy, modify, merge, publish,
7*61046927SAndroid Build Coastguard Worker# distribute, sub license, and/or sell copies of the Software, and to
8*61046927SAndroid Build Coastguard Worker# permit persons to whom the Software is furnished to do so, subject to
9*61046927SAndroid Build Coastguard Worker# the following conditions:
10*61046927SAndroid Build Coastguard Worker#
11*61046927SAndroid Build Coastguard Worker# The above copyright notice and this permission notice (including the
12*61046927SAndroid Build Coastguard Worker# next paragraph) shall be included in all copies or substantial portions
13*61046927SAndroid Build Coastguard Worker# of the Software.
14*61046927SAndroid Build Coastguard Worker#
15*61046927SAndroid Build Coastguard Worker# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16*61046927SAndroid Build Coastguard Worker# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17*61046927SAndroid Build Coastguard Worker# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
18*61046927SAndroid Build Coastguard Worker# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
19*61046927SAndroid Build Coastguard Worker# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20*61046927SAndroid Build Coastguard Worker# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21*61046927SAndroid Build Coastguard Worker# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22*61046927SAndroid Build Coastguard Worker
23*61046927SAndroid Build Coastguard Workerdef create_depfile(app, env):
24*61046927SAndroid Build Coastguard Worker    if not app.config.depfile:
25*61046927SAndroid Build Coastguard Worker        return
26*61046927SAndroid Build Coastguard Worker
27*61046927SAndroid Build Coastguard Worker    with open(app.config.depfile, 'w') as f:
28*61046927SAndroid Build Coastguard Worker        for doc in env.found_docs:
29*61046927SAndroid Build Coastguard Worker            path = env.doc2path(doc)
30*61046927SAndroid Build Coastguard Worker            f.write('{0}: {1}\n'.format(app.outdir, path))
31*61046927SAndroid Build Coastguard Worker
32*61046927SAndroid Build Coastguard Workerdef setup(app):
33*61046927SAndroid Build Coastguard Worker    app.add_config_value('depfile', None, 'env')
34*61046927SAndroid Build Coastguard Worker    app.connect('env-updated', create_depfile)
35