• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/python3
2#
3# Copyright 2016-2023 The Khronos Group Inc.
4# SPDX-License-Identifier: Apache-2.0
5
6import argparse
7import subprocess
8import sys
9
10from genspec import *
11
12# Eventually, these may be defined by the extdependency module
13Version1_3 = [ 'VK_VERSION_1_0', 'VK_VERSION_1_1', 'VK_VERSION_1_2', 'VK_VERSION_1_3' ]
14Version1_2 = [ 'VK_VERSION_1_0', 'VK_VERSION_1_1', 'VK_VERSION_1_2' ]
15Version1_1 = [ 'VK_VERSION_1_0', 'VK_VERSION_1_1' ]
16Version1_0 = [ 'VK_VERSION_1_0' ]
17
18if __name__ == '__main__':
19    parser = argparse.ArgumentParser()
20
21    parser.add_argument('-internal', action='store_true',
22                        help='Generate internal build, not public')
23    parser.add_argument('-norefpages', action='store_true',
24                        help='Do not generate refpages')
25    parser.add_argument('-singlerefpage', action='store_true',
26                        help='Generate single-page refpage - NOT SUPPORTED')
27    parser.add_argument('-chunked', action='store_true',
28                        help='Generate chunked HTML outputs')
29    parser.add_argument('-pdf', action='store_true',
30                        help='Generate PDF outputs')
31
32    parser.add_argument('-nov13', action='store_false', dest='v13',
33                        help='Suppress Vulkan 1.3 targets')
34    parser.add_argument('-v12', action='store_true',
35                        help='Generate Vulkan 1.2 targets')
36    parser.add_argument('-v11', action='store_true',
37                        help='Generate Vulkan 1.1 targets')
38    parser.add_argument('-v10', action='store_true',
39                        help='Generate Vulkan 1.0 targets')
40
41    parser.add_argument('-nocorespec', action='store_false', dest='corespec',
42                        help='Do not generate core API-only targets')
43    parser.add_argument('-noratspec', action='store_false', dest='ratspec',
44                        help='Do not generate core API + ratified extensions-only targets')
45    parser.add_argument('-noallspec', action='store_false', dest='allspec',
46                        help='Do not generate full API + all extensions targets')
47
48    parser.add_argument('-registry', action='store',
49                        default=None,
50                        help='Path to API XML registry file specifying version and extension dependencies')
51    parser.add_argument('-apiname', action='store',
52                        default=None,
53                        help='API name to generate')
54
55    parser.add_argument('-gitroot', action='store',
56                        default='/home/tree/git',
57                        help='Set the directory containing gitlab vulkan and github Vulkan-Docs repo clones to build from')
58    parser.add_argument('-repodir', action='store', dest='repoDir',
59                        default=None,
60                        help='Set the repository directory to build from (overrides defaults)')
61    parser.add_argument('-outdir', action='store', dest='outDir',
62                        default=None,
63                        help='Set the output directory to build into (overrides defaults)')
64
65    args = parser.parse_args()
66
67    # Look for scripts/extdependency.py
68    # This requires makeSpec to be invoked from the repository root, but we
69    # could derive that path.
70    sys.path.insert(0, 'scripts')
71    from extdependency import ApiDependencies
72
73    deps = ApiDependencies(args.registry, args.apiname)
74
75    allExts = deps.allExtensions()
76    ratifiedExts = deps.ratifiedExtensions()
77
78    if args.internal:
79        # For internal build & pseudo-release
80        if args.repoDir is None:
81            args.repoDir = f'{args.gitroot}/vulkan'
82        if args.outDir is None:
83            args.outDir = f'{args.gitroot}/vulkan/out'
84    else:
85        # For public release
86        if args.repoDir is None:
87            args.repoDir = f'{args.gitroot}/Vulkan-Docs'
88        if args.outDir is None:
89            args.outDir = f'{args.gitroot}/registry/vulkan/specs'
90
91    refPageTargets = ''
92
93    if not args.norefpages:
94        # Generate separate reference pages
95        refPageTargets += ' manhtmlpages'
96
97    if args.singlerefpage:
98        # Generate single-page refpage.
99        refPageTargets += ' manhtml'
100        if args.pdf:
101            refPageTargets += ' manpdf'
102        print('echo Info: single-page refpage targets are NOT SUPPORTED')
103
104    specTargets = ' html'
105    if args.chunked:
106        specTargets += ' chunked'
107    if args.pdf:
108        specTargets += ' pdf'
109
110    print('echo Info: Building release from', args.repoDir, 'to', args.outDir)
111    print('echo Info: Building spec targets', specTargets)
112    print('')
113
114    # Current Vulkan 1.3 specs
115    if args.v13:
116        if args.allspec:
117            # Build ref pages and validusage targets only for 1.3 + all exts
118            # Formerly set xmlTargets = 'clobber install', but we no longer
119            # generate headers in the registry tree.
120            buildBranch(targetDir = '1.3-extensions',
121                        versions = Version1_3,
122                        extensions = allExts,
123                        ratified = False,
124                        apititle = '(with all registered Vulkan extensions)',
125                        specTargets = specTargets + ' validusage' + refPageTargets,
126                        repoDir = args.repoDir,
127                        outDir = args.outDir)
128
129        if args.ratspec:
130            buildBranch(targetDir = '1.3-khr-extensions',
131                        versions = Version1_3,
132                        extensions = ratifiedExts,
133                        ratified = True,
134                        apititle = '(with all ratified extensions)',
135                        specTargets = specTargets,
136                        repoDir = args.repoDir,
137                        outDir = args.outDir)
138
139        if args.corespec:
140            # Build style guide and registry documentation targets only for 1.3
141            # + no extensions.
142            buildBranch(targetDir = '1.3',
143                        versions = Version1_3,
144                        extensions = None,
145                        ratified = True,
146                        apititle = None,
147                        specTargets = specTargets + ' styleguide registry',
148                        repoDir = args.repoDir,
149                        outDir = args.outDir,
150                        needRefSources = True)
151
152    # Vulkan 1.2 specs
153    if args.v12:
154        if args.allspec:
155            buildBranch(targetDir = '1.2-extensions',
156                        versions = Version1_2,
157                        extensions = allExts,
158                        ratified = False,
159                        apititle = '(with all registered Vulkan extensions)',
160                        specTargets = specTargets,
161                        repoDir = args.repoDir,
162                        outDir = args.outDir)
163
164        if args.ratspec:
165            buildBranch(targetDir = '1.2-khr-extensions',
166                        versions = Version1_2,
167                        extensions = ratifiedExts,
168                        ratified = True,
169                        apititle = '(with all ratified extensions)',
170                        specTargets = specTargets,
171                        repoDir = args.repoDir,
172                        outDir = args.outDir)
173
174        if args.corespec:
175            # Build style guide and registry documentation targets only for 1.2
176            # + no extensions.
177            buildBranch(targetDir = '1.2',
178                        versions = Version1_2,
179                        extensions = None,
180                        ratified = True,
181                        apititle = None,
182                        specTargets = specTargets + ' styleguide registry',
183                        repoDir = args.repoDir,
184                        outDir = args.outDir,
185                        needRefSources = True)
186
187    # Vulkan 1.1 specs
188    if args.v11:
189        if args.allspec:
190            buildBranch(targetDir = '1.1-extensions',
191                        versions = Version1_1,
192                        extensions = allExts,
193                        ratified = False,
194                        apititle = '(with all registered Vulkan extensions)',
195                        specTargets = specTargets,
196                        repoDir = args.repoDir,
197                        outDir = args.outDir)
198
199        if args.ratspec:
200            buildBranch(targetDir = '1.1-khr-extensions',
201                        versions = Version1_1,
202                        extensions = ratifiedExts,
203                        ratified = True,
204                        apititle = '(with all ratified extensions)',
205                        specTargets = specTargets,
206                        repoDir = args.repoDir,
207                        outDir = args.outDir)
208
209        if args.corespec:
210            buildBranch(targetDir = '1.1',
211                        versions = Version1_1,
212                        extensions = None,
213                        ratified = True,
214                        apititle = None,
215                        specTargets = specTargets,
216                        repoDir = args.repoDir,
217                        outDir = args.outDir)
218    else:
219        print('echo Info: Not building 1.1 specs yet')
220
221
222    # Vulkan 1.0 specs.
223    if args.v10:
224        if args.allspec:
225            buildBranch(targetDir = '1.0-extensions',
226                        versions = Version1_0,
227                        extensions = allExts,
228                        ratified = False,
229                        apititle = '(with all registered Vulkan extensions)',
230                        specTargets = specTargets,
231                        repoDir = args.repoDir,
232                        outDir = args.outDir)
233
234        if args.ratspec:
235            buildBranch(targetDir = '1.0-wsi_extensions',
236                        versions = Version1_0,
237                        extensions = ratifiedExts,
238                        ratified = True,
239                        apititle = '(with all ratified extensions)',
240                        specTargets = specTargets,
241                        repoDir = args.repoDir,
242                        outDir = args.outDir)
243
244        if args.corespec:
245            buildBranch(targetDir = '1.0',
246                        versions = Version1_0,
247                        extensions = None,
248                        ratified = True,
249                        apititle = None,
250                        specTargets = specTargets,
251                        repoDir = args.repoDir,
252                        outDir = args.outDir)
253    else:
254        print('echo Info: Not building 1.0 specs yet')
255
256    print('echo Info: post-generation cleanup')
257    createTags(releaseNum(), buildOnFriday())
258