MCPcopy Create free account
hub / github.com/LunarG/VulkanTools / RunGenerators

Function RunGenerators

scripts/generate_source.py:33–158  ·  view source on GitHub ↗
(api: str, registry: str, video_registry: str, directory: str, styleFile: str, targetFilter: str, caching: bool)

Source from the content-addressed store, hash-verified

31from xml.etree import ElementTree
32
33def RunGenerators(api: str, registry: str, video_registry: str, directory: str, styleFile: str, targetFilter: str, caching: bool):
34
35 try:
36 code = common_codegen.RunShellCmd('clang-format --version')
37 has_clang_format = True
38 except:
39 has_clang_format = False
40
41 if not has_clang_format:
42 print("WARNING: Unable to find clang-format!")
43
44 # These live in the Vulkan-Docs repo, but are pulled in via the
45 # Vulkan-Headers/registry folder
46 # At runtime we inject python path to find these helper scripts
47 scripts = os.path.dirname(registry)
48 scripts_directory_path = os.path.dirname(os.path.abspath(__file__))
49 registry_headers_path = os.path.join(scripts_directory_path, scripts)
50 sys.path.insert(0, registry_headers_path)
51 try:
52 from reg import Registry
53 except Exception as err:
54 print("ModuleNotFoundError: No module named 'reg'") # normal python error message
55 print(f'{registry_headers_path} is not pointing to the Vulkan-Headers registry directory.')
56 print("Inside Vulkan-Headers there is a registry/reg.py file that is used.")
57 print(f"Error {err=}, {type(err)=}")
58 sys.exit(1) # Return without call stack so easy to spot error
59
60 from base_generator import BaseGeneratorOptions
61 from generators.api_dump_generator import ApiDumpGenerator
62
63 # These set fields that are needed by both OutputGenerator and BaseGenerator,
64 # but are uniform and don't need to be set at a per-generated file level
65 from base_generator import SetOutputDirectory, SetTargetApiName, SetMergedApiNames, EnableCaching
66 SetOutputDirectory(directory)
67 SetTargetApiName(api)
68
69 # Build up a list of all generators
70 # Note: Options variable names MUST match order of constructor variable in generator
71 generators = {
72 'api_dump_dispatch.h' : {
73 'generator' : ApiDumpGenerator,
74 'genCombined': True,
75 },
76 'api_dump_implementation.h' : {
77 'generator' : ApiDumpGenerator,
78 'genCombined': True,
79 },
80 }
81
82 unknownTargets = [x for x in (targetFilter if targetFilter else []) if x not in generators.keys()]
83 if unknownTargets:
84 print(f'ERROR: No generator options for unknown target(s): {", ".join(unknownTargets)}', file=sys.stderr)
85 return 1
86
87 # Filter if --target is passed in
88 targets = [x for x in generators.keys() if not targetFilter or x in targetFilter]
89
90 cachePath = os.path.join(tempfile.gettempdir(), f'vkobject_{os.getpid()}')

Callers 1

mainFunction · 0.85

Calls 1

typeEnum · 0.85

Tested by

no test coverage detected