summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Ramos <juan@lunarg.com>2023-10-06 16:13:24 -0600
committerJuan Ramos <114601453+juan-lunarg@users.noreply.github.com>2023-10-06 16:51:44 -0600
commit96bad23002d40ad7e7eba3743ff22af1cd24d8f4 (patch)
tree3838674883b800e4ab4651477770d2f67470fbe4
parenta4a8db5a8a9c55f1cd668ecb1bad8b4f66a68d46 (diff)
downloadVulkan-Tools-96bad23002d40ad7e7eba3743ff22af1cd24d8f4.tar.gz
Vulkan-Tools-96bad23002d40ad7e7eba3743ff22af1cd24d8f4.tar.bz2
Vulkan-Tools-96bad23002d40ad7e7eba3743ff22af1cd24d8f4.zip
mock: Ensure VkICD_mock_icd.json uses up to date API version
closes #617
-rw-r--r--.github/workflows/tools.yml12
-rw-r--r--CMakeLists.txt2
-rw-r--r--icd/VkICD_mock_icd.json.in6
-rwxr-xr-xscripts/generate_source.py15
4 files changed, 31 insertions, 4 deletions
diff --git a/.github/workflows/tools.yml b/.github/workflows/tools.yml
index dad2ec9c..99c4b727 100644
--- a/.github/workflows/tools.yml
+++ b/.github/workflows/tools.yml
@@ -208,3 +208,15 @@ jobs:
run: |
cd build-android
./build_all.sh
+
+ tools_codegen:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - uses: actions/setup-python@v4
+ with:
+ python-version: '3.10'
+ - run: sudo apt-get -qq update && sudo apt install libwayland-dev xorg-dev wayland-protocols
+ - run: cmake -S . -B build/ -D UPDATE_DEPS=ON -D UPDATE_DEPS_DIR=external -D TOOLS_CODEGEN=ON
+ - run: cmake --build build --target tools_codegen
+ - run: git diff --exit-code
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 33a9cf84..53042b60 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -123,7 +123,7 @@ if (TOOLS_CODEGEN)
add_custom_target(tools_codegen
COMMAND Python3::Interpreter ${PROJECT_SOURCE_DIR}/scripts/generate_source.py
"${VULKAN_HEADERS_INSTALL_DIR}/${CMAKE_INSTALL_DATADIR}/vulkan/registry"
- --incremental --api ${API_TYPE}
+ --incremental --generated-version ${VulkanHeaders_VERSION} --api ${API_TYPE}
)
endif()
diff --git a/icd/VkICD_mock_icd.json.in b/icd/VkICD_mock_icd.json.in
index f550bb27..56d09300 100644
--- a/icd/VkICD_mock_icd.json.in
+++ b/icd/VkICD_mock_icd.json.in
@@ -1,7 +1,7 @@
{
- "file_format_version" : "1.0.1",
+ "file_format_version": "1.0.1",
"ICD": {
"library_path": "@JSON_LIBRARY_PATH@",
- "api_version": "1.1.97"
+ "api_version": "1.3.267"
}
-}
+} \ No newline at end of file
diff --git a/scripts/generate_source.py b/scripts/generate_source.py
index abd8a754..6c63f0c9 100755
--- a/scripts/generate_source.py
+++ b/scripts/generate_source.py
@@ -22,6 +22,7 @@
import argparse
import filecmp
import os
+import json
import shutil
import subprocess
import sys
@@ -38,6 +39,7 @@ def main(argv):
default='vulkan',
choices=['vulkan', 'vulkansc'],
help='Specify API name to generate')
+ parser.add_argument('--generated-version', help='sets the header version used to generate the repo')
parser.add_argument('registry', metavar='REGISTRY_PATH', help='path to the Vulkan-Headers registry directory')
group = parser.add_mutually_exclusive_group()
group.add_argument('-i', '--incremental', action='store_true', help='only update repo files that change')
@@ -53,6 +55,19 @@ def main(argv):
#base directory for the source repository
repo_dir = common_codegen.repo_relative('')
+ # Update the api_version in the respective json files
+ if args.generated_version:
+ json_files = []
+ json_files.append(common_codegen.repo_relative('icd/VkICD_mock_icd.json.in'))
+ for json_file in json_files:
+ with open(json_file) as f:
+ data = json.load(f)
+
+ data["ICD"]["api_version"] = args.generated_version
+
+ with open(json_file, mode='w', encoding='utf-8', newline='\n') as f:
+ f.write(json.dumps(data, indent=4))
+
# get directory where generators will run if needed
if args.verify or args.incremental:
# generate in temp directory so we can compare or copy later