From 96bad23002d40ad7e7eba3743ff22af1cd24d8f4 Mon Sep 17 00:00:00 2001 From: Juan Ramos Date: Fri, 6 Oct 2023 16:13:24 -0600 Subject: mock: Ensure VkICD_mock_icd.json uses up to date API version closes #617 --- .github/workflows/tools.yml | 12 ++++++++++++ CMakeLists.txt | 2 +- icd/VkICD_mock_icd.json.in | 6 +++--- scripts/generate_source.py | 15 +++++++++++++++ 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 -- cgit v1.2.3