cmake: Use VulkanHeaders_VERSION
authorJuan Ramos <juan@lunarg.com>
Tue, 27 Dec 2022 21:37:21 +0000 (14:37 -0700)
committerJuan Ramos <114601453+juan-lunarg@users.noreply.github.com>
Tue, 27 Dec 2022 21:50:31 +0000 (14:50 -0700)
Removes need for a bit of python code / parsing.
And it's consistent with VVL's approach.

loader/CMakeLists.txt
loader/generated/loader_generated_header_version.cmake [deleted file]
scripts/generate_source.py
scripts/loader_genvk.py
scripts/loader_versioning_generator.py [deleted file]

index b24c037b4b69ac9d135a8e98550630f8c4f377a5..10fa787e80b749ffbed9d90f3aa97c2908679e79 100644 (file)
@@ -17,9 +17,6 @@
 # limitations under the License.
 # ~~~
 
-# Get version of the API the generated code used and put it into a cmake variable LOADER_GENERATED_HEADER_VERSION
-include(generated/loader_generated_header_version.cmake)
-
 add_library(loader_specific_options INTERFACE)
 target_link_libraries(loader_specific_options INTERFACE loader_common_options Vulkan::Headers)
 target_include_directories(loader_specific_options INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/generated ${CMAKE_CURRENT_BINARY_DIR})
@@ -317,10 +314,9 @@ else()
         add_library(vulkan SHARED ${NORMAL_LOADER_SRCS} ${OPT_LOADER_SRCS})
     endif()
     add_dependencies(vulkan loader_asm_gen_files)
-    # set version based on LOADER_GENERATED_HEADER_VERSION used to generate the code
     set_target_properties(vulkan
                           PROPERTIES SOVERSION "1"
-                          VERSION ${LOADER_GENERATED_HEADER_VERSION})
+                          VERSION ${VulkanHeaders_VERSION})
     target_link_libraries(vulkan PRIVATE ${CMAKE_DL_LIBS} m)
     if (NOT ANDROID)
         target_link_libraries(vulkan PRIVATE Threads::Threads)
@@ -359,8 +355,8 @@ else()
             OUTPUT_NAME vulkan
             FRAMEWORK TRUE
             FRAMEWORK_VERSION A
-            VERSION "${LOADER_GENERATED_HEADER_VERSION}" # "current version"
-            SOVERSION "1.0.0"                        # "compatibility version"
+            VERSION "${VulkanHeaders_VERSION}" # "current version"
+            SOVERSION "1.0.0"                  # "compatibility version"
             MACOSX_FRAMEWORK_IDENTIFIER com.lunarg.vulkanFramework
             PUBLIC_HEADER "${FRAMEWORK_HEADERS}"
         )
@@ -383,7 +379,7 @@ endif()
 # Generate pkg-config file.
 find_package(PkgConfig QUIET)
 if(PKG_CONFIG_FOUND)
-    set(VK_API_VERSION "${LOADER_GENERATED_HEADER_VERSION}")
+    set(VK_API_VERSION "${VulkanHeaders_VERSION}")
     set(PRIVATE_LIBS "")
     if (APPLE AND BUILD_STATIC_LOADER)
         # Libs.private should only be present when building a static loader
diff --git a/loader/generated/loader_generated_header_version.cmake b/loader/generated/loader_generated_header_version.cmake
deleted file mode 100644 (file)
index 55a64e0..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-# *** THIS FILE IS GENERATED - DO NOT EDIT ***
-# See loader_versioning_generator.py for modifications
-
-############################################################################
-#
-# Copyright (c) 2021 The Khronos Group Inc.
-# Copyright (c) 2021 Valve Corporation
-# Copyright (c) 2021 LunarG, Inc.
-# Copyright (c) 2021 Google 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.
-#
-# Author: Charles Giessen <charles@lunarg.com>
-#
-############################################################################
-
-set(LOADER_GENERATED_HEADER_VERSION "1.3.238")
-
index 233e92bfdfbdb493af5c6aa82b389fd46518c183..712747b830e95c7e30975e570199f78e6e1327cc 100755 (executable)
@@ -45,8 +45,7 @@ def main(argv):
                                             'vk_layer_dispatch_table.h',
                                             'vk_loader_extensions.h',
                                             'vk_loader_extensions.c',
-                                            'vk_object_types.h',
-                                            'loader_generated_header_version.cmake']]
+                                            'vk_object_types.h']]
 
     repo_dir = common_codegen.repo_relative('loader/generated')
 
index 5d79f4433a88f6e2b7d61476d0dc642e1ca887bf..3489599a20ac432d5f64949551e619516b867d7e 100644 (file)
@@ -239,30 +239,6 @@ def makeGenOpts(args):
             helper_file_type  = 'object_types_header')
         ]
 
-    # Loader Generated Header Version Options for loader_generated_header_version.cmake
-    genOpts['loader_generated_header_version.cmake'] = [
-          LoaderVersioningGenerator,
-          LoaderVersioningGeneratorOptions(
-            conventions       = conventions,
-            filename          = 'loader_generated_header_version.cmake',
-            directory         = directory,
-            genpath           = None,
-            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)
-        ]
-
 # Create an API generator and corresponding generator options based on
 # the requested target and command line options.
 # This is encapsulated in a function so it can be profiled and/or timed.
@@ -381,7 +357,6 @@ if __name__ == '__main__':
     from dispatch_table_helper_generator import DispatchTableHelperOutputGenerator, DispatchTableHelperOutputGeneratorOptions
     from helper_file_generator import HelperFileOutputGenerator, HelperFileOutputGeneratorOptions
     from loader_extension_generator import LoaderExtensionOutputGenerator, LoaderExtensionGeneratorOptions
-    from loader_versioning_generator import LoaderVersioningGenerator, LoaderVersioningGeneratorOptions
 
     # Temporary workaround for vkconventions python2 compatibility
     import abc; abc.ABC = abc.ABCMeta('ABC', (object,), {})
diff --git a/scripts/loader_versioning_generator.py b/scripts/loader_versioning_generator.py
deleted file mode 100644 (file)
index 821cfbc..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-#!/usr/bin/python3 -i
-#
-# Copyright (c) 2021 The Khronos Group Inc.
-# Copyright (c) 2021 Valve Corporation
-# Copyright (c) 2021 LunarG, Inc.
-# Copyright (c) 2021 Google 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.
-#
-# Author: Charles Giessen <charles@lunarg.com>
-
-import os,re,sys
-import xml.etree.ElementTree as etree
-from generator import *
-from collections import namedtuple
-from common_codegen import *
-
-#
-# LoaderVersioningGeneratorOptions - subclass of GeneratorOptions.
-class LoaderVersioningGeneratorOptions(GeneratorOptions):
-    def __init__(self,
-                 conventions = None,
-                 filename = None,
-                 directory = '.',
-                 genpath = None,
-                 apiname = None,
-                 profile = None,
-                 versions = '.*',
-                 emitversions = '.*',
-                 defaultExtensions = None,
-                 addExtensions = None,
-                 removeExtensions = None,
-                 emitExtensions = None,
-                 sortProcedure = regSortFeatures,
-                 prefixText = "",
-                 genFuncPointers = True,
-                 protectFile = True,
-                 protectFeature = True,
-                 apicall = '',
-                 apientry = '',
-                 apientryp = '',
-                 alignFuncParam = 0,
-                 library_name = '',
-                 expandEnumerants = True):
-        GeneratorOptions.__init__(self,
-                conventions = conventions,
-                filename = filename,
-                directory = directory,
-                genpath = genpath,
-                apiname = apiname,
-                profile = profile,
-                versions = versions,
-                emitversions = emitversions,
-                defaultExtensions = defaultExtensions,
-                addExtensions = addExtensions,
-                removeExtensions = removeExtensions,
-                emitExtensions = emitExtensions,
-                sortProcedure = sortProcedure)
-        self.prefixText       = prefixText
-        self.genFuncPointers  = genFuncPointers
-        self.protectFile      = protectFile
-        self.protectFeature   = protectFeature
-        self.apicall          = apicall
-        self.apientry         = apientry
-        self.apientryp        = apientryp
-        self.alignFuncParam   = alignFuncParam
-        self.library_name     = library_name
-#
-# LoaderVersioningGenerator - subclass of OutputGenerator. Outputs cmake file containing vulkan version used when generating files
-class LoaderVersioningGenerator(OutputGenerator):
-    """Generate helper file based on XML element attributes"""
-    def __init__(self,
-                 errFile = sys.stderr,
-                 warnFile = sys.stderr,
-                 diagFile = sys.stdout):
-        OutputGenerator.__init__(self, errFile, warnFile, diagFile)
-
-    #
-    # Called once at the beginning of each run
-    def beginFile(self, genOpts):
-        OutputGenerator.beginFile(self, genOpts)
-        # User-supplied prefix text, if any (list of strings)
-        self.library_name = genOpts.library_name
-
-        version_major = ''
-        version_minor = ''
-        version_patch = ''
-        for elem in self.registry.reg.find('types').findall('type'):
-            if elem.get('category') == 'define':
-                if elem.get('name') == 'VK_HEADER_VERSION_COMPLETE':
-                    # Parses the following string:
-                    #define <name>VK_HEADER_VERSION_COMPLETE</name> <type>VK_MAKE_API_VERSION</type>(0, 1, 2, VK_HEADER_VERSION)</type>
-                    # The 0th index is the VARIANT version, 1st & 2nd are the Major & Minor
-                    version_major = re.findall("[0-9]+", ''.join(elem.itertext()))[1]
-                    version_minor = re.findall("[0-9]+", ''.join(elem.itertext()))[2]
-                if elem.get('name') == 'VK_HEADER_VERSION':
-                    # Parses the following string:
-                    #define <name>VK_HEADER_VERSION</name> 189</type>
-                    version_patch = re.findall("[0-9]+", ''.join(elem.itertext()))[0]
-
-        # File Comment
-        file_comment = '# *** THIS FILE IS GENERATED - DO NOT EDIT ***\n'
-        file_comment += '# See loader_versioning_generator.py for modifications\n'
-        write(file_comment, file=self.outFile)
-        # Copyright Notice
-        cmake_version_copyright = '''############################################################################
-#
-# Copyright (c) 2021 The Khronos Group Inc.
-# Copyright (c) 2021 Valve Corporation
-# Copyright (c) 2021 LunarG, Inc.
-# Copyright (c) 2021 Google 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.
-#
-# Author: Charles Giessen <charles@lunarg.com>
-#
-############################################################################
-'''
-        write(cmake_version_copyright, file=self.outFile)
-        write(f'set(LOADER_GENERATED_HEADER_VERSION \"{version_major}.{version_minor}.{version_patch}\")', file=self.outFile)
-
-    #
-    # Write generated file content to output file
-    def endFile(self):
-        dest_file = ''
-        # Remove blank lines at EOF
-        if dest_file.endswith('\n'):
-            dest_file = dest_file[:-1]
-        write(dest_file, file=self.outFile)
-        # Finish processing in superclass
-        OutputGenerator.endFile(self)
\ No newline at end of file