summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Giessen <charles@lunarg.com>2023-01-03 16:26:23 -0700
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>2023-01-09 12:04:34 -0700
commit15b02f97238be98952233a6830b508063c3200f0 (patch)
tree3e47a615e5a515a10ce62088be1bc13b309d188d
parenta68ebff22ea8e7ec1843fc5db255cf69807a2aa9 (diff)
downloadVulkan-Loader-15b02f97238be98952233a6830b508063c3200f0.tar.gz
Vulkan-Loader-15b02f97238be98952233a6830b508063c3200f0.tar.bz2
Vulkan-Loader-15b02f97238be98952233a6830b508063c3200f0.zip
Add Vulkan-Headers version to source
The version of the Vulkan-Headers used to generate the source code is what should be used to set the version of the binary, rather than the version of the Vulkan-Headers that is currently available. This commit checks that version into the repo so that it is used, and adds the necessary python code to update it. This behavior was previously in the repo but was broken by the update to use the version parsing logic from the Vulkan-Headers.
-rw-r--r--CMakeLists.txt8
-rw-r--r--cmake/generated_header_version.cmake3
-rw-r--r--loader/CMakeLists.txt6
-rwxr-xr-xscripts/generate_source.py9
4 files changed, 21 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e71de78f..8a547b96 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,6 +24,9 @@ set(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM OFF)
project(Vulkan-Loader)
+# Gets the header version used during code generation
+include(cmake/generated_header_version.cmake)
+
if (UPDATE_DEPS)
find_package(PythonInterp 3 REQUIRED)
@@ -322,8 +325,9 @@ if(PYTHONINTERP_FOUND)
get_target_property(VulkanRegistry_DIR Vulkan::Registry INTERFACE_INCLUDE_DIRECTORIES)
add_custom_target(VulkanLoader_generated_source
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/scripts/generate_source.py
- ${VulkanRegistry_DIR} --incremental
- )
+ ${VulkanRegistry_DIR}
+ --generated-version ${VulkanHeaders_VERSION}
+ --incremental)
else()
message("WARNING: VulkanLoader_generated_source target requires python 3")
endif()
diff --git a/cmake/generated_header_version.cmake b/cmake/generated_header_version.cmake
new file mode 100644
index 00000000..958d47e7
--- /dev/null
+++ b/cmake/generated_header_version.cmake
@@ -0,0 +1,3 @@
+# *** THIS FILE IS GENERATED - DO NOT EDIT ***
+# See generate_source.py for modifications
+set(LOADER_GENERATED_HEADER_VERSION 1.3.238) \ No newline at end of file
diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt
index eb6032c7..c48f097c 100644
--- a/loader/CMakeLists.txt
+++ b/loader/CMakeLists.txt
@@ -312,7 +312,7 @@ else()
add_dependencies(vulkan loader_asm_gen_files)
set_target_properties(vulkan
PROPERTIES SOVERSION "1"
- VERSION ${VulkanHeaders_VERSION})
+ VERSION ${LOADER_GENERATED_HEADER_VERSION})
target_link_libraries(vulkan PRIVATE ${CMAKE_DL_LIBS} m)
if (NOT ANDROID)
target_link_libraries(vulkan PRIVATE Threads::Threads)
@@ -351,7 +351,7 @@ else()
OUTPUT_NAME vulkan
FRAMEWORK TRUE
FRAMEWORK_VERSION A
- VERSION "${VulkanHeaders_VERSION}" # "current version"
+ VERSION "${LOADER_GENERATED_HEADER_VERSION}" # "current generated version"
SOVERSION "1.0.0" # "compatibility version"
MACOSX_FRAMEWORK_IDENTIFIER com.lunarg.vulkanFramework
PUBLIC_HEADER "${FRAMEWORK_HEADERS}"
@@ -375,7 +375,7 @@ endif()
# Generate pkg-config file.
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
- set(VK_API_VERSION "${VulkanHeaders_VERSION}")
+ set(VK_API_VERSION "${LOADER_GENERATED_HEADER_VERSION}")
set(PRIVATE_LIBS "")
if (APPLE AND BUILD_STATIC_LOADER)
# Libs.private should only be present when building a static loader
diff --git a/scripts/generate_source.py b/scripts/generate_source.py
index 712747b8..59cabaea 100755
--- a/scripts/generate_source.py
+++ b/scripts/generate_source.py
@@ -33,6 +33,7 @@ verify_exclude = ['.clang-format']
def main(argv):
parser = argparse.ArgumentParser(description='Generate source code for this repository')
parser.add_argument('registry', metavar='REGISTRY_PATH', help='path to the Vulkan-Headers registry directory')
+ parser.add_argument('--generated-version', help='sets the header version used to generate the repo')
group = parser.add_mutually_exclusive_group()
group.add_argument('-i', '--incremental', action='store_true', help='only update repo files that change')
group.add_argument('-v', '--verify', action='store_true', help='verify repo files match generator output')
@@ -106,6 +107,14 @@ def main(argv):
print('update', repo_filename)
shutil.copyfile(temp_filename, repo_filename)
+ # write out the header version used to generate the code to a checked in CMake FIle
+ if args.generated_version:
+ f = open(common_codegen.repo_relative('cmake/generated_header_version.cmake'), "w")
+ f.write('# *** THIS FILE IS GENERATED - DO NOT EDIT ***\n')
+ f.write('# See generate_source.py for modifications\n')
+ f.write(f'set(LOADER_GENERATED_HEADER_VERSION {args.generated_version})')
+ f.close()
+
return 0
if __name__ == '__main__':