def makeGenOpts(extensions = [], removeExtensions = [], protect = True, directory = '.'): global genOpts genOpts = {} # Descriptive names for various regexp patterns used to select # versions and extensions allVersions = allExtensions = '.*' noVersions = noExtensions = None addExtensions = makeREstring(extensions) removeExtensions = makeREstring(removeExtensions) # Copyright text prefixing all headers (list of strings). prefixStrings = [ '/*', '** Copyright (c) 2015-2017 The Khronos Group Inc.', '**', '** Licensed under the Apache License, Version 2.0 (the "License");', '** you may not use this file except in compliance with the License.', '** You may obtain a copy of the License at', '**', '** http://www.apache.org/licenses/LICENSE-2.0', '**', '** Unless required by applicable law or agreed to in writing, software', '** distributed under the License is distributed on an "AS IS" BASIS,', '** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.', '** See the License for the specific language governing permissions and', '** limitations under the License.', '*/', '' ] # Text specific to Vulkan headers vkPrefixStrings = [ '/*', '** This header is generated from the Khronos Vulkan XML API Registry.', '**', '*/', '' ] # Defaults for generating re-inclusion protection wrappers (or not) protectFile = protect protectFeature = protect protectProto = protect # # LoaderAndValidationLayer Generators # Options for threading layer genOpts['thread_check.h'] = [ ThreadOutputGenerator, ThreadGeneratorOptions( filename = 'thread_check.h', directory = directory, apiname = 'vulkan', profile = None, versions = allVersions, emitversions = allVersions, defaultExtensions = 'vulkan', addExtensions = addExtensions, removeExtensions = removeExtensions, prefixText = prefixStrings + vkPrefixStrings, protectFeature = False, apicall = 'VKAPI_ATTR ', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', alignFuncParam = 48) ] # Options for parameter validation layer genOpts['parameter_validation.h'] = [ ParamCheckerOutputGenerator, ParamCheckerGeneratorOptions( filename = 'parameter_validation.h', directory = directory, apiname = 'vulkan', profile = None, versions = allVersions, emitversions = allVersions, defaultExtensions = 'vulkan', addExtensions = addExtensions, removeExtensions = removeExtensions, prefixText = prefixStrings + vkPrefixStrings, protectFeature = False, apicall = 'VKAPI_ATTR ', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', alignFuncParam = 48) ] # Options for unique objects layer genOpts['unique_objects_wrappers.h'] = [ UniqueObjectsOutputGenerator, UniqueObjectsGeneratorOptions( filename = 'unique_objects_wrappers.h', directory = directory, apiname = 'vulkan', profile = None, versions = allVersions, emitversions = allVersions, defaultExtensions = 'vulkan', addExtensions = addExtensions, removeExtensions = removeExtensions, prefixText = prefixStrings + vkPrefixStrings, protectFeature = False, apicall = 'VKAPI_ATTR ', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', alignFuncParam = 48) ] # Options for dispatch table helper generator genOpts['vk_dispatch_table_helper.h'] = [ DispatchTableHelperOutputGenerator, DispatchTableHelperOutputGeneratorOptions( filename = 'vk_dispatch_table_helper.h', directory = directory, apiname = 'vulkan', profile = None, versions = allVersions, emitversions = allVersions, defaultExtensions = 'vulkan', addExtensions = addExtensions, removeExtensions = removeExtensions, prefixText = prefixStrings + vkPrefixStrings, protectFeature = False, apicall = 'VKAPI_ATTR ', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', alignFuncParam = 48) ] # Options for Layer dispatch table generator genOpts['vk_layer_dispatch_table.h'] = [ LoaderExtensionOutputGenerator, LoaderExtensionGeneratorOptions( filename = 'vk_layer_dispatch_table.h', directory = directory, apiname = 'vulkan', profile = None, versions = allVersions, emitversions = allVersions, defaultExtensions = 'vulkan', addExtensions = addExtensions, removeExtensions = removeExtensions, prefixText = prefixStrings + vkPrefixStrings, protectFeature = False, apicall = 'VKAPI_ATTR ', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', alignFuncParam = 48) ] # Options for loader extension source generator genOpts['vk_loader_extensions.h'] = [ LoaderExtensionOutputGenerator, LoaderExtensionGeneratorOptions( filename = 'vk_loader_extensions.h', directory = directory, apiname = 'vulkan', profile = None, versions = allVersions, emitversions = allVersions, defaultExtensions = 'vulkan', addExtensions = addExtensions, removeExtensions = removeExtensions, prefixText = prefixStrings + vkPrefixStrings, protectFeature = False, apicall = 'VKAPI_ATTR ', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', alignFuncParam = 48) ] # Options for loader extension source generator genOpts['vk_loader_extensions.c'] = [ LoaderExtensionOutputGenerator, LoaderExtensionGeneratorOptions( filename = 'vk_loader_extensions.c', directory = directory, apiname = 'vulkan', profile = None, versions = allVersions, emitversions = allVersions, defaultExtensions = 'vulkan', addExtensions = addExtensions, removeExtensions = removeExtensions, prefixText = prefixStrings + vkPrefixStrings, protectFeature = False, apicall = 'VKAPI_ATTR ', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', alignFuncParam = 48) ] # Helper file generator options for vk_enum_string_helper.h genOpts['vk_enum_string_helper.h'] = [ HelperFileOutputGenerator, HelperFileOutputGeneratorOptions( filename = 'vk_enum_string_helper.h', directory = directory, apiname = 'vulkan', profile = None, versions = allVersions, emitversions = allVersions, defaultExtensions = 'vulkan', addExtensions = addExtensions, removeExtensions = removeExtensions, prefixText = prefixStrings + vkPrefixStrings, protectFeature = False, apicall = 'VKAPI_ATTR ', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', alignFuncParam = 48, helper_file_type = 'enum_string_header') ] # Helper file generator options for vk_struct_size_helper.h genOpts['vk_struct_size_helper.h'] = [ HelperFileOutputGenerator, HelperFileOutputGeneratorOptions( filename = 'vk_struct_size_helper.h', directory = directory, apiname = 'vulkan', profile = None, versions = allVersions, emitversions = allVersions, defaultExtensions = 'vulkan', addExtensions = addExtensions, removeExtensions = removeExtensions, prefixText = prefixStrings + vkPrefixStrings, protectFeature = False, apicall = 'VKAPI_ATTR ', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', alignFuncParam = 48, helper_file_type = 'struct_size_header') ] # Helper file generator options for vk_struct_size_helper.c genOpts['vk_struct_size_helper.c'] = [ HelperFileOutputGenerator, HelperFileOutputGeneratorOptions( filename = 'vk_struct_size_helper.c', directory = directory, apiname = 'vulkan', profile = None, versions = allVersions, emitversions = allVersions, defaultExtensions = 'vulkan', addExtensions = addExtensions, removeExtensions = removeExtensions, prefixText = prefixStrings + vkPrefixStrings, protectFeature = False, apicall = 'VKAPI_ATTR ', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', alignFuncParam = 48, helper_file_type = 'struct_size_source') ] # Helper file generator options for vk_safe_struct.h genOpts['vk_safe_struct.h'] = [ HelperFileOutputGenerator, HelperFileOutputGeneratorOptions( filename = 'vk_safe_struct.h', directory = directory, apiname = 'vulkan', profile = None, versions = allVersions, emitversions = allVersions, defaultExtensions = 'vulkan', addExtensions = addExtensions, removeExtensions = removeExtensions, prefixText = prefixStrings + vkPrefixStrings, protectFeature = False, apicall = 'VKAPI_ATTR ', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', alignFuncParam = 48, helper_file_type = 'safe_struct_header') ] # Helper file generator options for vk_safe_struct.cpp genOpts['vk_safe_struct.cpp'] = [ HelperFileOutputGenerator, HelperFileOutputGeneratorOptions( filename = 'vk_safe_struct.cpp', directory = directory, apiname = 'vulkan', profile = None, versions = allVersions, emitversions = allVersions, defaultExtensions = 'vulkan', addExtensions = addExtensions, removeExtensions = removeExtensions, prefixText = prefixStrings + vkPrefixStrings, protectFeature = False, apicall = 'VKAPI_ATTR ', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', alignFuncParam = 48, helper_file_type = 'safe_struct_source') ]
def makeGenOpts(args): global genOpts genOpts = {} # Default class of extensions to include, or None defaultExtensions = args.defaultExtensions # Additional extensions to include (list of extensions) extensions = args.extension # Extensions to remove (list of extensions) removeExtensions = args.removeExtensions # Extensions to emit (list of extensions) emitExtensions = args.emitExtensions # Features to include (list of features) features = args.feature # Whether to disable inclusion protect in headers protect = args.protect # Output target directory directory = args.directory # Descriptive names for various regexp patterns used to select # versions and extensions allFeatures = allExtensions = '.*' noFeatures = noExtensions = None # Turn lists of names/patterns into matching regular expressions addExtensionsPat = makeREstring(extensions, None) removeExtensionsPat = makeREstring(removeExtensions, None) emitExtensionsPat = makeREstring(emitExtensions, allExtensions) featuresPat = makeREstring(features, allFeatures) # Copyright text prefixing all headers (list of strings). prefixStrings = [ '/*', '** Copyright (c) 2015-2018 The Khronos Group Inc.', '**', '** Licensed under the Apache License, Version 2.0 (the "License");', '** you may not use this file except in compliance with the License.', '** You may obtain a copy of the License at', '**', '** http://www.apache.org/licenses/LICENSE-2.0', '**', '** Unless required by applicable law or agreed to in writing, software', '** distributed under the License is distributed on an "AS IS" BASIS,', '** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.', '** See the License for the specific language governing permissions and', '** limitations under the License.', '*/', '' ] # Text specific to Vulkan headers vkPrefixStrings = [ '/*', '** This header is generated from the Khronos Vulkan XML API Registry.', '**', '*/', '' ] # Defaults for generating re-inclusion protection wrappers (or not) protectFeature = protect # ValidationLayer Generators # Options for threading layer genOpts['thread_check.h'] = [ ThreadOutputGenerator, ThreadGeneratorOptions(filename='thread_check.h', directory=directory, apiname='vulkan', profile=None, versions=featuresPat, emitversions=featuresPat, defaultExtensions='vulkan', addExtensions=addExtensionsPat, removeExtensions=removeExtensionsPat, emitExtensions=emitExtensionsPat, prefixText=prefixStrings + vkPrefixStrings, protectFeature=False, apicall='VKAPI_ATTR ', apientry='VKAPI_CALL ', apientryp='VKAPI_PTR *', alignFuncParam=48, expandEnumerants=False) ] # Options for parameter validation layer genOpts['parameter_validation.cpp'] = [ ParameterValidationOutputGenerator, ParameterValidationGeneratorOptions( filename='parameter_validation.cpp', directory=directory, apiname='vulkan', profile=None, versions=featuresPat, emitversions=featuresPat, defaultExtensions='vulkan', addExtensions=addExtensionsPat, removeExtensions=removeExtensionsPat, emitExtensions=emitExtensionsPat, prefixText=prefixStrings + vkPrefixStrings, apicall='VKAPI_ATTR ', apientry='VKAPI_CALL ', apientryp='VKAPI_PTR *', alignFuncParam=48, expandEnumerants=False, valid_usage_path=args.scripts) ] # Options for unique objects layer genOpts['unique_objects_wrappers.h'] = [ UniqueObjectsOutputGenerator, UniqueObjectsGeneratorOptions(filename='unique_objects_wrappers.h', directory=directory, apiname='vulkan', profile=None, versions=featuresPat, emitversions=featuresPat, defaultExtensions='vulkan', addExtensions=addExtensionsPat, removeExtensions=removeExtensionsPat, emitExtensions=emitExtensionsPat, prefixText=prefixStrings + vkPrefixStrings, protectFeature=False, apicall='VKAPI_ATTR ', apientry='VKAPI_CALL ', apientryp='VKAPI_PTR *', alignFuncParam=48, expandEnumerants=False) ] # Options for object_tracker layer genOpts['object_tracker.cpp'] = [ ObjectTrackerOutputGenerator, ObjectTrackerGeneratorOptions(filename='object_tracker.cpp', directory=directory, apiname='vulkan', profile=None, versions=featuresPat, emitversions=featuresPat, defaultExtensions='vulkan', addExtensions=addExtensionsPat, removeExtensions=removeExtensionsPat, emitExtensions=emitExtensionsPat, prefixText=prefixStrings + vkPrefixStrings, protectFeature=False, apicall='VKAPI_ATTR ', apientry='VKAPI_CALL ', apientryp='VKAPI_PTR *', alignFuncParam=48, expandEnumerants=False, valid_usage_path=args.scripts) ] # Options for dispatch table helper generator genOpts['vk_dispatch_table_helper.h'] = [ DispatchTableHelperOutputGenerator, DispatchTableHelperOutputGeneratorOptions( filename='vk_dispatch_table_helper.h', directory=directory, apiname='vulkan', profile=None, versions=featuresPat, emitversions=featuresPat, defaultExtensions='vulkan', addExtensions=addExtensionsPat, removeExtensions=removeExtensionsPat, emitExtensions=emitExtensionsPat, prefixText=prefixStrings + vkPrefixStrings, apicall='VKAPI_ATTR ', apientry='VKAPI_CALL ', apientryp='VKAPI_PTR *', alignFuncParam=48, expandEnumerants=False) ] # Options for Layer dispatch table generator genOpts['vk_layer_dispatch_table.h'] = [ LoaderExtensionOutputGenerator, LoaderExtensionGeneratorOptions(filename='vk_layer_dispatch_table.h', directory=directory, apiname='vulkan', profile=None, versions=featuresPat, emitversions=featuresPat, defaultExtensions='vulkan', addExtensions=addExtensionsPat, removeExtensions=removeExtensionsPat, emitExtensions=emitExtensionsPat, prefixText=prefixStrings + vkPrefixStrings, apicall='VKAPI_ATTR ', apientry='VKAPI_CALL ', apientryp='VKAPI_PTR *', alignFuncParam=48, expandEnumerants=False) ] # Helper file generator options for vk_enum_string_helper.h genOpts['vk_enum_string_helper.h'] = [ HelperFileOutputGenerator, HelperFileOutputGeneratorOptions(filename='vk_enum_string_helper.h', directory=directory, apiname='vulkan', profile=None, versions=featuresPat, emitversions=featuresPat, defaultExtensions='vulkan', addExtensions=addExtensionsPat, removeExtensions=removeExtensionsPat, emitExtensions=emitExtensionsPat, prefixText=prefixStrings + vkPrefixStrings, apicall='VKAPI_ATTR ', apientry='VKAPI_CALL ', apientryp='VKAPI_PTR *', alignFuncParam=48, expandEnumerants=False, helper_file_type='enum_string_header') ] # Helper file generator options for vk_safe_struct.h genOpts['vk_safe_struct.h'] = [ HelperFileOutputGenerator, HelperFileOutputGeneratorOptions(filename='vk_safe_struct.h', directory=directory, apiname='vulkan', profile=None, versions=featuresPat, emitversions=featuresPat, defaultExtensions='vulkan', addExtensions=addExtensionsPat, removeExtensions=removeExtensionsPat, emitExtensions=emitExtensionsPat, prefixText=prefixStrings + vkPrefixStrings, apicall='VKAPI_ATTR ', apientry='VKAPI_CALL ', apientryp='VKAPI_PTR *', alignFuncParam=48, expandEnumerants=False, helper_file_type='safe_struct_header') ] # Helper file generator options for vk_safe_struct.cpp genOpts['vk_safe_struct.cpp'] = [ HelperFileOutputGenerator, HelperFileOutputGeneratorOptions(filename='vk_safe_struct.cpp', directory=directory, apiname='vulkan', profile=None, versions=featuresPat, emitversions=featuresPat, defaultExtensions='vulkan', addExtensions=addExtensionsPat, removeExtensions=removeExtensionsPat, emitExtensions=emitExtensionsPat, prefixText=prefixStrings + vkPrefixStrings, apicall='VKAPI_ATTR ', apientry='VKAPI_CALL ', apientryp='VKAPI_PTR *', alignFuncParam=48, expandEnumerants=False, helper_file_type='safe_struct_source') ] # Helper file generator options for vk_object_types.h genOpts['vk_object_types.h'] = [ HelperFileOutputGenerator, HelperFileOutputGeneratorOptions( filename='vk_object_types.h', directory=directory, apiname='vulkan', profile=None, versions=featuresPat, emitversions=featuresPat, defaultExtensions='vulkan', addExtensions=addExtensionsPat, removeExtensions=removeExtensionsPat, emitExtensions=emitExtensionsPat, prefixText=prefixStrings + vkPrefixStrings, apicall='VKAPI_ATTR ', apientry='VKAPI_CALL ', apientryp='VKAPI_PTR *', alignFuncParam=48, expandEnumerants=False, helper_file_type='object_types_header') ] # Helper file generator options for extension_helper.h genOpts['vk_extension_helper.h'] = [ HelperFileOutputGenerator, HelperFileOutputGeneratorOptions( filename='vk_extension_helper.h', directory=directory, apiname='vulkan', profile=None, versions=featuresPat, emitversions=featuresPat, defaultExtensions='vulkan', addExtensions=addExtensionsPat, removeExtensions=removeExtensionsPat, emitExtensions=emitExtensionsPat, prefixText=prefixStrings + vkPrefixStrings, apicall='VKAPI_ATTR ', apientry='VKAPI_CALL ', apientryp='VKAPI_PTR *', alignFuncParam=48, expandEnumerants=False, helper_file_type='extension_helper_header') ] # Helper file generator options for typemap_helper.h genOpts['vk_typemap_helper.h'] = [ HelperFileOutputGenerator, HelperFileOutputGeneratorOptions( filename='vk_typemap_helper.h', directory=directory, apiname='vulkan', profile=None, versions=featuresPat, emitversions=featuresPat, defaultExtensions='vulkan', addExtensions=addExtensionsPat, removeExtensions=removeExtensionsPat, emitExtensions=emitExtensionsPat, prefixText=prefixStrings + vkPrefixStrings, protectFeature=False, apicall='VKAPI_ATTR ', apientry='VKAPI_CALL ', apientryp='VKAPI_PTR *', alignFuncParam=48, expandEnumerants=False, helper_file_type='typemap_helper_header') ]