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