1e5c31af7Sopenharmony_ci#!/usr/bin/python3 2e5c31af7Sopenharmony_ci# 3e5c31af7Sopenharmony_ci# Copyright 2016-2024 The Khronos Group Inc. 4e5c31af7Sopenharmony_ci# 5e5c31af7Sopenharmony_ci# SPDX-License-Identifier: Apache-2.0 6e5c31af7Sopenharmony_ci"""This script builds a full release package including XHTML and PDF 7e5c31af7Sopenharmony_civersions of the specification, including an optional list of 8e5c31af7Sopenharmony_ciextensions. Other files in the release directory are removed, 9e5c31af7Sopenharmony_ciincluding man pages, XHTML chunked, HTML, validity output, etc. 10e5c31af7Sopenharmony_ci 11e5c31af7Sopenharmony_ciThe current branch must be fully committed and up to date when the 12e5c31af7Sopenharmony_ciscript is run, with no outstanding un-added / un-committed files. 13e5c31af7Sopenharmony_ciAfter completing the build, suggestions for creating tags are made.""" 14e5c31af7Sopenharmony_ci 15e5c31af7Sopenharmony_ciimport time 16e5c31af7Sopenharmony_cifrom datetime import date, timedelta 17e5c31af7Sopenharmony_ci 18e5c31af7Sopenharmony_ci 19e5c31af7Sopenharmony_cidef releaseNum(): 20e5c31af7Sopenharmony_ci """Return the Vulkan release number, used for tags.""" 21e5c31af7Sopenharmony_ci return '$REVISION' 22e5c31af7Sopenharmony_ci 23e5c31af7Sopenharmony_ci 24e5c31af7Sopenharmony_cidef buildOnFriday(): 25e5c31af7Sopenharmony_ci """Return a date for the current, or upcoming if not already, Friday, 26e5c31af7Sopenharmony_ci which is when releases happen.""" 27e5c31af7Sopenharmony_ci today = date.today() 28e5c31af7Sopenharmony_ci friday = today + timedelta((4 - today.weekday()) % 7) 29e5c31af7Sopenharmony_ci return friday 30e5c31af7Sopenharmony_ci 31e5c31af7Sopenharmony_ci 32e5c31af7Sopenharmony_cidef buildRelease(label, 33e5c31af7Sopenharmony_ci versions, 34e5c31af7Sopenharmony_ci extensions, 35e5c31af7Sopenharmony_ci ratified, 36e5c31af7Sopenharmony_ci outdir, 37e5c31af7Sopenharmony_ci apititle, 38e5c31af7Sopenharmony_ci xmlDir, xmlTargets, 39e5c31af7Sopenharmony_ci specDir, specTargets, 40e5c31af7Sopenharmony_ci miscSrc=None, miscDst=None, needRefSources=False): 41e5c31af7Sopenharmony_ci """Build a release. 42e5c31af7Sopenharmony_ci 43e5c31af7Sopenharmony_ci - `label` = textual label to use for target being generated 44e5c31af7Sopenharmony_ci - `versions` = list of core API versions to include 45e5c31af7Sopenharmony_ci - `extensions` = list of extension names to include 46e5c31af7Sopenharmony_ci - `ratified` = True if this is a ratified spec (one built without non-KHR extensions) 47e5c31af7Sopenharmony_ci - `outdir` = directory to generate specs in 48e5c31af7Sopenharmony_ci - `apititle` = extra title to apply to the specification 49e5c31af7Sopenharmony_ci - `xmlDir` = directory containing registry XML 50e5c31af7Sopenharmony_ci - `xmlTargets` = targets to build in xml/ 51e5c31af7Sopenharmony_ci - `specDir` = directory containing spec source & Makefile 52e5c31af7Sopenharmony_ci - `specTargets` = targets to build 53e5c31af7Sopenharmony_ci - `miscSrc` = path to copy misc files from, if non-None 54e5c31af7Sopenharmony_ci - `miscDst` = path to copy misc files to, if non-None 55e5c31af7Sopenharmony_ci - `needRefSources` = True if ref pages must be extracted from the spec sources""" 56e5c31af7Sopenharmony_ci 57e5c31af7Sopenharmony_ci print('echo Info: Generating target=' + label, 58e5c31af7Sopenharmony_ci 'outdir=' + outdir) 59e5c31af7Sopenharmony_ci 60e5c31af7Sopenharmony_ci outarg = 'OUTDIR=' + outdir 61e5c31af7Sopenharmony_ci 62e5c31af7Sopenharmony_ci if versions != None and len(versions) > 0: 63e5c31af7Sopenharmony_ci versarg = 'VERSIONS="' + ' '.join(versions) + '"' 64e5c31af7Sopenharmony_ci else: 65e5c31af7Sopenharmony_ci versarg = '' 66e5c31af7Sopenharmony_ci 67e5c31af7Sopenharmony_ci if extensions != None and len(extensions) > 0: 68e5c31af7Sopenharmony_ci extarg = 'EXTENSIONS="' + ' '.join(extensions) + '"' 69e5c31af7Sopenharmony_ci else: 70e5c31af7Sopenharmony_ci extarg = '' 71e5c31af7Sopenharmony_ci 72e5c31af7Sopenharmony_ci if ratified: 73e5c31af7Sopenharmony_ci ratifiedarg = 'EXTRAATTRIBS="-a ratified_core_spec"' 74e5c31af7Sopenharmony_ci else: 75e5c31af7Sopenharmony_ci ratifiedarg = '' 76e5c31af7Sopenharmony_ci 77e5c31af7Sopenharmony_ci if apititle != None: 78e5c31af7Sopenharmony_ci titlearg = 'APITITLE="' + apititle + '"' 79e5c31af7Sopenharmony_ci else: 80e5c31af7Sopenharmony_ci titlearg = '' 81e5c31af7Sopenharmony_ci 82e5c31af7Sopenharmony_ci # print('echo Info: Creating directory and cleaning spec in', outdir) 83e5c31af7Sopenharmony_ci print('mkdir -p', outdir) 84e5c31af7Sopenharmony_ci print('(cd ', outdir, '&& rm -rf', 85e5c31af7Sopenharmony_ci 'html chunked pdf', 86e5c31af7Sopenharmony_ci 'man config checks', 87e5c31af7Sopenharmony_ci 'vkspec.html styleguide.html apispec.html apispec.pdf registry.html', 88e5c31af7Sopenharmony_ci ')') 89e5c31af7Sopenharmony_ci 90e5c31af7Sopenharmony_ci if xmlTargets != '': 91e5c31af7Sopenharmony_ci # print('echo Info: Generating headers and spec include files') 92e5c31af7Sopenharmony_ci print('cd', xmlDir) 93e5c31af7Sopenharmony_ci print('make', outarg, xmlTargets) 94e5c31af7Sopenharmony_ci 95e5c31af7Sopenharmony_ci # print('echo Info: Generating ref pages sources and spec targets') 96e5c31af7Sopenharmony_ci print('cd', specDir) 97e5c31af7Sopenharmony_ci print('make', outarg, 'clean') 98e5c31af7Sopenharmony_ci # This is a temporary workaround for a dependency bug - if any of the 99e5c31af7Sopenharmony_ci # specTargets require ref page sources, and they are not already present 100e5c31af7Sopenharmony_ci # at the time the make is invoked, that target will not be built. 101e5c31af7Sopenharmony_ci if needRefSources: 102e5c31af7Sopenharmony_ci print('make', outarg, versarg, extarg, 'refpages') 103e5c31af7Sopenharmony_ci # Now make the actual targets. 104e5c31af7Sopenharmony_ci print('make -O -k -j 8', 105e5c31af7Sopenharmony_ci outarg, versarg, extarg, ratifiedarg, titlearg, 106e5c31af7Sopenharmony_ci 'NOTEOPTS="-a implementation-guide"', 107e5c31af7Sopenharmony_ci specTargets) 108e5c31af7Sopenharmony_ci 109e5c31af7Sopenharmony_ci if miscSrc != None and miscDst != None: 110e5c31af7Sopenharmony_ci print('mkdir -p', miscDst) 111e5c31af7Sopenharmony_ci print('cp', miscSrc + '/*.adoc', miscDst + '/') 112e5c31af7Sopenharmony_ci 113e5c31af7Sopenharmony_ci print('') 114e5c31af7Sopenharmony_ci 115e5c31af7Sopenharmony_ci 116e5c31af7Sopenharmony_cidef buildBranch(targetDir = '', 117e5c31af7Sopenharmony_ci versions = '', 118e5c31af7Sopenharmony_ci extensions = '', 119e5c31af7Sopenharmony_ci ratified = False, 120e5c31af7Sopenharmony_ci apititle = '(NO TITLE SPECIFIED)', 121e5c31af7Sopenharmony_ci xmlTargets = '', 122e5c31af7Sopenharmony_ci specTargets = '', 123e5c31af7Sopenharmony_ci repoDir = '', 124e5c31af7Sopenharmony_ci outDir = '', 125e5c31af7Sopenharmony_ci needRefSources=False): 126e5c31af7Sopenharmony_ci """Build all target documents. 127e5c31af7Sopenharmony_ci 128e5c31af7Sopenharmony_ci - `repoDir` = path to the Vulkan git repo containing the specs 129e5c31af7Sopenharmony_ci - `outDir` = path to the output base directory in which targets are generated""" 130e5c31af7Sopenharmony_ci 131e5c31af7Sopenharmony_ci # Directory with vk.xml and generation tools 132e5c31af7Sopenharmony_ci xmlDir = repoDir + '/xml' 133e5c31af7Sopenharmony_ci # Directory with spec sources 134e5c31af7Sopenharmony_ci specDir = repoDir 135e5c31af7Sopenharmony_ci # Directory containing misc. files to copy to registry. 136e5c31af7Sopenharmony_ci # At present there are none, since GLSL extensions have moved to the 137e5c31af7Sopenharmony_ci # GLSL repository and are redirected from the Vulkan registry website. 138e5c31af7Sopenharmony_ci # These should be relative to repoDir and outDir, respectively 139e5c31af7Sopenharmony_ci miscSrc = None 140e5c31af7Sopenharmony_ci miscDst = None 141e5c31af7Sopenharmony_ci 142e5c31af7Sopenharmony_ci buildRelease(targetDir, 143e5c31af7Sopenharmony_ci versions, 144e5c31af7Sopenharmony_ci extensions, 145e5c31af7Sopenharmony_ci ratified, 146e5c31af7Sopenharmony_ci outDir + '/' + targetDir, 147e5c31af7Sopenharmony_ci apititle, 148e5c31af7Sopenharmony_ci xmlDir, xmlTargets, 149e5c31af7Sopenharmony_ci specDir, specTargets, 150e5c31af7Sopenharmony_ci miscSrc, miscDst, 151e5c31af7Sopenharmony_ci needRefSources) 152e5c31af7Sopenharmony_ci 153e5c31af7Sopenharmony_ci 154e5c31af7Sopenharmony_cidef createTags(releaseNum, tagdate): 155e5c31af7Sopenharmony_ci """Print commands to tag the git branches. 156e5c31af7Sopenharmony_ci 157e5c31af7Sopenharmony_ci - `releaseNum` = release number of this spec update, to tag the tree with 158e5c31af7Sopenharmony_ci - `tagdate` = date (used to be used to tag the tree with)""" 159e5c31af7Sopenharmony_ci # Tag date in YYYYMMDD format 160e5c31af7Sopenharmony_ci now = tagdate.strftime('%Y%m%d') 161e5c31af7Sopenharmony_ci 162e5c31af7Sopenharmony_ci print('echo To tag the spec branch for this release, execute the command:') 163e5c31af7Sopenharmony_ci print('echo git tag -a -m \\"Tag Vulkan API specification for 1.3.' + 164e5c31af7Sopenharmony_ci releaseNum, 'release\\"', 'v1.3.' + releaseNum) 165