(argv)
| 159 | |
| 160 | |
| 161 | def main(argv): |
| 162 | |
| 163 | # files to exclude from --verify check |
| 164 | verify_exclude = ['.clang-format'] # None currently |
| 165 | |
| 166 | parser = argparse.ArgumentParser(description='Generate source code for this repository') |
| 167 | parser.add_argument('registry', metavar='REGISTRY_PATH', help='path to the Vulkan-Headers registry directory') |
| 168 | parser.add_argument('--api', |
| 169 | default='vulkan', |
| 170 | choices=['vulkan', 'vulkansc'], |
| 171 | help='Specify API name to generate') |
| 172 | parser.add_argument('--generated-version', help='sets the header version used to generate the repo') |
| 173 | group = parser.add_mutually_exclusive_group() |
| 174 | group.add_argument('--target', nargs='+', help='only generate file names passed in') |
| 175 | group.add_argument('-i', '--incremental', action='store_true', help='only update repo files that change') |
| 176 | group.add_argument('-v', '--verify', action='store_true', help='verify repo files match generator output') |
| 177 | group.add_argument('-o', action='store', dest='directory', help='Create target and related files in specified directory') |
| 178 | args = parser.parse_args(argv) |
| 179 | |
| 180 | repo_dir = common_codegen.RepoRelative('.') |
| 181 | |
| 182 | registry = os.path.abspath(os.path.join(args.registry, 'vk.xml')) |
| 183 | video_registry = os.path.abspath(os.path.join(args.registry, 'video.xml')) |
| 184 | if not os.path.isfile(registry) and not os.path.isfile(registry): |
| 185 | registry = os.path.abspath(os.path.join(args.registry, 'Vulkan-Headers/registry/vk.xml')) |
| 186 | if not os.path.isfile(registry): |
| 187 | print(f'cannot find vk.xml in {args.registry}') |
| 188 | return -1 |
| 189 | video_registry = os.path.abspath(os.path.join(args.registry, 'Vulkan-Headers/registry/video.xml')) |
| 190 | if not os.path.isfile(video_registry): |
| 191 | print(f'{video_registry} does not exist') |
| 192 | return -1 |
| 193 | |
| 194 | # Need pass style file incase running with --verify and it can't find the file automatically in the temp directory |
| 195 | style_file = os.path.join(repo_dir, '.clang-format') |
| 196 | |
| 197 | # get directory where generators will run |
| 198 | if args.verify or args.incremental: |
| 199 | # generate in temp directory so we can compare or copy later |
| 200 | temp_obj = tempfile.TemporaryDirectory(prefix='vulkan_tools_codegen_') |
| 201 | temp_dir = temp_obj.name |
| 202 | gen_dir = temp_dir |
| 203 | elif args.directory: |
| 204 | gen_dir = args.directory |
| 205 | else: |
| 206 | # generate directly in the repo |
| 207 | gen_dir = repo_dir |
| 208 | |
| 209 | RunGenerators(api=args.api,registry=registry, video_registry=video_registry, directory=gen_dir, styleFile=style_file, targetFilter=args.target, flatOutput=False) |
| 210 | |
| 211 | # optional post-generation steps |
| 212 | if args.verify: |
| 213 | # compare contents of temp dir and repo |
| 214 | temp_files = {} |
| 215 | repo_files = {} |
| 216 | for details in generators.values(): |
| 217 | if details['directory'] not in temp_files: |
| 218 | temp_files[details['directory']] = set() |
no test coverage detected