From 9e0c022226ec6d17e55d35e0e6f9b38b22c30bbd Mon Sep 17 00:00:00 2001 From: Patrick Wuttke Date: Tue, 8 Jul 2025 08:11:55 +0200 Subject: [PATCH] Fixed recipe for VulkanHeaders and added recipes for SpirVHeaders and SpirVReflect. --- recipes/SpirVHeaders/recipe.py | 26 ++++++++++++++++++++ recipes/SpirVReflect/recipe.py | 43 +++++++++++++++++++++++++++++++++ recipes/VulkanHeaders/recipe.py | 6 ++++- 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 recipes/SpirVHeaders/recipe.py create mode 100644 recipes/SpirVReflect/recipe.py diff --git a/recipes/SpirVHeaders/recipe.py b/recipes/SpirVHeaders/recipe.py new file mode 100644 index 0000000..54ec082 --- /dev/null +++ b/recipes/SpirVHeaders/recipe.py @@ -0,0 +1,26 @@ + + +import re +from SCons.Script import * + + +def _git_cook(env: Environment, repo: dict) -> dict: + vulkan_headers = env.Cook('VulkanHeaders') + checkout_root = repo['checkout_root'] + + return { + 'CPPPATH': [f'{checkout_root}/include'] + } + + +env.GitRecipe( + globals = globals(), + repo_name = 'SpirVHeaders', + repo_url = 'https://github.com/KhronosGroup/SPIRV-Headers.git', + tag_pattern = re.compile(r'^vulkan-sdk-([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$'), + tag_fn = lambda version: f'vulkan-sdk-{version[0]}.{version[1]}.{version[2]}.{version[3]}', + cook_fn = _git_cook, + dependencies = { + 'VulkanHeaders': {} + } +) diff --git a/recipes/SpirVReflect/recipe.py b/recipes/SpirVReflect/recipe.py new file mode 100644 index 0000000..5dfb222 --- /dev/null +++ b/recipes/SpirVReflect/recipe.py @@ -0,0 +1,43 @@ + + +import re +from SCons.Script import * + + +def _git_cook(env: Environment, repo: dict) -> dict: + checkout_root = repo['checkout_root'] + + source_files = [f'{checkout_root}/spirv_reflect.cpp'] + + additional_cxx_flags = [] + additional_cppdefines = ['SPIRV_REFLECT_USE_SYSTEM_SPIRV_H'] + if env['COMPILER_FAMILY'] == 'gcc': + additional_cxx_flags.append('-Wno-overflow') + lib_spirv_reflect = env.StaticLibrary( + CCFLAGS = env['CCFLAGS'] + additional_cxx_flags, + CPPPATH = [repo['checkout_root']], + CPPDEFINES = list(env['CPPDEFINES']) + additional_cppdefines, + target = env['LIB_DIR'] + '/spirv_reflect', + source = source_files, + dependencies = { + 'SpirVHeaders': {} + } + ) + + return { + 'CPPPATH': [repo['checkout_root']], + 'LIBS': [lib_spirv_reflect] + } + + +env.GitRecipe( + globals = globals(), + repo_name = 'SpirVReflect', + repo_url = 'https://github.com/KhronosGroup/SPIRV-Reflect.git', + tag_pattern = re.compile(r'^vulkan-sdk-([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$'), + tag_fn = lambda version: f'vulkan-sdk-{version[0]}.{version[1]}.{version[2]}.{version[3]}', + cook_fn = _git_cook, + dependencies = { + 'SpirVHeaders': {} + } +) diff --git a/recipes/VulkanHeaders/recipe.py b/recipes/VulkanHeaders/recipe.py index fcd8726..5dbf17e 100644 --- a/recipes/VulkanHeaders/recipe.py +++ b/recipes/VulkanHeaders/recipe.py @@ -40,6 +40,10 @@ def cook(env: Environment, version) -> dict: git_ref = f'refs/tags/v{version[0]}.{version[1]}.{version[2]}' repo = env.GitBranch(repo_name = _get_repo_name(env), remote_url = _get_repo_url(env), git_ref = git_ref) checkout_root = repo['checkout_root'] + include_dir = os.path.join(checkout_root, 'include') return { - 'CPPPATH': [os.path.join(checkout_root, 'include')] + 'CPPPATH': [include_dir], + 'CMAKE_VARS': { + 'Vulkan_INCLUDE_DIR': include_dir + } }