~mmach/netext73/mesa-haswell

« back to all changes in this revision

Viewing changes to docs/doxygen-wrapper.py

  • Committer: mmach
  • Date: 2022-09-22 19:56:13 UTC
  • Revision ID: netbit73@gmail.com-20220922195613-wtik9mmy20tmor0i
2022-09-22 21:17:09

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python3
2
 
#
3
 
# Copyright © 2021 Intel Corporation
4
 
#
5
 
# Permission is hereby granted, free of charge, to any person obtaining a
6
 
# copy of this software and associated documentation files (the
7
 
# "Software"), to deal in the Software without restriction, including
8
 
# without limitation the rights to use, copy, modify, merge, publish,
9
 
# distribute, sub license, and/or sell copies of the Software, and to
10
 
# permit persons to whom the Software is furnished to do so, subject to
11
 
# the following conditions:
12
 
#
13
 
# The above copyright notice and this permission notice (including the
14
 
# next paragraph) shall be included in all copies or substantial portions
15
 
# of the Software.
16
 
#
17
 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18
 
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
 
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
20
 
# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
21
 
# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
 
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
 
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
 
 
25
 
import argparse
26
 
from mako.template import Template
27
 
import os
28
 
import subprocess
29
 
import tempfile
30
 
 
31
 
INPUT_PATHS = [
32
 
    'src/compiler/nir/nir.h',
33
 
    'src/intel/isl',
34
 
    'src/vulkan/runtime',
35
 
]
36
 
 
37
 
TEMPLATE_DOXYFILE = Template("""
38
 
# Doxyfile 1.9.1
39
 
DOXYFILE_ENCODING = UTF-8
40
 
PROJECT_NAME = "Mesa"
41
 
 
42
 
INPUT = ${' '.join(input_files)}
43
 
XML_OUTPUT = ${output_xml}
44
 
 
45
 
# Only generate XML
46
 
GENERATE_HTML = NO
47
 
GENERATE_LATEX = NO
48
 
GENERATE_XML = YES
49
 
 
50
 
# Add aliases for easily writing reStructuredText in comments
51
 
ALIASES  = "rst=\\verbatim embed:rst:leading-asterisk"
52
 
ALIASES += "endrst=\endverbatim"
53
 
 
54
 
ENABLE_PREPROCESSING = YES
55
 
MACRO_EXPANSION = YES
56
 
EXPAND_ONLY_PREDEF = YES
57
 
 
58
 
# Defines required to keep doxygen from tripping on our attribute macros
59
 
PREDEFINED  = PACKED=
60
 
PREDEFINED += ATTRIBUTE_CONST=
61
 
PREDEFINED += MUST_CHECK=
62
 
""")
63
 
 
64
 
def run_doxygen(output_path, input_paths=[]):
65
 
    doxyfile = tempfile.NamedTemporaryFile(mode='w', delete=False)
66
 
    try:
67
 
        doxyfile.write(TEMPLATE_DOXYFILE.render(
68
 
            input_files=[ os.path.abspath(i) for i in input_paths ],
69
 
            output_xml=os.path.abspath(output_path),
70
 
        ))
71
 
        doxyfile.close()
72
 
 
73
 
        subprocess.run(['doxygen', doxyfile.name])
74
 
 
75
 
    finally:
76
 
        doxyfile.close()
77
 
        os.unlink(doxyfile.name)
78
 
 
79
 
if __name__ == '__main__':
80
 
    parser = argparse.ArgumentParser()
81
 
    parser.add_argument('--out-dir',
82
 
                        help='Output XML directory.',
83
 
                        required=True)
84
 
    args = parser.parse_args()
85
 
 
86
 
    this_dir = os.path.dirname(os.path.abspath(__file__))
87
 
    mesa_dir = os.path.join(this_dir, '..')
88
 
    def fixpath(p):
89
 
        if os.path.isabs(p):
90
 
            return p
91
 
        return os.path.join(mesa_dir, p)
92
 
 
93
 
    input_paths = [ fixpath(p) for p in INPUT_PATHS ]
94
 
 
95
 
    run_doxygen(args.out_dir, input_paths)